[FFmpeg-user] confusion with "-vsync 1" / "-vsync cfr" and "-map" (to sync audio to video)
Tracey Jaquith
tracey at archive.org
Fri Jan 11 21:36:41 CET 2013
Thanks Carl!
OK, so
-async 1
(at least per the documentation)
makes it sound like it only corrects A/V sync issues at the start of the source video.
doing something like:
-af aresample=8000
stopped the A/V sync issues in flash, but I'm sort of making up that number from google monster
since I'm not sure what values to use.
Did "-vsync" in my command line make a difference?
Absolutely! 8-)
I have tried various cmd-line options and techniques over the years, but the two lead contenders now, plus "nothing" for comparison, are:
-vsync 0 (html5 playback of mp4 is fine; flash plugin of same mp4 has A/V slip)
-vcync 1 (both html5 and flash are fine -- I am fretting just a bit about dropping/duping video frames)
[none] (both html5 and flash are fine -- but other TV source videos of ours have A/V slip when w/o "-vsync" param)
Let me switch over to the mp4 creation and the longer sample (just over 4 minutes):
cat ~/go
#!/bin/bash -ex
wget -q -O libx264-IA.ffpreset http://archive.org/~tracey/downloads/libx264-IA.ffpreset.txt;
ffmpeg -y -i http://archive.org/~tracey/_/tv-a-change/boo.mpg -vcodec libx264 -vf yadif,scale=640:360 -fpre libx264-IA.ffpreset -ac 2 -b:a 128k -ar 44100 -map 0:1 -map 0:0 -acodec aac -strict experimental -vsync 0 vsync0.mp4;
ffmpeg -y -i http://archive.org/~tracey/_/tv-a-change/boo.mpg -vcodec libx264 -vf yadif,scale=640:360 -fpre libx264-IA.ffpreset -ac 2 -b:a 128k -ar 44100 -map 0:1 -map 0:0 -acodec aac -strict experimental -vsync 1 vsync1.mp4;
ffmpeg -y -i http://archive.org/~tracey/_/tv-a-change/boo.mpg -vcodec libx264 -vf yadif,scale=640:360 -fpre libx264-IA.ffpreset -ac 2 -b:a 128k -ar 44100 -map 0:1 -map 0:0 -acodec aac -strict experimental none.mp4;
Below is the full output of the three commands above.
Apologies for not sending full output -- I had figured either my question was an obvious (to others) "you're doing it wrong!" so full output wouldn't be necessary or that it would be slightly rude to dump it all. I sit corrected! 8-)
I'm still slightly confused, though, as to whether or not choosing either the audio or video stream to sync the other to works in my original question -- well, I think I'm missing/misunderstand something about that so am still wondering if the packets/frames should indeed differ slightly depending on "-map 0:1,0:0 -map 0:0,0:0" vs "-map 0:1,0:1 -map 0:0,0:1" argument options.
best,
-Tracey
+ wget -q -O libx264-IA.ffpreset http://archive.org/~tracey/downloads/libx264-IA.ffpreset.txt
+ ffmpeg -y -i http://archive.org/~tracey/_/tv-a-change/boo.mpg -vcodec libx264 -vf yadif,scale=640:360 -fpre libx264-IA.ffpreset -ac 2 -b:a 128k -ar 44100 -map 0:1 -map 0:0 -acodec aac -strict experimental -vsync 0 vsync0.mp4
ffmpeg version N-47856-g51fcf27 Copyright (c) 2000-2012 the FFmpeg developers
built on Dec 15 2012 07:01:55 with gcc 4.7 (Ubuntu/Linaro 4.7.2-2ubuntu1)
configuration: --disable-shared --disable-ffserver --disable-vdpau --enable-avfilter --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libtheora --enable-libvorbis --enable-libxvid --enable-nonfree --enable-postproc --enable-pthreads --enable-static --enable-ffplay --enable-libvpx --enable-libx264 --enable-version3 --extra-cflags=-I/tmp/f/usr/local/include --extra-ldflags=-L/tmp/f/usr/local/lib --extra-cflags=-static --prefix=/usr --enable-libfreetype --enable-libgsm --enable-libspeex --extra-ldflags=-static
libavutil 52. 12.100 / 52. 12.100
libavcodec 54. 79.102 / 54. 79.102
libavformat 54. 49.102 / 54. 49.102
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 27.101 / 3. 27.101
libswscale 2. 1.103 / 2. 1.103
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
[mpeg @ 0x354b920] max_analyze_duration 5000000 reached at 5024000
Input #0, mpeg, from 'http://archive.org/~tracey/_/tv-a-change/boo.mpg':
Duration: 00:04:00.69, start: 0.360000, bitrate: 9723 kb/s
Stream #0:0[0x80]: Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
[libx264 @ 0x35589e0] using SAR=1/1
[libx264 @ 0x35589e0] using cpu capabilities: MMX2 SSE2 SSE3 Cache64 BMI1
[libx264 @ 0x35589e0] profile Constrained Baseline, level 3.0
[libx264 @ 0x35589e0] 264 - core 129 r2230 1cffe9f - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=700 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=768 vbv_bufsize=1400 nal_hrd=none ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'vsync0.mp4':
Metadata:
encoder : Lavf54.49.102
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 700 kb/s, 30k tbn, 29.97 tbc
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 128 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (mpeg2video -> libx264)
Stream #0:0 -> #0:1 (ac3 -> aac)
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from rate:48000 fmt:fltp ch:6 chl:5.1(side) to rate:48000 fmt:fltp ch:2 chl:stereo
Input stream #0:0 frame changed from rate:48000 fmt:fltp ch:2 chl:stereo to rate:48000 fmt:fltp ch:6 chl:5.1(side)
frame= 6850 fps= 38 q=32766.0 Lsize= 24076kB time=00:04:00.70 bitrate= 819.4kbits/s
video:20184kB audio:3695kB subtitle:0 global headers:0kB muxing overhead 0.823989%
[libx264 @ 0x35589e0] frame I:74 Avg QP:20.48 size: 20413
[libx264 @ 0x35589e0] frame P:6776 Avg QP:22.54 size: 2827
[libx264 @ 0x35589e0] mb I I16..4: 37.8% 0.0% 62.2%
[libx264 @ 0x35589e0] mb P I16..4: 1.8% 0.0% 1.1% P16..4: 31.0% 10.1% 2.9% 0.0% 0.0% skip:53.1%
[libx264 @ 0x35589e0] coded y,uvDC,uvAC intra: 40.5% 61.1% 30.3% inter: 12.7% 22.9% 2.7%
[libx264 @ 0x35589e0] i16 v,h,dc,p: 46% 29% 7% 18%
[libx264 @ 0x35589e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 22% 18% 5% 6% 6% 6% 5% 5%
[libx264 @ 0x35589e0] i8c dc,h,v,p: 50% 24% 20% 6%
[libx264 @ 0x35589e0] kb/s:694.80
+ ffmpeg -y -i http://archive.org/~tracey/_/tv-a-change/boo.mpg -vcodec libx264 -vf yadif,scale=640:360 -fpre libx264-IA.ffpreset -ac 2 -b:a 128k -ar 44100 -map 0:1 -map 0:0 -acodec aac -strict experimental -vsync 1 vsync1.mp4
ffmpeg version N-47856-g51fcf27 Copyright (c) 2000-2012 the FFmpeg developers
built on Dec 15 2012 07:01:55 with gcc 4.7 (Ubuntu/Linaro 4.7.2-2ubuntu1)
configuration: --disable-shared --disable-ffserver --disable-vdpau --enable-avfilter --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libtheora --enable-libvorbis --enable-libxvid --enable-nonfree --enable-postproc --enable-pthreads --enable-static --enable-ffplay --enable-libvpx --enable-libx264 --enable-version3 --extra-cflags=-I/tmp/f/usr/local/include --extra-ldflags=-L/tmp/f/usr/local/lib --extra-cflags=-static --prefix=/usr --enable-libfreetype --enable-libgsm --enable-libspeex --extra-ldflags=-static
libavutil 52. 12.100 / 52. 12.100
libavcodec 54. 79.102 / 54. 79.102
libavformat 54. 49.102 / 54. 49.102
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 27.101 / 3. 27.101
libswscale 2. 1.103 / 2. 1.103
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
[mpeg @ 0x3f6d920] max_analyze_duration 5000000 reached at 5024000
Input #0, mpeg, from 'http://archive.org/~tracey/_/tv-a-change/boo.mpg':
Duration: 00:04:00.69, start: 0.360000, bitrate: 9723 kb/s
Stream #0:0[0x80]: Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
[libx264 @ 0x3f7a9e0] using SAR=1/1
[libx264 @ 0x3f7a9e0] using cpu capabilities: MMX2 SSE2 SSE3 Cache64 BMI1
[libx264 @ 0x3f7a9e0] profile Constrained Baseline, level 3.0
[libx264 @ 0x3f7a9e0] 264 - core 129 r2230 1cffe9f - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=700 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=768 vbv_bufsize=1400 nal_hrd=none ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'vsync1.mp4':
Metadata:
encoder : Lavf54.49.102
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 700 kb/s, 30k tbn, 29.97 tbc
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 128 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (mpeg2video -> libx264)
Stream #0:0 -> #0:1 (ac3 -> aac)
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from rate:48000 fmt:fltp ch:6 chl:5.1(side) to rate:48000 fmt:fltp ch:2 chl:stereo
Input stream #0:0 frame changed from rate:48000 fmt:fltp ch:2 chl:stereo to rate:48000 fmt:fltp ch:6 chl:5.1(side)
frame= 7214 fps= 41 q=32766.0 Lsize= 24317kB time=00:04:00.70 bitrate= 827.6kbits/s dup=364 drop=0
video:20422kB audio:3695kB subtitle:0 global headers:0kB muxing overhead 0.830906%
[libx264 @ 0x3f7a9e0] frame I:75 Avg QP:20.43 size: 20671
[libx264 @ 0x3f7a9e0] frame P:7139 Avg QP:22.46 size: 2712
[libx264 @ 0x3f7a9e0] mb I I16..4: 36.6% 0.0% 63.4%
[libx264 @ 0x3f7a9e0] mb P I16..4: 1.7% 0.0% 1.0% P16..4: 29.9% 9.6% 2.8% 0.0% 0.0% skip:55.0%
[libx264 @ 0x3f7a9e0] coded y,uvDC,uvAC intra: 40.7% 61.3% 30.5% inter: 12.1% 21.9% 2.6%
[libx264 @ 0x3f7a9e0] i16 v,h,dc,p: 47% 29% 7% 18%
[libx264 @ 0x3f7a9e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 22% 18% 5% 6% 6% 6% 5% 5%
[libx264 @ 0x3f7a9e0] i8c dc,h,v,p: 50% 25% 20% 6%
[libx264 @ 0x3f7a9e0] kb/s:695.00
+ ffmpeg -y -i http://archive.org/~tracey/_/tv-a-change/boo.mpg -vcodec libx264 -vf yadif,scale=640:360 -fpre libx264-IA.ffpreset -ac 2 -b:a 128k -ar 44100 -map 0:1 -map 0:0 -acodec aac -strict experimental none.mp4
ffmpeg version N-47856-g51fcf27 Copyright (c) 2000-2012 the FFmpeg developers
built on Dec 15 2012 07:01:55 with gcc 4.7 (Ubuntu/Linaro 4.7.2-2ubuntu1)
configuration: --disable-shared --disable-ffserver --disable-vdpau --enable-avfilter --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libtheora --enable-libvorbis --enable-libxvid --enable-nonfree --enable-postproc --enable-pthreads --enable-static --enable-ffplay --enable-libvpx --enable-libx264 --enable-version3 --extra-cflags=-I/tmp/f/usr/local/include --extra-ldflags=-L/tmp/f/usr/local/lib --extra-cflags=-static --prefix=/usr --enable-libfreetype --enable-libgsm --enable-libspeex --extra-ldflags=-static
libavutil 52. 12.100 / 52. 12.100
libavcodec 54. 79.102 / 54. 79.102
libavformat 54. 49.102 / 54. 49.102
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 27.101 / 3. 27.101
libswscale 2. 1.103 / 2. 1.103
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
[mpeg @ 0x3eb6920] max_analyze_duration 5000000 reached at 5024000
Input #0, mpeg, from 'http://archive.org/~tracey/_/tv-a-change/boo.mpg':
Duration: 00:04:00.69, start: 0.360000, bitrate: 9723 kb/s
Stream #0:0[0x80]: Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
[libx264 @ 0x3ec39e0] using SAR=1/1
[libx264 @ 0x3ec39e0] using cpu capabilities: MMX2 SSE2 SSE3 Cache64 BMI1
[libx264 @ 0x3ec39e0] profile Constrained Baseline, level 3.0
[libx264 @ 0x3ec39e0] 264 - core 129 r2230 1cffe9f - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=700 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=768 vbv_bufsize=1400 nal_hrd=none ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'none.mp4':
Metadata:
encoder : Lavf54.49.102
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 700 kb/s, 30k tbn, 29.97 tbc
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 128 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (mpeg2video -> libx264)
Stream #0:0 -> #0:1 (ac3 -> aac)
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from rate:48000 fmt:fltp ch:6 chl:5.1(side) to rate:48000 fmt:fltp ch:2 chl:stereo
Input stream #0:0 frame changed from rate:48000 fmt:fltp ch:2 chl:stereo to rate:48000 fmt:fltp ch:6 chl:5.1(side)
frame= 7214 fps= 38 q=32766.0 Lsize= 24317kB time=00:04:00.70 bitrate= 827.6kbits/s dup=364 drop=0
video:20422kB audio:3695kB subtitle:0 global headers:0kB muxing overhead 0.830916%
[libx264 @ 0x3ec39e0] frame I:75 Avg QP:20.45 size: 20637
[libx264 @ 0x3ec39e0] frame P:7139 Avg QP:22.48 size: 2712
[libx264 @ 0x3ec39e0] mb I I16..4: 36.7% 0.0% 63.3%
[libx264 @ 0x3ec39e0] mb P I16..4: 1.7% 0.0% 1.0% P16..4: 29.9% 9.6% 2.8% 0.0% 0.0% skip:55.0%
[libx264 @ 0x3ec39e0] coded y,uvDC,uvAC intra: 40.7% 61.2% 30.5% inter: 12.1% 21.9% 2.6%
[libx264 @ 0x3ec39e0] i16 v,h,dc,p: 46% 29% 7% 18%
[libx264 @ 0x3ec39e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 22% 18% 5% 6% 6% 6% 5% 5%
[libx264 @ 0x3ec39e0] i8c dc,h,v,p: 50% 24% 20% 6%
[libx264 @ 0x3ec39e0] kb/s:694.99
On Jan 11, 2013, at 11:19 AM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> Tracey Jaquith <tracey <at> archive.org> writes:
>
>> I am the developer of the TV Archive ( http://archive.org/tv )
>> and have a question regarding A/V "sync" issues.
>>
>> We are finding that some of our "harder" channels are
>> requiring "-vsync 0" or "-vsync 1". The problem with the
>> former is that our resulting .mp4 get A/V slip when
>> progressively downloaded through the flash plugin (only) but
>> are fine for html5 browsers. So we want to go with "-vsync 1".
>> I'd *like* to make the audio frames dropped/duped
>
> I suspect this means that, instead of -vsync x,
> you want to use -async 1 (which is now also
> -af aresample=async iirc).
>
> Generally, please do not post extracts of console but only
> complete, uncut console output (at least the first 50 and
> the last 50 lines).
>
> (Did -vsync in your command line really make a difference?
> Hard to believe...)
>
> Carl Eugen
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
More information about the ffmpeg-user
mailing list