Opened 12 years ago
Last modified 12 years ago
#2360 new defect
FFmpeg rtp streaming was not synchronous
Reported by: | Ken | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | ffmpeg |
Version: | 1.1.3 | Keywords: | rtp synchronous |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug:
Hello,I use ffmpeg-1.1.3 and deliver stream to darwin server.
First,I create a sdp data.
ffmpeg -f video4linux2 -s 720:480 -i /dev/video0 -f alsa -i hw:0,0 -an -vcodec libx264 -pix_fmt yuv420p -s 176x144 -b 104k -r 12 -profile baseline -level 30 -flags +global_header -f rtp rtp://XXXIP:20000 -vn -flags +global_header -acodec libfaac -ac 1 -ar 16000 -ab 16k -f rtp rtp://XXXIP:20002>test.sdp
SDP Data
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
t=0 0
a=tool:libavformat 54.59.106
m=video 20000 RTP/AVP 96
c=IN IP4 XXXIP
b=AS:104
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z0LAHtkCxOhAAAADAEAAAAYDxYuS,aMuMsg==; profile-level-id=42C01E
m=audio 20002 RTP/AVP 97
c=IN IP4 XXXIP
b=AS:16
a=rtpmap:97 MPEG4-GENERIC/16000/1
a=fmtp:97 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=1408
Second,I copy the sdp data in Darwin Server /usr/local/movies/
and remove the word "SDP:"
Third,
Play ffmpeg
ffmpeg -f video4linux2 -s 720:480 -i /dev/video0 -f alsa -i hw:0,0 -an -vcodec libx264 -pix_fmt yuv420p -s 176x144 -b 104k -r 12 -profile baseline -level 30 -flags +global_header -f rtp rtp://XXXIP:20000 -vn -flags +global_header -acodec libfaac -ac 1 -ar 16000 -ab 16k -f rtp rtp://XXXIP:20002
But,I use feature phone(rtsp),it has no audio,so I fix the parameter.(add -rtpflags latm)
ffmpeg -f video4linux2 -s 720:480 -i /dev/video0 -f alsa -i hw:0,0 -an -vcodec libx264 -pix_fmt yuv420p -s 176x144 -b 104k -r 12 -profile baseline -level 30 -flags +global_header -f rtp rtp://XXXIP:20000 -vn -flags +global_header -rtpflags latm -acodec libfaac -ac 1 -ar 16000 -ab 16k -f rtp rtp://XXXIP:20002>test.sdp
SDP Data:
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
t=0 0
a=tool:libavformat 54.59.106
m=video 20000 RTP/AVP 96
c=IN IP4 XXXIP
b=AS:104
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z0LAHtkCxOhAAAADAEAAAAYDxYuS,aMuMsg==; profile-level-id=42C01E
m=audio 20002 RTP/AVP 97
c=IN IP4 XXXIP
b=AS:16
a=rtpmap:97 MP4A-LATM/16000/1
a=fmtp:97 profile-level-id=40;cpresent=0;config=400028103fc0
It look perfectly,but the sound is faster than video.
So,have anyone known how to sovle it?
Thanks
Change History (3)
comment:1 by , 12 years ago
Keywords: | synchronous added; simultaneously removed |
---|---|
Summary: | FFmpeg rtp streaming was not simultaneously → FFmpeg rtp streaming was not synchronous |
comment:2 by , 12 years ago
comment:3 by , 12 years ago
Sorry,for example,(listen sound) ->(after 2~3 s)->(watch match video).
I try other protocol,such as rtmp,the data encode is good,only use rtp protocol the video and audio are desync.
ffmpeg -f video4linux2 -s 720:480 -i /dev/video0 -f alsa -i hw:0,0 -an -vcodec libx264 -pix_fmt yuv420p -s 176x144 -b 104k -r 12 -profile baseline -level 30 -flags +global_header -f rtp rtp://XXXIP:20000 -vn -flags +global_header -rtpflags latm -acodec libfaac -ac 1 -ar 16000 -ab 16k -f rtp rtp://XXXIP:20002 ffmpeg version 1.1.3 Copyright (c) 2000-2013 the FFmpeg developers built on Mar 14 2013 13:47:14 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) configuration: --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvpx --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-gpl --enable-postproc --enable-nonfree --enable-network --enable-protocol=tcp --enable-demuxer=rtsp --enable-decoder=h264 --enable-zlib libavutil 52. 13.100 / 52. 13.100 libavcodec 54. 86.100 / 54. 86.100 libavformat 54. 59.106 / 54. 59.106 libavdevice 54. 3.102 / 54. 3.102 libavfilter 3. 32.100 / 3. 32.100 libswscale 2. 1.103 / 2. 1.103 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 2.100 / 52. 2.100 [video4linux2,v4l2 @ 0x261c300] Estimating duration from bitrate, this may be inaccurate Input #0, video4linux2,v4l2, from '/dev/video0': Duration: N/A, start: 1363312657.741746, bitrate: 165722 kb/s Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 720x480, 165722 kb/s, 29.97 tbr, 1000k tbn, 29.97 tbc [alsa @ 0x261cf00] Estimating duration from bitrate, this may be inaccurate Guessed Channel Layout for Input Stream #1.0 : stereo Input #1, alsa, from 'hw:0,0': Duration: N/A, start: 1363312657.744649, bitrate: 1536 kb/s Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s Please use -b:a or -b:v, -b is ambiguous Please use -profile:a or -profile:v, -profile is ambiguous [libx264 @ 0x2623a60] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX [libx264 @ 0x2623a60] profile Constrained Baseline, level 3.0 [libx264 @ 0x2623a60] 264 - core 129 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=36 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=12 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=104 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 Output #0, rtp, to 'rtp://XXXIP:20000': Metadata: encoder : Lavf54.59.106 Stream #0:0: Video: h264, yuv420p, 176x144, q=-1--1, 104 kb/s, 90k tbn, 12 tbc Output #1, rtp, to 'rtp://XXXIP:20002': Metadata: encoder : Lavf54.59.106 Stream #1:0: Audio: aac, 16000 Hz, mono, s16, 16 kb/s Stream mapping: Stream #0:0 -> #0:0 (rawvideo -> libx264) Stream #1:0 -> #1:0 (pcm_s16le -> libfaac) SDP: v=0 o=- 0 0 IN IP4 127.0.0.1 s=No Name t=0 0 a=tool:libavformat 54.59.106 m=video 20000 RTP/AVP 96 c=IN IP4 XXXIP b=AS:104 a=rtpmap:96 H264/90000 a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z0LAHtkCxOhAAAADAEAAAAYDxYuS,aMuMsg==; profile-level-id=42C01E m=audio 20002 RTP/AVP 97 c=IN IP4 XXXIP b=AS:16 a=rtpmap:97 MP4A-LATM/16000/1 a=fmtp:97 profile-level-id=40;cpresent=0;config=400028103fc0 Press [q] to stop, [?] for help frame= 9 fps=0.0 q=0.0 size= 0kB time=00:00:00.25 bitrate= 0.0kbits/sframe= 16 fps= 16 q=0.0 size= 0kB time=00:00:00.77 bitrate= 0.0kbits/sframe= 22 fps= 15 q=0.0 size= 0kB time=00:00:01.28 bitrate= 0.0kbits/sframe= 28 fps= 14 q=0.0 size= 0kB time=00:00:01.79 bitrate= 0.0kbits/sframe= 34 fps= 14 q=0.0 size= 0kB time=00:00:02.30 bitrate= 0.0kbits/sframe= 40 fps= 13 q=0.0 size= 0kB time=00:00:02.75 bitrate= 0.0kbits/sframe= 46 fps= 13 q=0.0 size= 0kB time=00:00:03.26 bitrate= 0.0kbits/sframe= 52 fps= 13 q=0.0 size= 0kB time=00:00:03.77 bitrate= 0.0kbits/sframe= 58 fps= 13 q=0.0 size= 0kB time=00:00:04.29 bitrate= 0.0kbits/sframe= 64 fps= 13 q=0.0 size= 0kB time=00:00:04.80 bitrate= 0.0kbits/sframe= 70 fps= 13 q=0.0 size= 0kB time=00:00:05.31 bitrate= 0.0kbits/sframe= 76 fps= 13 q=0.0 size= 0kB time=00:00:05.82 bitrate= 0.0kbits/sframe= 82 fps= 13 q=29.0 size= 5kB time=00:00:06.27 bitrate= 6.5kbits/frame= 88 fps= 12 q=25.0 size= 9kB time=00:00:06.78 bitrate= 11.2kbits/frame= 94 fps= 12 q=22.0 size= 11kB time=00:00:07.29 bitrate= 12.1kbits/frame= 100 fps= 12 q=18.0 size= 12kB time=00:00:07.81 bitrate= 12.4kbits/frame= 106 fps= 12 q=20.0 size= 18kB time=00:00:08.32 bitrate= 17.8kbits/frame= 112 fps= 12 q=19.0 size= 21kB time=00:00:08.83 bitrate= 19.3kbits/frame= 118 fps= 12 q=17.0 size= 24kB time=00:00:09.34 bitrate= 20.6kbits/frame= 124 fps= 12 q=17.0 size= 28kB time=00:00:09.79 bitrate= 23.5kbits/frame= 130 fps= 12 q=18.0 size= 35kB time=00:00:10.30 bitrate= 28.1kbits/frame= 136 fps= 12 q=22.0 size= 53kB time=00:00:10.81 bitrate= 40.2kbits/frame= 142 fps= 12 q=22.0 size= 63kB time=00:00:11.32 bitrate= 45.4kbits/frame= 148 fps= 12 q=23.0 size= 76kB time=00:00:11.84 bitrate= 52.8kbits/frame= 154 fps= 12 q=27.0 size= 112kB time=00:00:12.35 bitrate= 74.3kbits/frame= 160 fps= 12 q=30.0 size= 144kB time=00:00:12.86 bitrate= 91.5kbits/frame= 166 fps= 12 q=31.0 size= 164kB time=00:00:13.31 bitrate= 101.0kbits/frame= 172 fps= 12 q=32.0 size= 175kB time=00:00:13.82 bitrate= 103.9kbits/frame= 179 fps= 12 q=31.0 size= 183kB time=00:00:14.33 bitrate= 104.5kbits/frame= 185 fps= 12 q=32.0 size= 197kB time=00:00:14.85 bitrate= 108.4kbits/frame= 191 fps= 12 q=32.0 size= 204kB time=00:00:15.36 bitrate= 108.8kbits/frame= 197 fps= 12 q=32.0 size= 209kB time=00:00:15.87 bitrate= 108.1kbits/frame= 203 fps= 12 q=32.0 size= 214kB time=00:00:16.32 bitrate= 107.5kbits/frame= 209 fps= 12 q=32.0 size= 219kB time=00:00:16.83 bitrate= 106.6kbits/frame= 215 fps= 12 q=32.0 size= 224kB time=00:00:17.34 bitrate= 105.6kbits/frame= 221 fps= 12 q=31.0 size= 225kB time=00:00:17.85 bitrate= 103.0kbits/frame= 227 fps= 12 q=30.0 size= 225kB time=00:00:18.36 bitrate= 100.2kbits/frame= 233 fps= 12 q=30.0 size= 229kB time=00:00:18.88 bitrate= 99.3kbits/frame= 239 fps= 12 q=29.0 size= 229kB time=00:00:19.39 bitrate= 96.8kbits/frame= 245 fps= 12 q=29.0 size= 230kB time=00:00:19.84 bitrate= 95.2kbits/frame= 251 fps= 12 q=29.0 size= 233kB time=00:00:20.35 bitrate= 93.7kbits/frame= 257 fps= 12 q=28.0 size= 233kB time=00:00:20.86 bitrate= 91.7kbits/frame= 263 fps= 12 q=27.0 size= 235kB time=00:00:21.37 bitrate= 89.9kbits/frame= 269 fps= 12 q=27.0 size= 240kB time=00:00:21.88 bitrate= 89.8kbits/frame= 275 fps= 12 q=27.0 size= 242kB time=00:00:22.40 bitrate= 88.4kbits/frame= 281 fps= 12 q=26.0 size= 244kB time=00:00:22.91 bitrate= 87.1kbits/frame= 287 fps= 12 q=26.0 size= 245kB time=00:00:23.36 bitrate= 86.0kbits/frame= 293 fps= 12 q=26.0 size= 253kB time=00:00:23.87 bitrate= 86.9kbits/frame= 299 fps= 12 q=26.0 size= 261kB time=00:00:24.38 bitrate= 87.7kbits/frame= 305 fps= 12 q=26.0 size= 263kB time=00:00:24.89 bitrate= 86.7kbits/frame= 311 fps= 12 q=26.0 size= 265kB time=00:00:25.40 bitrate= 85.6kbits/frame= 312 fps= 12 q=32766.0 Lsize= 386kB time=00:00:26.00 bitrate= 121.6kbits/s dup=0 drop=460 video:381kB audio:50kB subtitle:0 global headers:0kB muxing overhead -10.524577% [libx264 @ 0x2623a60] frame I:8 Avg QP:22.06 size: 5805 [libx264 @ 0x2623a60] frame P:304 Avg QP:23.80 size: 1130 [libx264 @ 0x2623a60] mb I I16..4: 16.7% 0.0% 83.3% [libx264 @ 0x2623a60] mb P I16..4: 0.8% 0.0% 1.9% P16..4: 32.4% 16.4% 7.3% 0.0% 0.0% skip:41.0% [libx264 @ 0x2623a60] final ratefactor: 22.73 [libx264 @ 0x2623a60] coded y,uvDC,uvAC intra: 75.8% 79.0% 70.3% inter: 31.2% 37.7% 19.4% [libx264 @ 0x2623a60] i16 v,h,dc,p: 4% 76% 7% 14% [libx264 @ 0x2623a60] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 24% 11% 6% 8% 8% 8% 7% 8% [libx264 @ 0x2623a60] i8c dc,h,v,p: 33% 39% 18% 11% [libx264 @ 0x2623a60] ref P L0: 82.0% 8.6% 9.4% [libx264 @ 0x2623a60] kb/s:119.94 Received signal 2: terminating.
Replying to Ken_JJ:
Do you mean that when using your command you see progressive A/V desync, ie the stream starts either with some desync or in-sync but A/V sync gets worse and worse over time?
Or do you mean that there is A/V desync from the beginning that stays approximately constant but does not get better?
Is the problem only reproducible if you output to sdp or also if you encode a file?
In any case: Please add the complete, uncut console output together with your command line to make this a valid ticket.