14

Encoding with ffmpeg and libx264, are there presets or flags that will optimize decoding speed?

Right now it seems that videos transcoded with similar file sizes are decoded at very different speeds using Qtkit, and I was wondering whether there are options for encoding such that the decoding speed will be maximal.

nbubis
  • 2,304
  • 5
  • 31
  • 46
  • If you use sliced encoding, your decoder can take advantage of multithreading (assuming your decoder may be sped up by that, e.g. decoding of a single stream is the bottleneck on a multi core CPU. – Alex Cohn Jan 07 '14 at 13:29
  • @AlexCohn - can you point out any references on "sliced encoding" with ffmpeg? – nbubis Jan 07 '14 at 19:02
  • 1
    See http://mewiki.project357.com/wiki/X264_Settings#slices and http://mewiki.project357.com/wiki/X264_Settings#sliced-threads. This approach may reduce decode time maybe by 75%, but at expense of quality. It is only relevant for hi-rez frames. E.g. BlueRay Disk _requires_ 4 slices. – Alex Cohn Jan 08 '14 at 09:38
  • @Nathaniel, Can you describe your problem more in detail because you mention about re-encoding. Is reducing the resolution an option for you? – Dundar Jan 10 '14 at 14:54

2 Answers2

14

There is --tune fastdecode in x264 (or -tune fastdecode if using ffmpeg) if you want optimize for decoding speed at the cost of quality/compression efficiency. In libx264 tune setting is available as one of the params for x264_param_default_preset.

llogan
  • 121,796
  • 28
  • 232
  • 243
nobody555
  • 2,239
  • 18
  • 18
  • This definitely helps (brings it up from 2fps to 9 fps), but it's still not the same as the original videos which play at a good 30fps. Somehow the re-encoding messes thing up :( – nbubis Jan 07 '14 at 19:24
  • How was the original encoded? Was it h264 at all? What is the resolution and nitrate? Maybe ffmpeg dump can help understand the changes better. – Alex Cohn Jan 07 '14 at 19:54
  • 3
    It looks like `-tune fastdecode -tune zerolatency` works! I'll accept the answer, but you may want to add `zerolatency` to it. Cheers! – nbubis Jan 10 '14 at 23:00
  • imho zerolatency tuning don't have much to decoding. The only options from it that may help decoding are "--sliced-threads" if your decoder doesn't support frame threading and so need independent slices for multithreaded decoding and "--bframes 0" but B-frames shouldn't be much slower than P-frames. – nobody555 Jan 11 '14 at 21:56
  • 1
    @nmxprime Specify it when using x264_param_default_preset() to get default params with it. Or change needed params yourself [by looking which params it changes in libx264](http://git.videolan.org/gitweb.cgi?p=x264.git;a=blob;f=common/common.c;h=a9e1c7325246cb594d71a4f5d47ee4fde0649f34;hb=HEAD#l369) – nobody555 Jan 24 '14 at 20:34
3

I've used this in the past:

-b (to remove B Frame calculations)

-maxrate 8M (I find this is important because sometimes the averages have a large distribution in bitrate and so if you set 8M as an average, you may still find 15M peaks)

-tune fastdecode (already explained above)

Sousaplex
  • 149
  • 9