2
votes

At the moment, I am using ffmpeg library to convert videos from x type (MOV, AVI etc) to dedicated type i.e. MP4. But it is taking too long time for video conversion. Lets say the MOV video size is 1.8GB and the conversion takes approximately 1 hour 30 minutes. Is there any other way to reduce the conversion time duration with maintaining the same quality ?

My FFMPEG syntax as follows for video conversion:

  • ffmpeg -y -i input.mov -vcodec h264 -acodec aac -strict -2 out.mp4

How to acheieve fast video conversion ?

  • what about the output format changed to MPEG2 or others?
  • Is there any other fast codecs other than h264 ?
  • What are the best compression techniques ?

Any pointers would be really appreciable.

2
Add -preset fasterGyan
@Mulvya It looks, no major effect after presetuser2224250
90 minutes for what sounds like transcoding a feature-length film sounds about right. It'll hardly get any faster, unless you describe your situation a bit better.deceze♦

2 Answers

3
votes

There is always a trade off between compression ratio and compression speed.

To reduce conversion time, try the different presets made available by ffmpeg for libx264. For instance, the -preset ultrafast setting gives the fastest speed, by sacrifices the compression, so you will get bigger file size than if you don't use any preset (the default is -preset medium).

The best compression techniques for video that has been standardized currently is H.265, aka HEVC. You can checkout https://trac.ffmpeg.org/wiki/Encode/H.265 for more info. Note that H.265 gain better compression by more sophisticated techniques, so using it would generally lead to slower compression compared to H.264. By the same argument, switching to simpler compression method such as MPEG2 would generally speed up the process, at the price of lower compression ratio.

3
votes

Some various tips for this very broad question:

  • Make sure your console output does not contain using CPU capabilities: none!. If it does show this then your encoding speed may be significantly reduced, and you'll need to re-compile x264 and ffmpeg.

  • Ensure your ffmpeg does not use the --disable-asm, --disable-inline-asm, and --disable-yasm configure options.

  • Use a recent ffmpeg. You're using -strict -2 which makes me think your using an old version. See the FFmpeg Download page for links to builds for Linux, macOS, and Windows.

  • Stream copy the audio (with -c:a copy) when possible instead of re-encoding it.

  • Use a faster x264 encoding preset as already mentioned by others.

  • Hardware acceleration may be an option for you, but none of these are as efficient as x264.