notes about ffmpeg (mainly compression)
I tend to make long ffmpeg strings to test compression for stuff before forgetting my results. no longer. I shall write them down now
these are generally things that don’t really make it in my ffmpeg wrapper scripts as part of my miscellaneous scripts, as they apply across the board and usually require flexible experimentation that can’t necessarily be scripted
h265/x265
good for things that are “noisy”. parameters can be found on the x265 docs
R.E.P.O. clips seem to have much nicer quality in x265 instead of av1. I settled on this for now for repo clips:
ffmpeg -i INPUT -c:a copy -c:v libx265 -crf 27 -x265-params 'no-sao=1:keyint=300:min-keyint=300' -preset slower OUTPUT.mp4
probably don’t need crf 27 for most stuff, 29-33 seems reasonable. REPO is just noisy.
av1
good for things that are “smooth” and less noisy. parameters can be found on the project page. I use it for resonite clips
my go-to is crf 40. 10-bit is recommended even if source is 8-bit for slightly more depths on the blacks for little to no filesize increase. this is usually my starting cmdline when encoding videos overnight:
ffmpeg -i INPUT -c:a copy -c:v libsvtav1 -crf 40 -svtav1-params 'tune=0' -pix_fmt yuv420p10le -preset 3 OUTPUT.webm
2 pass
if you get an error like can't open ffmpeg2pass-2.log
and are wondering why in the world it’s trying to open -2
when your first pass had -0
, it’s because ffmpeg uses the output video track for the number on the pass file. when doing the first pass, there’s no audio, so it outputs -0
. on the second pass, if the video is after the audio, it’s going to open -1
or -2
or whatever.
you can work around this by explicitly stating -c:v:0
for both passes
vp9
parameters can be found on ffmepg-codecs
I don’t find vp9 to have a lot of use between h265 and av1, but occasionally it might win me out when pixel-peeking. noting the aforementioned 2-pass shenanigans:
ffmpeg -i INPUT -c:v:0 libvpx-vp9 -crf CRF -g KEYINT -keyint_min KEYINT -b:v 0 -pass 1 -an -f null /dev/null \
&& ffmpeg -i INPUT -c:v:0 libvpx-vp9 -c:a copy -crf CRF -g KEYINT -keyint_min KEYINT -b:v 0 -pass 2 OUTPUT.webm
overall
keyint of about 5 seconds (300
for 60fps videos, etc.) seems to be fine for most stuff.