54

Running this command:

ffmpeg -i xr.mp4 -tune ya zu.mp4

reveals the possible tune values for x264 and in turn FFmpeg:

[libx264 @ 0000000002167100] Possible tunes: film animation grain stillimage psnr ssim
                                             fastdecode zerolatency

However I could not find a reference explaining what these values actually do.

1 Answer 1

91

This is what the modes do:

  • film – intended for high-bitrate/high-quality movie content. Lower deblocking is used here.
  • animation – intended for cartoons, etc., where deblocking is boosted to compensate for larger, flat areas. More reference frames are used.
  • grain – this should be used for material that is already grainy. Here, the grain won't be filtered out as much.
  • stillimage – like the name says, it optimizes for still image encoding by lowering the deblocking filter.
  • psnr and ssim – these are debugging modes to optimize for good PSNR and SSIM values only. Better metrics don't necessarily mean better quality though.
  • fastdecode – disables CABAC and the in-loop deblocking filter to allow for faster decoding on devices with lower computational power.
  • zerolatency – optimization for fast encoding and low latency streaming

You can see the detailed options applied with each tune with x264 --fullhelp:

--tune <string>         Tune the settings for a particular type of source
                          or situation
                              Overridden by user settings.
                              Multiple tunings are separated by commas.
                              Only one psy tuning can be used at a time.
                              - film (psy tuning):
                                --deblock -1:-1 --psy-rd <unset>:0.15
                              - animation (psy tuning):
                                --bframes {+2} --deblock 1:1
                                --psy-rd 0.4:<unset> --aq-strength 0.6
                                --ref {Double if >1 else 1}
                              - grain (psy tuning):
                                --aq-strength 0.5 --no-dct-decimate
                                --deadzone-inter 6 --deadzone-intra 6
                                --deblock -2:-2 --ipratio 1.1 
                                --pbratio 1.1 --psy-rd <unset>:0.25
                                --qcomp 0.8
                              - stillimage (psy tuning):
                                --aq-strength 1.2 --deblock -3:-3
                                --psy-rd 2.0:0.7
                              - psnr (psy tuning):
                                --aq-mode 0 --no-psy
                              - ssim (psy tuning):
                                --aq-mode 2 --no-psy
                              - fastdecode:
                                --no-cabac --no-deblock --no-weightb
                                --weightp 0
                              - zerolatency:
                                --bframes 0 --force-cfr --no-mbtree
                                --sync-lookahead 0 --sliced-threads
                                --rc-lookahead 0
6
  • 2
    I was under the impression that --tune film is for grainy material, but from what you're saying it's synonymous with high-quality input; basically, if my sources are always great quality, then I should always use this tune. And then --tune grain should be used for things such as very old film material. Is that correct? Jun 9, 2013 at 0:57
  • 8
    @Florin Both are for high-quality sources, but --tune film will filter some of the grain and --tune grain will preserve more of it. AIUI the latter should only be used if the grain is an important part of the visuals that could still be noticeable at the target settings.
    – Tobu
    Aug 27, 2013 at 0:32
  • 13
    --tune film is for live-action content: anything shot on a camera, as opposed to cel animation or computer generated text/charts. It is even suitable for somewhat realistic 3d animation, so don't let the "film" part food you. It works for grainy and non-grainy sources and balances grain retention with overall quality-per-bitrate, whereas --tune grain will try to preserve grain at any cost; useful if keeping the grain is a must-have for some reason. --tune film does NOT only help for high bitrate (indeed, tunings tend to have more of an effect on lower bitrates in general). Aug 12, 2014 at 12:47
  • 13
    Note: "stillimage" is for people writing tools that use x264 to encode a single still frame, as an alterntive to JPEG or JPEG2000. It could however still be helpful for people doing a video which is essentially a slideshow of still images where a static image is shown unchanged for many frames before changing to the next image, as long as it literally is a static slide show with no transitions. The point of "stillimage" is that it boosts certain psy optimisations that would improve single frames at the expense of harming motion. Dec 16, 2014 at 3:58
  • 6
    Further note: x264 never "filters" grain. What we are altering is the extent to which the encoder gives grain special treatment. "grain" preset, for example, optimises the codec for situations where grain is significant and present everywhere and will alter the codec to better deal with that situation and make the grain look more even. Grain is never filtered by any setting (except nr), it is just inherently hard to compress efficiently and hard for codecs to make look nice unless you have specifically tuned for it. If you have not allocated enough bitrate for your encode, grain will suffer. Sep 13, 2020 at 22:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .