[FFmpeg-user] Audio and Video Out of Sync with UPD stream input and flv RTMP output
Murat Maman
murat.maman at gmail.com
Sat Nov 22 12:24:55 CET 2014
Hello everyone,
I have troubles with A/V sync for a live RTMP output stream generated by
ffmpeg. After playing around with the parameters for a few days now, I
still wasn’t able to get rid of the sync issues. I hope that you could spot
an issue in my command or advise me in how to avoid sync troubles. I would
extremely appreciate any help here.
Here’s the my problem: In order to publish a live RTMP stream, I use one
UDP input, this is coming from an application that is only able to output
raw formats. Ffmpeg is used for encoding resizing and encoding video to
H.264. Finally, streams are muxed into flv and published via RTMP. In
general, this works very well, and the results look great. However,
unfortunately A/V seems to drift after running for a couple of days or 5-6
hours.
Here’s the my command:
sudo ffmpeg -y -f rawvideo mpegts \
-fflags nobuffer \
-i 'udp://@UPD LINK?fifo_size=1000000&overrun_nonfatal=1' \
-maxrate 4000k -bufsize 4000k \
-af volume=1.0 \
-strict experimental \
-c:a libfaac -ar 44100 -ac 2 -b:a 128k \
-vsync 1 -c:v libx264 -r 25 -vf yadif,scale=720:576 -aspect:v 16:9 -b:v
4000k -pix_fmt yuv420p \
-preset superfast -tune zerolatency -threads 0 -crf 25 \
-fflags nobuffer \
-f flv 'rtmp://[URL]'
I have tried several vsync settings and “map” variations. I believe the
above command should try to sync the video stream to the audio stream,
which seems most sensible for our scenario. I have tried it the other
around as well, with no different results, i.e. A/V is still drifting.
As I am able to confirm that the source application feeds very well. Also
i have changed output rtmp to hls but result was same still drifting.
In case of problem i checking source by dumping video and saw that there is
no problem.
I am break current connection and reconnect to same udp link then problem
was solving but i can do this everytime.
Here is my questions what is the source of problem and how can i understand
video and audio out of sync. I am thinking if i can undestand drift between
audio and video then i can reset the connection and then reconnect the
source.
This is console output,
ffmpeg version git-2013-12-30-61d43a2 Copyright (c) 2000-2013 the FFmpeg
developers
built on Dec 30 2013 23:01:15 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --enable-gpl --enable-pthreads --enable-libfaac
--enable-libmp3lame --enable-libopencore-amrnb --enable-libass
--enable-libfdk-aac --enable-libopus --enable-libtheora --enable-libvorbis
--enable-libvpx --enable-mmx --enable-nonfree --enable-version3
--enable-libx264
libavutil 52. 59.100 / 52. 59.100
libavcodec 55. 47.100 / 55. 47.100
libavformat 55. 22.101 / 55. 22.101
libavdevice 55. 5.102 / 55. 5.102
libavfilter 4. 0.103 / 4. 0.103
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
[mpeg2video @ 0x2e4ace0] Invalid frame dimensions 0x0.
Last message repeated 16 times
Input #0, mpegts, from 'udp://@UDP
LINK?fifo_size=1000000&overrun_nonfatal=1':
Duration: N/A, start: 75687.034456, bitrate: 256 kb/s
Program 1101
Stream #0:0[0x65]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002),
yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr,
90k tbn, 50 tbc
Stream #0:1[0xc9](tur): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz,
stereo, s16p, 256 kb/s
[libx264 @ 0x2eb0640] using SAR=64/45
[libx264 @ 0x2eb0640] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x2eb0640] profile High, level 3.0
[libx264 @ 0x2eb0640] 264 - core 140 r2 1ca7bb9 - H.264/MPEG-4 AVC codec -
Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1
ref=1 deblock=1:0:0 analyse=0x3:0x3 me=dia subme=1 psy=1 psy_rd=1.00:0.00
mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11
fast_pskip=1 chroma_qp_offset=0 threads=9 lookahead_threads=9
sliced_threads=1 slices=9 nr=0 decimate=1 interlaced=0 bluray_compat=0
constrained_intra=0 bframes=0 weightp=1 keyint=250 keyint_min=25
scenecut=40 intra_refresh=0 rc_lookahead=0 rc=crf mbtree=0 crf=25.0
qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=4000 vbv_bufsize=4000
crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
Output #0, rawvideo, to 'mpegts':
Metadata:
encoder : Lavf55.22.101
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 720x576 [SAR
64:45 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 25 tbc
Output #1, flv, to 'rtmp://[URL]':
Metadata:
encoder : Lavf55.22.101
Stream #1:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p,
720x576 [SAR 64:45 DAR 16:9], q=-1--1, 4000 kb/s, 1k tbn, 25 tbc
Stream #1:1(tur): Audio: aac (libfaac) ([10][0][0][0] / 0x000A), 44100
Hz, stereo, s16, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video -> rawvideo)
Stream #0:0 -> #1:0 (mpeg2video -> libx264)
Stream #0:1 -> #1:1 (mp2 -> libfaac)
Press [q] to stop, [?] for help
[flv @ 0x2eafe40] Failed to update header with correct duration.8
bitrate=124416.0kbits/s dup=78 drop=0
[flv @ 0x2eafe40] Failed to update header with correct filesize.
frame= 98 fps= 43 q=0.0 Lq=27.0 size= 59535kB time=00:00:03.92
bitrate=124416.0kbits/s dup=78 drop=0
video:59989kB audio:45kB subtitle:0 global headers:0kB muxing overhead
-0.832512%
[libx264 @ 0x2eb0640] frame I:2 Avg QP:19.43 size: 47187
[libx264 @ 0x2eb0640] frame P:95 Avg QP:20.19 size: 3896
[libx264 @ 0x2eb0640] mb I I16..4: 8.9% 17.0% 74.1%
[libx264 @ 0x2eb0640] mb P I16..4: 0.4% 0.6% 0.4% P16..4: 40.7% 0.0%
0.0% 0.0% 0.0% skip:58.0%
[libx264 @ 0x2eb0640] 8x8 transform intra:26.4% inter:44.9%
[libx264 @ 0x2eb0640] coded y,uvDC,uvAC intra: 75.2% 81.0% 55.3% inter:
11.6% 12.6% 1.1%
[libx264 @ 0x2eb0640] i16 v,h,dc,p: 42% 41% 14% 3%
[libx264 @ 0x2eb0640] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 16% 17% 6% 7%
9% 6% 9% 10%
[libx264 @ 0x2eb0640] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 13% 13% 9% 7%
9% 6% 10% 8%
[libx264 @ 0x2eb0640] i8c dc,h,v,p: 47% 20% 22% 11%
[libx264 @ 0x2eb0640] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x2eb0640] kb/s:957.69
More information about the ffmpeg-user
mailing list