I don’t use multipass, so I’ll leave that to someone else, but here’s what I used to optimize AV1 encoding quality on my A380 (on Jellyfin) according to Intel’s quality optimization guide:
-look_ahead_depth 99 \
-look_ahead_depth (LAD) requires -extbrc 1, and recommended value for quality is 40. It also requires -extra_hw_frames to be set to the same value:
-extbrc 1 \
-look_ahead_depth 40 \
-extra_hw_frames 40 \
-b:v 1M \
For CBR, Intel also recommends to set -bufsize to at least 2 times the bitrate to maximize quality. In this case, 2M should be used. Also -rc_init_occupancy should also be set for initial buffer delay. The recommended value is half of bitrate:
-b:v 1M \
-bufsize 2M \
-rc_init_occupancy 512K \
Other optimizations:
-
-adaptive_i 1for adaptive scene change detection -
-adaptive_b 1for adaptive miniGOP -
-b_strategy 1 -bf 7activate full 3 level B-Pyramid. Note that-bfshould be set to less value than LAD. (If LAD is 40, then valid value is up to 39.)
So final command (untested):
ffmpeg \
-i input.mp4 \
-init_hw_device vaapi=va:/dev/dri/renderD128 \
-c:v av1_qsv \
-preset veryslow \
-extbrc 1 \
-look_ahead_depth 40 \
-extra_hw_frames 40 \
-b:v 1M \
-bufsize 2M \
-rc_init_occupancy 512K \
-low_power 0 \
-adaptive_i 1 \
-adaptive_b 1 \
-b_strategy 1 -bf 7 \
output.mp4
Typically I run VBR, but this settings halved the encoding speed while giving a much better quality. SVT-AV1 still produces a better result at a smaller filesize however (but it’s wayyyy too slow compared to QSV).
Forcing ExtBRC to use the new EncTools by setting -extbrc 1 -look_ahead_depth 40 (or any value above 1) seems to be what helps with quality on QSV AV1.