ffmpeg conversion skips audio
While converting a video to mp4 format using ffmpeg the audio gets skipped because of which the audio goes out of sync with the Video.
One can have a look at the following Video: https://vialogues.com/vialogues/play/486
I am using the following options for conversion
/usr/local/bin/ffmpeg -y -i $inputfile -acodec libfaac -ar 44100 -ab 96k -vcodec libx264 -level 41 -bufsize 20000k -maxrate 25000k -g 250 -r 20 -s 480x270 -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +dct8x8+bpyramid -me_method umh -subq 7 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -bf 16 -b_strategy 1 -bidir_refine 1 -refs 6 -crf 25 -deblockalpha 0 -vpre medium -deblockbeta 0 $outputfile
Also the ffmpeg version is
ffmpeg
FFmpeg version 0.6.1, Copyright (c) 2000-2010 the FFmpeg developers
built on Feb 19 2011 19:03:56 with gcc 4.4.5
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab
libavutil 50.15. 1 / 50.15. 1
libavcodec 52.72. 2 / 52.72. 2
libavformat 52.64. 2 / 52.64. 2
libavdevice 52. 2. 0 / 52. 2. 0
libswscale 0.11. 0 / 0.11. 0
libpostproc 51. 2. 0 / 51. 2. 0
Hyper fast Audio and Video encoder
Any ideas as to why 开发者_如何学编程this would be happening?
I did a lot of research and played with async option of ffmpeg, I found out that the lip sync issue was occuring because of the fact that the audio was getting downsampled by libfaac so I changed the option of --acodec to copy which effectively means don't downsample it and put it in the raw format.
After this the issue was gone.
/usr/local/bin/ffmpeg -y -i $inputfile -acodec copy -ar 44100 -ab 96k -vcodec libx264 -level 41 -bufsize 20000k -maxrate 25000k -g 250 -r 20 -s 480x270 -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +dct8x8+bpyramid -me_method umh -subq 7 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -bf 16 -b_strategy 1 -bidir_refine 1 -refs 6 -crf 25 -deblockalpha 0 -vpre medium -deblockbeta 0 $outputfile
Couple of links which were kind of helpful in figuring out about ffmpeg more were:
1) Talks about how FFMPEG works: http://howto-pages.org/ffmpeg/ 2) Converting video to quicktime: http://ubuntuforums.org/archive/index.php/t-387640.html 3) Installing FFMPEG on UBUNTU : http://ubuntuforums.org/showpost.php?p=6963607&postcount=360
Your answer is one solution that worked well for me, too, when I faced the similar problem. However, copying the audio track wasn't an option for me because I want it compressed, and originals might have 384kbps tracks.
But the important thing that you mentioned was the problem of downsampling. That, and this thread (http://doom10.org/index.php?topic=1639.0) got me thinking and into trying aac codec. It's deemed experimental, but it worked great for me! -async, -vsync did nothing, but -acodec aac -strict experimental (for ffmpeg not to warn you that it's experimental) did wonders! Highly recommend this solution to anyone who has audio/video sync problems and where copying the audio is not an option and ordinary solutions don't work. aac is a great codec. I'm still going to use libfaac as my main aac codec because aac is experimental but I am pretty sure now acc can produce great results in production and be consistent.
精彩评论