So, this is a follow-up to the 2nd part guide regarding aomenc-av1, which can be found here:
https://old.reddit.com/r/AV1/comments/lfheh9/encoder_tuning_part_2_making_aomencav1libaomav1/
While that guide is still fine for the most part at a first glance,
I’ve learned a lot regarding the pseudo-reference AV1 encoder, its options, its intricacies, and best of all, its shortcomings.
It now means I understand a lot more about the options themselves, what they do, how to take advantage of them, when to actually use them,
and even how to get around their downsides through some clever options and even a custom WIP build on how to address aomenc-av1’s greatest weakness:
a surprising lack of deep psycho-visual optimizations(intra only has a nice number of them, but barely any video coding versions).
Before I begin, I have to add that this is not a comprehensive documentation. A simple Reddit forum post is far too small for such a massive endeavour, so a separate post will be done with an entry on a dedicated Wiki of some sorts to explain what each and every option does in detail, and even speed-features and their explanations.
Now, to get on to the main subject of the post itself: the 2nd generation tuning guide for aomenc-av1!
— Encoder speed preset
- The encoder preset itself:
--cpu-used=X
.
For VOD purposes, this ranges from 0 (abominably slow) to 6 (decently fast) in the good preset.
For realtime purposes like streaming, the RT presets range from 5 to 10, with 5 being the slowest RT preset and 10 being the fastest.
For reference, the default is 0. Not exactly optimal…
My general recommendation for choosing what preset to utilize is based on speed, usability and quality.
In that context, all realtime presets are off of the table until aomenc gets their frame-threading merged into the mainline build due to their low single instance speed/quality ratio; you are better off using SVT-AV1 right now in that sense.
Otherwise, my general recommendation is in the middle: CPU-2 being the lowest preset I’d recommend actually using, CPU-3 being a good middle ground in general since it keeps most of the juicy features on.
CPU-4 is good for those wanting faster encoding than CPU-3 while not losing much. CPU-5 is where tradeoffs start getting a bit more severe since pruning and the disabling of features(particularly loop restoration filtering).
gets disabled. CPU-6 is the fastest I’d go utilizing aomenc. Any faster today, and going with SVT-AV1 is a better tradeoff.
General recommendations: --cpu-used=2
for slow encoding, --cpu-used=3
as the middle ground, and --cpu-used=5
as the fast option.
— Keyframe refresh intervals
--kf-max-dist=240 --kf-min-dist=12
This parameter dictates the maximum distance between statically placed keyframes(as in, keyframes not placed by the scene-detection algorithms).
For seeking purposes in most content, the standard recommendation is 10 seconds worth of frames, with 300 frames usually being the max number of frames being put to keep good seeking performance.
So, my recommendations would for 240 frames for 24FPS, 250 frames for 25FPS, and 300 frames for >30FPS content.
As for kf-min-dist, it is the minimum amount of frames before you can place a keyframe. This is mainly done in case the scene-detection fails to insert intra-refreshes or fails to detect flashes and places unnecessary keyframes all over the place.
— Threading options
--threads=cpu-threads --sb-size=64
for <=1080p content.
–threads=cpu-threads –sb-size=64 –tile-columns=1
for even higher encoder side threading and some decoder side tile threading.
--threads=cpu-threads --sb-size=64 --tile-columns=2 --tile-rows=1
if you need best threading for decoding purposes, particularly at higher resolutions.
--threads=cpu-threads --tile-columns=2 --tile-rows=1
for >1080p resolutions
--threads=2 --sb-size=64
+ thread pinning if you use chunked encoding to give yourself better thread scaling.
Now, threading in aomenc. What an interesting subject.
Aomenc has access to these threading parameters:
–