I'm saddled with using ffmpeg for some video conversion on an older windows box. Unfortunately my app crawls to a halt whenever ffmpeg is running. Can any ffmpeg experts suggest any performance tips to optimize ffmpeg?

These are the arguments I am supplying ffmpeg with

['-i', _master, '-s', '720x540', '-sws_flags', 'lanczos', '-qscale:v', '1', '-y', _tempMaster]

Actually forgot 2 additional operations


['-i', "concat:" + _head + "|" + _tempMaster + "|" + _tail, '-c', 'copy', '-y', _concatALL] 


['-i', _audio, '-i', _concatALL, '-vcodec', 'libx264', '-crf', '22', '-vf', 'hqdn3d=1:1:1:1,unsharp=2:2:.7:2:2:0.0', '-y', _finalOutput] 
  • Please show the actual ffmpeg commands and the complete console outputs. – llogan May 2 '13 at 17:30
  • Lanczos filtering is pretty expensive. Can you try a different image filter? fast_bilinear is pretty doggone fast compared to lanczos, but will reduce image quality slightly. Just replace lanczos with fast_bilinear and compare.

  • A lot of what's slow about ffmpeg has to do with codecs, and it's not clear from your commandline options what muxers/demuxers/encoders/decoders/filters you're using, other than libswscale. Codec options have a lot to do with the computational complexity of a video job.

  • Make sure you are running the latest version of ffmpeg.

  • Try swapping out libav/ffmpeg to see if it helps. They've diverged a bit lately.

  • Maybe compile a new version of ffmpeg from source, using a more advanced compiler with Link Time Optimization and other expensive optimizations, such as Visual Studio 2012's compiler, or Clang.

  • If the operating system is 64-bit, you can get at least a 5 to 10% performance speedup by using a 64-bit build of ffmpeg. The additional CPU registers will definitely help with the tight loops of an encoder or image resizing algorithm. I think all processors branded "i5" to date are 64-bit enabled, so installing a 64-bit OS would be an option if you're running 32-bit.

  • If you seriously need to shave off milliseconds and have a lot of time and knowledge of C, use a profiler to time a debug build of ffmpeg. See where (in what methods/filters/codecs) it spends most of its time. See if you can work out some micro-optimizations, or maybe cut corners in quality to speed it up.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.