srs之2.0对纯音频的流进行HLS,苹果系统播放卡顿伴有杂音的问题
来源:互联网 发布:衣服淘宝店名大全 编辑:程序博客网 时间:2024/04/28 20:09
https://github.com/ossrs/srs/issues/512
RTMP 流是通过FMLE 推送到SRS 是纯音频 AAC 格式的
SRS日志,音频采样率是多少?
[2015-10-27 10:08:08.715][trace][26340][0] srs checking config...[2015-10-27 10:08:08.715][trace][26340][0] detect intranet address: 127.0.0.1, ifname=lo[2015-10-27 10:08:08.715][trace][26340][0] retrieve local ipv4 ip=10.12.4.61, index=0[2015-10-27 10:08:08.716][trace][26340][0] detect intranet address: 10.12.4.61, ifname=eth0[2015-10-27 10:08:08.716][trace][26340][0] retrieve local ipv4 ip=172.17.42.1, index=1[2015-10-27 10:08:08.716][trace][26340][0] detect intranet address: 172.17.42.1, ifname=docker0[2015-10-27 10:08:08.716][warn][26340][0][0] stats network use index=0, ip=10.12.4.61[2015-10-27 10:08:08.716][warn][26340][0][0] stats disk not configed, disk iops disabled.[2015-10-27 10:08:08.716][trace][26340][0] write log to file ./objs/srs.log[2015-10-27 10:08:08.716][trace][26340][0] you can: tailf ./objs/srs.log[2015-10-27 10:08:08.716][trace][26340][0] @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_SrsLog[2015-10-27 10:08:08.716][trace][26340][0] srs(simple-rtmp-server) 2.0.195[2015-10-27 10:08:08.716][trace][26340][0] license: The MIT License (MIT), Copyright (c) 2013-2015 SRS(simple-rtmp-server)[2015-10-27 10:08:08.716][trace][26340][0] primary/master: SRS/1.0release[2015-10-27 10:08:08.716][trace][26340][0] authors: winlin,wenjie.zhao[2015-10-27 10:08:08.716][trace][26340][0] contributors: winlin<winlin@vip.126.com> wenjie.zhao<740936897@qq.com> xiangcheng.liu<liuxc0116@foxmail.com> naijia.liu<youngcow@youngcow.net> alcoholyi<alcoholyi@qq.com> byteman<wangchen2011@gmail.com> chad.wang<chad.wang.cn@gmail.com> suhetao<suhetao@gmail.com> Johnny<fengjihu@163.com> karthikeyan<keyanmca@gmail.com> StevenLiu<lq@chinaffmpeg.org> zhengfl<zhengfl_1989@126.com> tufang14<breadbean1449@gmail.com> allspace<allspace@gmail.com> niesongsong<nie950@gmail.com> rudeb0t<nimrod@themanxgroup.tw> [2015-10-27 10:08:08.716][trace][26340][0] uname: Linux MediaWiki 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux[2015-10-27 10:08:08.716][trace][26340][0] build: 2015-10-26 16:49:02, little-endian[2015-10-27 10:08:08.716][trace][26340][0] configure: --disable-all --with-ssl --with-hls --with-nginx --with-ffmpeg --with-transcode[2015-10-27 10:08:08.716][trace][26340][0] features: --prefix=/usr/local/srs --with-hls --without-hds --without-dvr --with-nginx --with-ssl --with-ffmpeg --with-transcode --without-ingest --without-stat --without-http-callback --without-http-server --without-stream-caster --without-http-api --without-librtmp --without-research --without-utest --without-gperf --without-gmc --without-gmp --without-gcp --without-gprof --without-arm-ubuntu12 --without-mips-ubuntu12 --log-trace[2015-10-27 10:08:08.716][trace][26340][0] conf: conf/hls.conf, limit: 1000[2015-10-27 10:08:08.716][trace][26340][0] writev limits write 1024 iovs a time[2015-10-27 10:08:08.716][warn][26340][0][0] SRS 2.0.195 is not stable, please use stable branch 1.0release instead[2015-10-27 10:08:08.716][trace][26340][0] cpu is amd64, glibc 2.12[2015-10-27 10:08:08.716][trace][26340][0] cpu is x86_64, glibc 2.12[2015-10-27 10:08:08.716][trace][26340][0] check feature rtmp handshake: on[2015-10-27 10:08:08.716][trace][26340][0] check feature hls: on[2015-10-27 10:08:08.716][warn][26340][0][0] check feature hds: off[2015-10-27 10:08:08.716][warn][26340][0][0] check feature http callback: off[2015-10-27 10:08:08.716][warn][26340][0][0] check feature http api: off[2015-10-27 10:08:08.716][warn][26340][0][0] check feature http server: off[2015-10-27 10:08:08.716][warn][26340][0][0] check feature http parser: off[2015-10-27 10:08:08.716][warn][26340][0][0] check feature dvr: off[2015-10-27 10:08:08.716][trace][26340][0] check feature transcode: on[2015-10-27 10:08:08.716][warn][26340][0][0] check feature ingest: off[2015-10-27 10:08:08.716][warn][26340][0][0] check feature system stat: off[2015-10-27 10:08:08.716][trace][26340][0] check feature compile nginx: on[2015-10-27 10:08:08.716][trace][26340][0] check feature compile ffmpeg: on[2015-10-27 10:08:08.716][warn][26340][0][0] stream caster: off[2015-10-27 10:08:08.716][trace][26340][0] MR(merged-read): on, @see https://github.com/simple-rtmp-server/srs/issues/241[2015-10-27 10:08:08.716][trace][26340][0] MR(merged-read) default 0 sleep 350[2015-10-27 10:08:08.716][trace][26340][0] MW(merged-write) default sleep 350[2015-10-27 10:08:08.716][trace][26340][0] read chunk stream cache cid [0, 16)[2015-10-27 10:08:08.716][trace][26340][0] default gop cache 1, play queue 30s[2015-10-27 10:08:08.716][trace][26340][0] complex send algorithm enabled.[2015-10-27 10:08:08.716][warn][26340][0][0] TCP_NODELAY enabled, may hurts performance.[2015-10-27 10:08:08.716][trace][26340][0] auto guess socket send buffer by merged write[2015-10-27 10:08:08.716][trace][26340][0] system default latency in ms: mw(0-350) + mr(0-350) + play-queue(0-30000)[2015-10-27 10:08:08.716][trace][26340][0] start deamon mode...[2015-10-27 10:08:08.716][trace][26341][0] father process exit. ret=0[2015-10-27 10:08:08.716][trace][26342][0] son(deamon) process running.[2015-10-27 10:08:08.716][trace][26342][0] st_set_eventsys to epoll[2015-10-27 10:08:08.717][trace][26342][0] st_init success, use epoll[2015-10-27 10:08:08.717][trace][26340][0] grandpa process exit.[2015-10-27 10:08:08.717][trace][26342][100] server main cid=100[2015-10-27 10:08:08.717][trace][26342][100] write pid=26342 to ./objs/srs.pid success![2015-10-27 10:08:08.727][trace][26342][100] RTMP listen at tcp://0.0.0.0:1935, fd=8[2015-10-27 10:08:08.727][trace][26342][100] signal installed[2015-10-27 10:08:10.605][trace][26342][104] RTMP client ip=10.16.0.3[2015-10-27 10:08:10.605][trace][26342][104] srand initialized the random.[2015-10-27 10:08:10.607][trace][26342][104] simple handshake success.[2015-10-27 10:08:10.607][trace][26342][104] connect app, tcUrl=rtmp://10.12.4.61/live, pageUrl=, swfUrl=rtmp://10.12.4.61/live, schema=rtmp, vhost=__defaultVhost__, port=1935, app=live, args=null[2015-10-27 10:08:10.607][trace][26342][104] out chunk size to 60000[2015-10-27 10:08:10.845][trace][26342][104] client identified, type=fmle-publish, stream_name=mytest1, duration=-1.00[2015-10-27 10:08:10.855][trace][26342][104] source url=/live/mytest1, ip=10.16.0.3, cache=1, is_edge=0, source_id=-1[-1][2015-10-27 10:08:11.041][trace][26342][104] hls: win=60.00, frag=5.00, prefix=, path=./objs/nginx/html, m3u8=[app]/[stream].m3u8, ts=[app]/[stream]-[seq].ts, aof=1.00, floor=0, clean=1, waitk=1, dispose=0[2015-10-27 10:08:11.052][trace][26342][104] start publish mr=0/350, p1stpt=20000, pnt=20000, tcp_nodelay=0, rtcid=106[2015-10-27 10:08:11.382][trace][26342][104] got metadata[2015-10-27 10:08:11.382][trace][26342][104] 4B audio sh, codec(10, profile=LC, 2channels, 0kbps, 44100HZ), flv(16bits, 2channels, 44100HZ)[2015-10-27 10:08:11.382][trace][26342][104] input chunk size to 366[2015-10-27 10:08:11.386][trace][26342][104] input chunk size to 398[2015-10-27 10:08:11.386][trace][26342][104] audio drop ts segment, sequence_no=0, uri=mytest1-0.ts, duration=59839.19, start=0[2015-10-27 10:08:11.391][trace][26342][104] input chunk size to 410[2015-10-27 10:08:11.396][trace][26342][104] input chunk size to 501[2015-10-27 10:08:14.896][trace][26342][104] input chunk size to 505[2015-10-27 10:08:15.399][trace][26342][104] input chunk size to 514[2015-10-27 10:08:16.394][trace][26342][104] input chunk size to 528[2015-10-27 10:08:22.397][trace][26342][104] input chunk size to 539[2015-10-27 10:08:32.885][trace][26342][104] input chunk size to 545[2015-10-27 10:08:51.052][trace][26342][104] <- CPB time=20001, okbps=0,0,0, ikbps=129,129,0, mr=0/350, p1stpt=20000, pnt=20000
FMLE 配置是 format:AAC Channels:Stereo Sample Rate:44100 Hz Bit Rate:128 Kbps
把码率降低到64试试看。另外,把切片和m3u8发给我吧,可以打包传网盘上。
http://pan.baidu.com/s/1eQDGevo
调整后将 FMLE 配置修改为 format:AAC Channels:Stereo Sample Rate:44100 Hz Bit Rate:48 Kbps
依然出现苹果系统播放纯音频会有 “噗噗 ”噗噗“的 有规律的杂音。
RTMP转TS爆音,原因是因为RTMP的TBN是1/1000也就是毫秒为单位,但是TS是1/90000也就是1/90毫秒为单位,所以TS的分辨率更高。
从低分辨率转高分辨率,需要重新计算时间戳。这个在SRS1/nginx-rtmp是有的,但是计算后貌似解决的不完善。SRS2就没有计算,直接用RTMP的时间戳。
这个可能会有爆音的问题,基本上就是一个切片一次;因此如果能增大切片到10秒或者30秒,这个影响会很小。
不过我会fix它,看怎么解决得最完善。你可以把切片弄大,确认是不是这个问题。
我听了下,5秒会有一次顿的感觉,但是噗噗的那个杂音是一直都有的。
你是否能把RTMP流也录制下来,把RTMP和对应的TS都发给我?
我发现了,是pcr写得太多了,其实没有必要的。
每次pcr都会造成这种RTMP和TS的时间戳误差,导致噗噗的声音,还有片和片之间的大的间隙。
C:\Desktop\rtmpdump-2.4-git-010913-windows>rtmpdump.exe -r rtmp://10.12.4.61:1935/live/mytest -v -B 10 -o out.flv
RTMPDump v2.4
(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
Connecting ...
INFO: Connected...
Starting Live Stream
For duration: 10.000 sec
INFO: Metadata:
INFO: presetname Custom
INFO: creationdate Tue Oct 27 11:01:12 2015
INFO: audiodevice IN 1+2 (Digigram PCX924e)
INFO: audiosamplerate 44100.00
INFO: audiochannels 2.00
INFO: audioinputvolume 59.00
INFO: audiocodecid mp4a
INFO: audiodatarate 48.00
INFO: server SRS/2.0.195(ZhouGuowen)
INFO: srs_primary SRS/1.0release
INFO: srs_authors winlin,wenjie.zhao
INFO: server_version 2.0.195
64.294 kB / 9.70 sec
ERROR: RTMP_ReadPacket, failed to read RTMP packet header
66.581 kB / 10.05 sec
Download complete
http://pan.baidu.com/s/1sjzM1iP
上面是用rtmpdump 工具录制了rtmp 流
我调整了hls.conf 配置如下:
listen 1935;
max_connections 1000;
vhost defaultVhost {
hls {
enabled on;
hls_fragment 30;
hls_window 60;
hls_acodec aac;
hls_vcodec vn;
hls_aof_ratio 1.0;
hls_path ./objs/nginx/html;
hls_m3u8_file [app]/[stream].m3u8;
hls_ts_file [app]/[stream]-[seq].ts;
}
备注 :将 hls_fragment 参数修改为30 了
下面是目前的启动日志与环境:
[2015-10-27 11:59:25.257][trace][26675][0] srs checking config...
[2015-10-27 11:59:25.257][trace][26675][0] detect intranet address: 127.0.0.1, ifname=lo
[2015-10-27 11:59:25.257][trace][26675][0] retrieve local ipv4 ip=10.12.4.61, index=0
[2015-10-27 11:59:25.257][trace][26675][0] detect intranet address: 10.12.4.61, ifname=eth0
[2015-10-27 11:59:25.258][trace][26675][0] retrieve local ipv4 ip=172.17.42.1, index=1
[2015-10-27 11:59:25.258][trace][26675][0] detect intranet address: 172.17.42.1, ifname=docker0
[2015-10-27 11:59:25.258][warn][26675][0][0] stats network use index=0, ip=10.12.4.61
[2015-10-27 11:59:25.258][warn][26675][0][0] stats disk not configed, disk iops disabled.
[2015-10-27 11:59:25.258][trace][26675][0] write log to file ./objs/srs.log
[2015-10-27 11:59:25.258][trace][26675][0] you can: tailf ./objs/srs.log
[2015-10-27 11:59:25.258][trace][26675][0] @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_SrsLog
[2015-10-27 11:59:25.258][trace][26675][0] srs(simple-rtmp-server) 2.0.195
[2015-10-27 11:59:25.258][trace][26675][0] license: The MIT License (MIT), Copyright (c) 2013-2015 SRS(simple-rtmp-server)
[2015-10-27 11:59:25.258][trace][26675][0] primary/master: SRS/1.0release
[2015-10-27 11:59:25.258][trace][26675][0] authors: winlin,wenjie.zhao
[2015-10-27 11:59:25.258][trace][26675][0] contributors: winlinwinlin@vip.126.comwenjie.zhao740936897@qq.com xiangcheng.liuliuxc0116@foxmail.comnaijia.liuyoungcow@youngcow.net alcoholyialcoholyi@qq.com bytemanwangchen2011@gmail.comchad.wangchad.wang.cn@gmail.com suhetaosuhetao@gmail.com Johnnyfengjihu@163.comkarthikeyankeyanmca@gmail.com StevenLiulq@chinaffmpeg.org zhengflzhengfl_1989@126.comtufang14breadbean1449@gmail.com allspaceallspace@gmail.com niesongsongnie950@gmail.comrudeb0tnimrod@themanxgroup.tw
[2015-10-27 11:59:25.258][trace][26675][0] uname: Linux MediaWiki 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[2015-10-27 11:59:25.258][trace][26675][0] build: 2015-10-26 16:49:02, little-endian
[2015-10-27 11:59:25.258][trace][26675][0] configure: --disable-all --with-ssl --with-hls --with-nginx --with-ffmpeg --with-transcode
[2015-10-27 11:59:25.258][trace][26675][0] features: --prefix=/usr/local/srs --with-hls --without-hds --without-dvr --with-nginx --with-ssl --with-ffmpeg --with-transcode --without-ingest --without-stat --without-http-callback --without-http-server --without-stream-caster --without-http-api --without-librtmp --without-research --without-utest --without-gperf --without-gmc --without-gmp --without-gcp --without-gprof --without-arm-ubuntu12 --without-mips-ubuntu12 --log-trace
[2015-10-27 11:59:25.258][trace][26675][0] conf: conf/hls.conf, limit: 1000
[2015-10-27 11:59:25.258][trace][26675][0] writev limits write 1024 iovs a time
[2015-10-27 11:59:25.258][warn][26675][0][0] SRS 2.0.195 is not stable, please use stable branch 1.0release instead
[2015-10-27 11:59:25.258][trace][26675][0] cpu is amd64, glibc 2.12
[2015-10-27 11:59:25.258][trace][26675][0] cpu is x86_64, glibc 2.12
[2015-10-27 11:59:25.258][trace][26675][0] check feature rtmp handshake: on
[2015-10-27 11:59:25.258][trace][26675][0] check feature hls: on
[2015-10-27 11:59:25.258][warn][26675][0][0] check feature hds: off
[2015-10-27 11:59:25.258][warn][26675][0][0] check feature http callback: off
[2015-10-27 11:59:25.258][warn][26675][0][0] check feature http api: off
[2015-10-27 11:59:25.258][warn][26675][0][0] check feature http server: off
[2015-10-27 11:59:25.258][warn][26675][0][0] check feature http parser: off
[2015-10-27 11:59:25.258][warn][26675][0][0] check feature dvr: off
[2015-10-27 11:59:25.258][trace][26675][0] check feature transcode: on
[2015-10-27 11:59:25.258][warn][26675][0][0] check feature ingest: off
[2015-10-27 11:59:25.258][warn][26675][0][0] check feature system stat: off
[2015-10-27 11:59:25.258][trace][26675][0] check feature compile nginx: on
[2015-10-27 11:59:25.258][trace][26675][0] check feature compile ffmpeg: on
[2015-10-27 11:59:25.258][warn][26675][0][0] stream caster: off
[2015-10-27 11:59:25.258][trace][26675][0] MR(merged-read): on, @see #241
[2015-10-27 11:59:25.258][trace][26675][0] MR(merged-read) default 0 sleep 350
[2015-10-27 11:59:25.258][trace][26675][0] MW(merged-write) default sleep 350
[2015-10-27 11:59:25.258][trace][26675][0] read chunk stream cache cid [0, 16)
[2015-10-27 11:59:25.258][trace][26675][0] default gop cache 1, play queue 30s
[2015-10-27 11:59:25.258][trace][26675][0] complex send algorithm enabled.
[2015-10-27 11:59:25.258][warn][26675][0][0] TCP_NODELAY enabled, may hurts performance.
[2015-10-27 11:59:25.258][trace][26675][0] auto guess socket send buffer by merged write
[2015-10-27 11:59:25.258][trace][26675][0] system default latency in ms: mw(0-350) + mr(0-350) + play-queue(0-30000)
[2015-10-27 11:59:25.258][trace][26675][0] start deamon mode...
[2015-10-27 11:59:25.258][trace][26676][0] father process exit. ret=0
[2015-10-27 11:59:25.259][trace][26675][0] grandpa process exit.
[2015-10-27 11:59:25.259][trace][26677][0] son(deamon) process running.
[2015-10-27 11:59:25.259][trace][26677][0] st_set_eventsys to epoll
[2015-10-27 11:59:25.259][trace][26677][0] st_init success, use epoll
[2015-10-27 11:59:25.259][trace][26677][100] server main cid=100
[2015-10-27 11:59:25.260][trace][26677][100] write pid=26677 to ./objs/srs.pid success!
[2015-10-27 11:59:25.270][trace][26677][100] RTMP listen at tcp://0.0.0.0:1935, fd=8
[2015-10-27 11:59:25.270][trace][26677][100] signal installed
[2015-10-27 11:59:25.547][trace][26677][104] RTMP client ip=192.168.11.53
[2015-10-27 11:59:25.547][trace][26677][104] srand initialized the random.
[2015-10-27 11:59:25.548][trace][26677][104] simple handshake success.
[2015-10-27 11:59:25.548][trace][26677][104] connect app, tcUrl=rtmp://10.12.4.61:1935/live, pageUrl=, swfUrl=rtmp://10.12.4.61:1935/live, schema=rtmp, vhost=defaultVhost, port=1935, app=live, args=null
[2015-10-27 11:59:25.548][trace][26677][104] out chunk size to 60000
[2015-10-27 11:59:28.795][trace][26677][106] RTMP client ip=10.16.0.3
[2015-10-27 11:59:28.796][trace][26677][106] simple handshake success.
[2015-10-27 11:59:28.796][trace][26677][106] connect app, tcUrl=rtmp://10.12.4.61/live, pageUrl=, swfUrl=rtmp://10.12.4.61/live, schema=rtmp, vhost=defaultVhost, port=1935, app=live, args=null
[2015-10-27 11:59:28.796][trace][26677][106] out chunk size to 60000
[2015-10-27 11:59:29.045][trace][26677][106] client identified, type=fmle-publish, stream_name=mytest, duration=-1.00
[2015-10-27 11:59:29.055][trace][26677][106] source url=/live/mytest, ip=10.16.0.3, cache=1, is_edge=0, source_id=-1[-1]
[2015-10-27 11:59:29.255][trace][26677][106] hls: win=60.00, frag=30.00, prefix=, path=./objs/nginx/html, m3u8=[app]/[stream].m3u8, ts=[app]/[stream]-[seq].ts, aof=1.00, floor=0, clean=1, waitk=1, dispose=0
[2015-10-27 11:59:29.265][trace][26677][106] start publish mr=0/350, p1stpt=20000, pnt=20000, tcp_nodelay=0, rtcid=108
[2015-10-27 11:59:29.982][trace][26677][106] got metadata
[2015-10-27 11:59:29.989][trace][26677][106] 4B audio sh, codec(10, profile=LC, 2channels, 0kbps, 44100HZ), flv(16bits, 2channels, 44100HZ)
[2015-10-27 11:59:29.989][trace][26677][106] input chunk size to 143
[2015-10-27 11:59:29.989][trace][26677][106] input chunk size to 154
[2015-10-27 11:59:29.989][trace][26677][106] audio drop ts segment, sequence_no=0, uri=mytest-0.ts, duration=3343.64, start=0
[2015-10-27 11:59:30.491][trace][26677][106] input chunk size to 158
[2015-10-27 11:59:32.483][trace][26677][106] input chunk size to 161
[2015-10-27 11:59:37.484][trace][26677][106] input chunk size to 163
[2015-10-27 11:59:38.484][trace][26677][106] input chunk size to 166
[2015-10-27 11:59:40.499][trace][26677][106] input chunk size to 193
[2015-10-27 11:59:41.996][trace][26677][106] input chunk size to 197
[2015-10-27 11:59:45.987][trace][26677][106] input chunk size to 199
[2015-10-27 11:59:55.500][trace][26677][106] input chunk size to 211
[2015-10-27 11:59:55.747][warn][26677][104][62] client disconnect peer. ret=1004
[2015-10-27 11:59:59.762][trace][26677][110] RTMP client ip=192.168.11.53
[2015-10-27 11:59:59.762][trace][26677][110] simple handshake success.
[2015-10-27 11:59:59.762][trace][26677][110] connect app, tcUrl=rtmp://10.12.4.61:1935/live, pageUrl=, swfUrl=rtmp://10.12.4.61:1935/live, schema=rtmp, vhost=defaultVhost, port=1935, app=live, args=null
[2015-10-27 11:59:59.763][trace][26677][110] out chunk size to 60000
[2015-10-27 12:00:09.265][trace][26677][106] <- CPB time=20000, okbps=0,0,0, ikbps=51,51,0, mr=0/350, p1stpt=20000, pnt=20000
这是目前30S 切片
http://pan.baidu.com/s/1i3523lF
目前听 噗噗 噗噗声的确没那么明显了 但是断断续续情况还是有
不能用rtmpdump录制,用srs_rtmp_dump,编译出来的objs目录下有的。
rtmpdump会改时间戳。
好的
[root@ objs]# ./srs_rtmp_dump -r rtmp://127.0.0.1:1935/live/mytest -o output.flv
通过srs_rtmp_dump 截图rtmp流
http://pan.baidu.com/s/1eQrvxHC
请问您刚说的 关于(每次pcr都会造成这种RTMP和TS的时间戳误差,导致噗噗的声音,还有片和片之间的大的间隙。)
可以通过修改配置文件参数实现改善吗?
貌似没有精度的问题,我以前弄清楚了,可惜现在又忘记了,翻笔记也不记得了。
有可能是nginx-rtmp为了降低HLS的overload,将多个aac frame组合到一起写入ts,这个时候就需要计算时间差之类的。
我会弄清楚并fix这个问题的。
好的 并且刚试了下SRS_1.0 发现好像不支持 hls_acodec 与 hls_vcodec 参数是吧
我改成每个audio包写入,但是这样会增加HLS的开销(overhead),这个可以通过改变Audio的码率来避免。推荐的码率是:
实例视频doc/source.200kbps.768x320.flv
,视频码率是212kbps,音频码率:
30kbps时,TS大小358892,FLV大小294177,overhead是21.9%。
48kbps时,TS大小361336,FLV大小317177,overhead是13.9%。
54kbps时,TS大小382768,FLV大小324831,overhead是17.8%。
因此音频码率在48和54之间时,overhead最小;如果视频码率变大,音频的影响会更小。
那是需要修改源代码还是修改配置文件呢?
好的 我音频码率调整到48-54之间 目前码率是48
这个没有影响,只是开销大,也就是浪费的字节多而已。
我看视频和音频已经没有问题了;纯音频还在看,还是有噗噗的声音。
几乎可以确认和dts相关,但是和pcr没有关系。
1. video+audio的情况,可以每个audio写入一个frame,一个一个写没有问题,就是开销大点。
2. audio only时,必须不能一个audio一个audio的写,这样没法播放,必须将多个audio写成一个frame。
for #512, write audio frame by frame for video+audio hls.
3683f06
for #512, partical hotfix the hls pure audio. 2.0.196
d1979c7
2.0.196
视频+音频没有问题。
纯音频稍微好点了,有时候还是有破音,但是已经好很多了。
这个问题我一时间没法解决,不知道IOS播放器的行为。
SRS2先这么弄了,SRS3再好好解决这个问题。
for #512, make the segment more acceptable, when in [min, max_td * 2]…
3b0bf1e
好的 我会持续关注SRS 产品的,非常感谢您在百忙之中回复问题。
近期我会在下载 2.0.196 版本在测试下
是的 之前在测试过程中也发现只要开启 VIDEO 与AUDIO IOS 播放就正常了,这回明白咋回事了。
refer to #547
音频的dts要均匀,不均匀就会出现噗噗的声音(音视频都有的情况下),纯音频还没试过
是音频的累计误差造成的,譬如,对于AV流(包含音频和视频的流),如果将多个RTMP的Audio包组合成一个AAC的包(这样可以节省ts的payload),那么这些包组合起来的总长度,应该通过重新计算AAC的时间戳(即采样个数和采样率算出来,AAC一般固定为1024字节一个采样,可以解析后获得)。
假设有10个A:A0-A9,那么它们从原始编码器出来的时间戳转成RTMP的1/1000后是丢失精度了的,所以把10个包的误差弄成一个,就会显示出来它们的误差,譬如它们的RTMP时间戳是A0为100毫秒,A9为300毫秒,实际上组合成一个AAC的frame后可能时303毫秒之类的,下一个RTMP的时间戳时300毫秒,所以就会造成一些间隙。
所以对于组合多个RTMP的AAC包到TS的包,必须重新计算时间戳,NGINX-RTMP那种直接用1024字节作为采样长度,是不准确的。SRS对于AV流没有组合Audio包的情况,也是可以的;不过对于纯音频必须得组合包,不然无法播放。
我会找时间完全fix。
今天上午查了查,大概是这样
一个AAC Frame由1024个采样样本(不是1024Bytes)编码得到
一个Audio Frame播放时间(单位s) = 一个AAC Frame对应的采样样本个数 / 采样频率
假如 SampleRate 为 44100Hz,根据上面,这个Audio Frame播放时间 = 1024/44100 = 0.02232s * 1000 =22.32ms
pts的base_clock 按照1000ms计算,复用到ts里,base_clock是90k,所以还应该再乘以90。
所以我看https://github.com/arut/nginx-rtmp-module/blob/e08959247dc840bb42cdf3389b1f5edb5686825f/hls/ngx_rtmp_hls_module.c#L1809
est_pts = ctx->aframe_base + ctx->aframe_num * 90 * 1000 * 1024 / codec_ctx->sample_rate;
貌似多个Frame合并,计算pts,没有问题啊?
@winlinvip
你没有看到他注释了TODO么?
/* TODO: We assume here AAC frame size is 1024 * Need to handle AAC frames with frame size of 960 */
而且只是说明了如何计算,没有说明为何要这么计算(根据采样重新计算时间戳,而不是用rtmp的时间戳)。
这个才是我看来最大的问题,其实hls没有必要计算,只有在纯音频合并frame时才有必要。
hls如果音视频流都有,可以一个audio frame写入,不需要计算dts,直接用rtmp的没有问题。
1024 or 960 for AAC-LC
2048 or 1920 for HE-AAC (v2)
512 or 480 for AAC-LD and AAC-ELD
编码一次需要的采样样本数量由什么决定?
搞清楚这个,他那个need to就解决了吧
根据AAC采样数目计算dts,是由tbn决定的,这个是清楚的呢。
flv的tbn是1/1000,ts的tbn是1/90000,ts的精度更高,实际上原始编码器出flv/rtmp时,也是损失了精度的。
AAC Audio - Encoder Delay and Synchronization
https://developer.apple.com/library/content/technotes/tn2258/_index.html
这里也说得不清不楚的,也许要好好看看fdkaac的源码才能明白了。
- srs之2.0对纯音频的流进行HLS,苹果系统播放卡顿伴有杂音的问题
- 树莓派播放音频杂音问题
- 笔记本电脑 音频输出 杂音 问题的解决方案
- 解决RTMP推送时间戳问题引起HLS切片不均匀导致手机浏览器播放卡顿的问题
- 解决RTMP推送时间戳问题引起HLS切片不均匀导致手机浏览器播放卡顿的问题
- srs之使用10倍代码的HLS
- 使用lame转换音频时遇到的杂音问题
- 使用lame转换音频时遇到的杂音问题
- srs之hls
- 导航软件后台播放语音有杂音,卡顿
- [4] ffmpeg + SDL2 实现的有杂音的音频播放器
- 对rtmp流进行简单的收录
- [5] ffmpeg+SDL2实现的音频播放器V2.0(无杂音)
- srs之hls热备
- 虚拟ubuntu系统中浏览器的音频播放问题
- RTMP转HLS音频爆音的问题
- iphone开发之音频播放类AVAudioPlayer的使用——加纯代码案例
- DirectSound 播放声音杂音问题.
- Tesseract-OCR引擎 入门
- 第11课:Spark Streaming源码解读之Driver中的ReceiverTracker架构设计以及具体实现彻底研究
- ffmpeg学习笔记(6)
- wildfly8.1部署注意事项
- Codeforces Round #346 (Div. 2)-E. New Reform
- srs之2.0对纯音频的流进行HLS,苹果系统播放卡顿伴有杂音的问题
- Android按钮事件的四种写法(activity跳转)
- 20161028 Python 读书笔记之类、多态、继承、封装
- NYOJ - 436 - sum of all integer numbers(注意a<0)
- C++基础总结1
- php之文件与目录
- 关于CLASS , SEL, IMP的说明
- Spring-02-各种类型信息的注入配置格式
- 一起用HTML5 canvas做一个简单又骚气的粒子引擎
拓扑是 RTMP ------> SRS ------> IOS