How to use qvbr?
Hi!
I'm trying to figure out how to properly use qvbr.
For example using:
--max-bitrate 10000 --vbv-bufsize 10000 --qvbr 5000
Results in a average bitrate of 20Mbit/s.
That seems wrong?
Some posts over the AMF github suggests that qvbr mode needs pre-analysis to be enabled. But when I enable pre-analysis, VCEEnc tells me that it isn't supported.
That's on 6800XT and latest 22.6.1 driver.
Current version had problem handling pre-analysis, it was reporting pre-analysis isn't supported even though it is.
I've made a test build which will allow using pre-analysis with H.264 VBR/QVBR encoding.
Would you please have a try with the test build?
Thanks for the test build. pre-analysis seems to work now but the bitrate still seems far off. (like that the bitrate paramters are ignored)
I used this command line:
--quality slow --profile high --level 4.1 --bframes 2 --b-pyramid --max-bitrate 10000 --vbv-bufsize 10000 --vbaq --qvbr 5000
The average bitrate after encoding was ~30Mbit/s.
There is also this message:
storage->SetProperty(BPicturesDeltaQP)=6 failed: invalid param..
storage->SetProperty(ReferenceBPicturesDeltaQP)=4 failed: invalid param..
How about using --qvbr-quality? Smaller value seems to result smaller output size.
"invalid param" shows params not accepted (ignored) by the driver.
There is not much of a difference.
VCEEnc (x64) 7.01 (r1134) by rigaya, Jul 14 2022 12:57:39 (VC 1932/Win)
OS: Windows 10 x64 (19044) [UTF-8]
CPU: AMD Ryzen 9 3900XT 12-Core Processor [4.32GHz] (12C/24T)
GPU: AMD Radeon RX 6800 XT, AMF Runtime 1.4.25 / SDK 1.4.24
Input Info: AviSynth+ 3.7.2 r3661(yv12)->nv12 [AVX2], 1920x808, 24/1 fps
Vpp Filters copyHtoD
Output: H.264/AVC High @ Level 4.1
1920x808p 101:100 24.000fps (24/1fps)
Quality: slow
QVBR: 5000 kbps
QVBR level: 1
Max bitrate: 10000 kbps
QP: Min: 0, Max: 51
VBV Bufsize: 10000 kbps
Bframes: 2 frames, b-pyramid: on
Delta QP: Bframe: 0, RefBframe: 0
Pre Analysis: sc medium, ss high, activity y, caq medium
Ref frames: 2 frames
LTR frames: 0 frames
Motion Est: Q-pel
Slices: 1
GOP Len: 240 frames
Others: deblock vbaq
encoded 2201 frames, 119.80 fps, 48443.98 kbps, 529.61 MB
encode time 0:00:18, CPU: 5.4%, GPU: 7.2%, VE: 94.9%
frame type IDR 1467
frame type I 1467, total size 352.47 MB
frame type P 734, total size 177.14 MB
Terminating internal PA thread
VCEEnc (x64) 7.01 (r1134) by rigaya, Jul 14 2022 12:57:39 (VC 1932/Win)
OS: Windows 10 x64 (19044) [UTF-8]
CPU: AMD Ryzen 9 3900XT 12-Core Processor [4.26GHz] (12C/24T)
GPU: AMD Radeon RX 6800 XT, AMF Runtime 1.4.25 / SDK 1.4.24
Input Info: AviSynth+ 3.7.2 r3661(yv12)->nv12 [AVX2], 1920x808, 24/1 fps
Vpp Filters copyHtoD
Output: H.264/AVC High @ Level 4.1
1920x808p 101:100 24.000fps (24/1fps)
Quality: slow
QVBR: 5000 kbps
QVBR level: 24
Max bitrate: 10000 kbps
QP: Min: 0, Max: 51
VBV Bufsize: 10000 kbps
Bframes: 2 frames, b-pyramid: on
Delta QP: Bframe: 0, RefBframe: 0
Pre Analysis: sc medium, ss high, activity y, caq medium
Ref frames: 2 frames
LTR frames: 0 frames
Motion Est: Q-pel
Slices: 1
GOP Len: 240 frames
Others: deblock vbaq
encoded 2201 frames, 120.31 fps, 48432.03 kbps, 529.48 MB
encode time 0:00:18, CPU: 5.4%, GPU: 7.8%, VE: 98.6%
frame type IDR 1467
frame type I 1467, total size 352.34 MB
frame type P 734, total size 177.14 MB
Terminating internal PA thread
VCEEnc (x64) 7.01 (r1134) by rigaya, Jul 14 2022 12:57:39 (VC 1932/Win)
OS: Windows 10 x64 (19044) [UTF-8]
CPU: AMD Ryzen 9 3900XT 12-Core Processor [4.31GHz] (12C/24T)
GPU: AMD Radeon RX 6800 XT, AMF Runtime 1.4.25 / SDK 1.4.24
Input Info: AviSynth+ 3.7.2 r3661(yv12)->nv12 [AVX2], 1920x808, 24/1 fps
Vpp Filters copyHtoD
Output: H.264/AVC High @ Level 4.1
1920x808p 101:100 24.000fps (24/1fps)
Quality: slow
QVBR: 5000 kbps
QVBR level: 51
Max bitrate: 10000 kbps
QP: Min: 0, Max: 51
VBV Bufsize: 10000 kbps
Bframes: 2 frames, b-pyramid: on
Delta QP: Bframe: 0, RefBframe: 0
Pre Analysis: sc medium, ss high, activity y, caq medium
Ref frames: 2 frames
LTR frames: 0 frames
Motion Est: Q-pel
Slices: 1
GOP Len: 240 frames
Others: deblock vbaq
encoded 2201 frames, 119.87 fps, 48418.70 kbps, 529.34 MB
encode time 0:00:18, CPU: 5.0%, GPU: 7.3%, VE: 95.5%
frame type IDR 1467
frame type I 1467, total size 352.18 MB
frame type P 734, total size 177.16 MB
Terminating internal PA thread
So the invalid param message is a driver bug? Because it also shows: Delta QP: Bframe: 0, RefBframe: 0
Which should be 6 and 4 according to the message.
Would be nice to have qvbr level working in conjunction with the max bitrate level paramter like it works on nvidia.
With my tests only --qvbr-quality affects the bitrate. (bitrate setting seems to be ignored as you have mentioned)
--qvbr-quality 10 x64\VCEEncC64.exe -i sample_movie_1080p.mpg -o F:\temp\test.264 --pre-analysis --qvbr 10000 --qvbr-quality 10
--------------------------------------------------------------------------------
F:\temp\test.264
--------------------------------------------------------------------------------
VCEEnc (x64) 7.01 (r1132) by rigaya, Jul 14 2022 21:40:27 (VC 1932/Win)
OS: Windows 11 x64 (22000) [UTF-8]
CPU: AMD Ryzen 9 5950X 16-Core Processor [3.56GHz] (16C/32T)
GPU: Radeon RX 5500 XT, AMF Runtime 1.4.24 / SDK 1.4.24
Input Info: avvce: MPEG2, 1920x1080, 30000/1001 fps
Vpp Filters copyDtoD
Output: H.264/AVC High @ Level 4
1920x1080p 1:1 29.970fps (30000/1001fps)
Quality: balanced
QVBR: 10000 kbps
QVBR level: 10
Max bitrate: 25000 kbps
QP: Min: 0, Max: 51
VBV Bufsize: 31250 kbps
Bframes: 0 frames
Pre Analysis: sc medium, ss high, activity y, caq medium
Ref frames: 2 frames
LTR frames: 0 frames
Motion Est: Q-pel
Slices: 1
GOP Len: 300 frames
Others: deblock
encoded 5203 frames, 77.28 fps, 819.38 kbps, 16.96 MB
encode time 0:01:07, CPU: 1.2%, GPU: 16.3%, VE: 65.5%
frame type IDR 19
frame type I 19, total size 0.44 MB
frame type P 5184, total size 16.52 MB
Terminating FGEN thread
--qvbr-quality 30 x64\VCEEncC64.exe -i sample_movie_1080p.mpg -o F:\temp\test.264 --pre-analysis --qvbr 10000 --qvbr-quality 30
--------------------------------------------------------------------------------
F:\temp\test.264
--------------------------------------------------------------------------------
VCEEnc (x64) 7.01 (r1132) by rigaya, Jul 14 2022 21:40:27 (VC 1932/Win)
OS: Windows 11 x64 (22000) [UTF-8]
CPU: AMD Ryzen 9 5950X 16-Core Processor [3.68GHz] (16C/32T)
GPU: Radeon RX 5500 XT, AMF Runtime 1.4.24 / SDK 1.4.24
Input Info: avvce: MPEG2, 1920x1080, 30000/1001 fps
Vpp Filters copyDtoD
Output: H.264/AVC High @ Level 4
1920x1080p 1:1 29.970fps (30000/1001fps)
Quality: balanced
QVBR: 10000 kbps
QVBR level: 30
Max bitrate: 25000 kbps
QP: Min: 0, Max: 51
VBV Bufsize: 31250 kbps
Bframes: 0 frames
Pre Analysis: sc medium, ss high, activity y, caq medium
Ref frames: 2 frames
LTR frames: 0 frames
Motion Est: Q-pel
Slices: 1
GOP Len: 300 frames
Others: deblock
encoded 5203 frames, 73.92 fps, 4514.54 kbps, 93.43 MB
encode time 0:01:10, CPU: 1.4%, GPU: 18.8%, VE: 63.2%
frame type IDR 19
frame type I 19, total size 1.80 MB
frame type P 5184, total size 91.63 MB
Terminating FGEN thread
Please try starting from the minimum options for simplification, as other options might interfere.
So the invalid param message is a driver bug?
No, it shows that the option is not supported on the driver or the hardware, so you can remove the options (--b-deltaqp, --bref-deltaqp), or just ignore the message.
Strange, even with minimum options it still doesn't work for me. --qvbr-quality 1 vs 51 results in the same average bitrate.
What driver are you using? Your output shows AMF Runtime 1.4.24 / SDK 1.4.24 while mine shows AMF Runtime 1.4.25 / SDK 1.4.24 And your version shows r1132 while mine shows r1134
Strange...
I'm using driver 22.4.2.
The revision was r1132 because I was using my local build, I checked again but was the same with r1134.
Small update: I tried the latest "pro" drivers but they have the same problem. However, the latest driver from windows update (for win11, I'm on win10 but works anyway) seems to work better. Changing the quality parameter actually does effect the output bitrate with this drivers. But maxbitrate parameter still seems to be ignored. It's 31.0.12015.2001 with AMF Runtime 1.4.26 / SDK 1.4.24. But it is as slow as all other ones, only like ~90fps/s. VE says ~50% usage. With older drivers it says 90 fps/s but VE at 100% usage.
Bitrate seems to change now when adjusting the qvbr-quality value. I'm not sure if your updated version or the newer drivers did the trick.
//edit According to this doc: https://github.com/GPUOpen-LibrariesAndSDKs/AMF/wiki/Rate%20Control%20Methods
There is only a qvbr level and no bitrate option. So qvbr bitrate setting actually does nothing?
There is also PCVBR with peak bitrate constrain. Is the peak bitrate set by max_bitrate? And is it possible to have qvbr and peak bitrate constrain work together?
Sorry for reviving old thread. But it actually is fitting to write here.
There is also PCVBR with peak bitrate constrain. Is the peak bitrate set by max_bitrate?
Yes. Precisely.
According to this doc: https://github.com/GPUOpen-LibrariesAndSDKs/AMF/wiki/Rate%20Control%20Methods There is only a qvbr level and no bitrate option. So qvbr bitrate setting actually does nothing?
It actually does nothing.
So i want to ask @rigaya if it is possible to slightly change functionality for existing argument for rate control method?
--qvbr should not request bitrate as it will be promptly ignored. And currently it requests bitrate value to work (technically you can set it to 0, but it's not a point). Right now to properly use QVBR user must explicitly state --qvbr-quality with target QVBR QP level. Frankly speaking you can ignore --qvbr option completely and directly request --qvbr-quality as it is only thing that matters.
From user experience standpoint, would it not be reasonable to just make --qvbr flag to work as current --qvbr-quality parameter. Meaning it should accept QVBR QP level as input instead of bitrate which would be discarded anyways.
For context how it would look in documentation (QVBR QP levels are inversed compared to CQP, so i think mentioning this may be important):
--qvbr <int>
Sets QVBR quality level (1-51) in QP. 1 is lowest quality and 51 is highest.
Also, --qvbr-quality does not accept 0 even if stated in current VCEEnc_Options.en.md
Instead it defaults to 23.
Here is proof:
Command (--qvbr-quality 0): ./VCEEncC64.exe -i "C:\Users\-----\Videos\test sample\Big_Buck_Bunny_1080_10s_10MB.mp4" -o "Big_Buck_Bunny_1080_10s_10MB_processed.mp4" --codec avc --profile main --preset slow --qvbr-quality 0 --audio-copy
Output (QVBR level: 23):
--------------------------------------------------------------------------------
Big_Buck_Bunny_1080_10s_10MB_processed.mp4
--------------------------------------------------------------------------------
Pre-analysis will be enabled for QVBR mode.
storage->SetProperty(QvbrQualityLevel)=0 failed: out of range..
VCEEnc (x64) 8.23 (r1710) by rigaya, Jul 18 2024 12:57:57 (VC 1940/Win)
OS: Windows 11 x64 (22631) [UTF-8]
CPU: AMD Ryzen 7 5800X3D 8-Core Processor [4.48GHz] (8C/16T)
GPU: AMD Radeon RX 7800 XT [32.0.11029.1008]
AMF: Runtime 1.4.34 / SDK 1.4.34
Input Info: avvce: H.265/HEVC, 1920x1080, 30/1 fps
Output: H.264/AVC Main @ Level 4
1920x1080p 1:1 30.000fps (30/1fps)
avwriter: h264 => mp4
Quality: slow
QVBR: 5000 kbps
QVBR level: 23
Max bitrate: 20000 kbps
QP: Min: 0:0, Max: 51:51
VBV Bufsize: 5000 kb
Bframes: 0 frames
Pre Analysis: sc medium, ss high, activity y
lookahead 0, caq medium, paq none, taq 0, motion-qual none, ltr off
Ref frames: 2 frames
LTR frames: 0 frames
Motion Est: Q-pel
Slices: 1
GOP Len: 300 frames
Others: skipframe:on deblock
Terminating internal PA thread , 4054 kb/s, remain 0:00:00, GPU 6%, VE 45%, est out size 3.3MB
encoded 300 frames, 283.29 fps, 4026.69 kbps, 4.80 MB
encode time 0:00:01, CPU: 1.3%, GPU: 6.0%, VE: 45.0%
frame type IDR 1
frame type I 1, avgQP 30.00, total size 0.14 MB
frame type P 299, avgQP 30.13, total size 4.66 MB