master-of-zen / Av1an

Cross-platform command-line AV1 / VP9 / HEVC / H264 encoding framework with per scene quality encoding
GNU General Public License v3.0
1.51k stars 155 forks source link

Does `--video-params` disable default parameters and prevent target quality? #662

Open mqudsi opened 2 years ago

mqudsi commented 2 years ago

I observed that if I run av1an -e svt-av1 --target-quality=xx .... the output includes

Params: --preset 4 --keyint 240 --rc 0 --crf 25

But if I run av1an -e svt-av1 -v '--preset 10' --target-quality=xx ..., the output just says

Params: --preset 10

To me, this implies that the presence of an explicitly specified --video-params is preventing av1an from supplying its own parameters. My reading of the help output led me to assume that --video-params would be in addition to to and not instead of the default per-encoder video parameters av1an used to get its job done.

IMHO, av1an should always pass its video parameters unless the -v includes the same parameter (in which case the manually supplied parameter should win) - this would be for things like --preset, --keyint, etc. But if -v included --crf and --target-quality was used, I would expect av1an to throw an error complaining that --crf and --target-quality cannot be used together.

clidx commented 2 years ago

I agree with both of your points, but would just add that --crf and --target-quality not conflicting is a holdover from before when --crf had to be manually specified in the params so that av1an could change it. Now, not having them conflict adds unnecessary ambiguity about what av1an is actually doing.

mqudsi commented 2 years ago

Aside from fixing this, can you enlighten me as to what av1an is doing in this case? Is it currently possible to use target quality with a different svt-av1 preset?

FreezyLemon commented 2 years ago

When av1an shows you

Params: --preset 4 --keyint 240 --rc 0 --crf 25

it just means that those are the "base" parameters it uses for encoding. Target quality mode decides on a CRF value for every chunk based on your target quality setting, which means your actual encoder parameters will be --preset 4 --keyint 240 --rc 0 --crf x, with x possibly being different for every chunk.

If you use custom --video-params, that just means that your "base" parameters are different. It does not mean that av1an won't be able to change the CRF value. If you use --video-params "--preset 8 --keyint 0 --lookahead 60", then av1an will automatically add the required stuff to make it work: --preset 8 --keyint 0 --lookahead 60 --crf x. Again, x being decided by the target quality algorithm.

Small edit: Target quality or not, av1an only uses default encoder parameters if you do not use --video-params. Just FYI

mqudsi commented 2 years ago

Thanks for the explanation! I definitely wasn’t able to intuit that from the output.