Explanation of x264 tune
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.
Solution 1:
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
andssim
– 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