Search code examples
ffmpegx264libx264

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?


Solution

  • 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