gianni-rosato / svt-av1-psy

The Scalable Video Technology for AV1 (SVT-AV1 Encoder and Decoder) with perceptual enhancements for psychovisually optimal AV1 encoding
BSD 3-Clause Clear License
148 stars 13 forks source link

[BUG] Broken ratecontrol with --tune 3 and --mbr specified #32

Open krakoi opened 4 months ago

krakoi commented 4 months ago

If max bitrate and tune 3 is set, then the encoded video has heavy compression artifacts in the first few seconds, the encoder allocates too low bitrate to the start of the video. Later parts are fine. Tune 0 has no such issue, nor tune 3 without a max bitrate cap.

Short example video and encoded variants illustrating the issue: https://gofile.io/d/UQkYDK

CMD for encoding the above videos:

# test_tune0_mbr36.mp4
... | SvtAv1EncApp -i stdin --input-depth 10 --passes 2 --progress 3 --crf 48 --mbr 36m --preset 4 --tune 0 --lookahead 120 --tile-rows 1 --tile-columns 2 --variance-boost-strength 0 --variance-octile 0 --color-primaries 1 --transfer-characteristics 1 --matrix-coefficients 1 --color-range 0 --chroma-sample-position 1 -b "test_tune0_mbr36.mp4"

# test_tune3_mbr36.mp4:
... | SvtAv1EncApp -i stdin --input-depth 10 --passes 2 --progress 3 --crf 48 --mbr 36m --preset 4 --tune 3 --lookahead 120 --tile-rows 1 --tile-columns 2 --variance-boost-strength 0 --variance-octile 0 --color-primaries 1 --transfer-characteristics 1 --matrix-coefficients 1 --color-range 0 --chroma-sample-position 1 -b "test_tune3_mbr36.mp4"

# test_tune_3_no_mbr.mp4:
... | SvtAv1EncApp -i stdin --input-depth 10 --passes 2 --progress 3 --crf 48 --preset 4 --tune 3 --lookahead 120 --tile-rows 1 --tile-columns 2 --variance-boost-strength 0 --variance-octile 0 --color-primaries 1 --transfer-characteristics 1 --matrix-coefficients 1 --color-range 0 --chroma-sample-position 1 -b "test_tune_3_no_mbr.mp4"

Current master ( c233913e82fa44caec4a0f08efabb861b2f81edf ) is used for encoding the example videos.

JaitinPrakash commented 3 months ago

I've experienced the same issue. even using crf 1 and all the boosting at max strength and mbr at 5x source bitrate it generates garbage. but for me, this continues through the whole video. ffmpeg reports that svt is pretty much pinned at q=63 with occasional drops. I'm also on latest master.

gianni-rosato commented 3 months ago

Thanks for bringing this up, someone from our team will be looking at this ASAP.