GPUOpen-LibrariesAndSDKs / AMF

The Advanced Media Framework (AMF) SDK provides developers with optimal access to AMD devices for multimedia processing
Other
617 stars 151 forks source link

[Question]: Using -rc for AV1_AMF #453

Open Plootie opened 9 months ago

Plootie commented 9 months ago

I'm trying to av1_amf in ffmpeg to encode some videos i have, however setting -rc to 4 or above yields an error

[av1_amf @ 0000018b9b4ca340] encoder->Init() failed with error 4 [vost#0:0/av1_amf @ 0000018b9b4ce180] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height. [vf#0:0 @ 0000018b9b4d7b00] Error sending frames to consumers: Internal bug, should not have happened [vf#0:0 @ 0000018b9b4d7b00] Task finished with error code: -558323010 (Internal bug, should not have happened) [vf#0:0 @ 0000018b9b4d7b00] Terminating thread with return code -558323010 (Internal bug, should not have happened) [vost#0:0/av1_amf @ 0000018b9b4ce180] Could not open encoder before EOF [vost#0:0/av1_amf @ 0000018b9b4ce180] Task finished with error code: -22 (Invalid argument) [vost#0:0/av1_amf @ 0000018b9b4ce180] Terminating thread with return code -22 (Invalid argument) [out#0/matroska @ 0000018b9b51ca80] Nothing was written into output file, because at least one of its streams received no packets. frame= 0 fps=0.0 q=0.0 Lsize= 0KiB time=N/A bitrate=N/A speed=N/A Conversion failed!

Is this intended or am i doing something wrong? I'd really like to use qvbr for this

My full command is ffmpeg -y -i adventure.mp4 -c:v av1_amf -rc 4 output1.mkv

DimkaTsv commented 9 months ago

Can confirm that some weirdness is going on. Not sure if issue is same for ffmpeg command, though. --qvbr in VCEEnc works fine for AVC and HEVC, but if i try to do it with AV1 AMF is getting stuck in permanent cycle with no hw encoder usage for me. Used command: %~dp0\VCEEncC64.exe -i %1 -o "%~n1_processed%~x1" --codec av1 --profile main --level 5.2 --preset balanced --qvbr 7000 --audio-copy --chapter-copy vceencc_log.txt

[AMFDecoderUVDImpl] 2024-02-18 02:25:09.125     3E38 [AMFDecoderUVDImpl]   Debug: AMFDecoderUVDImpl::SubmitInput()
[AMFEncoderCoreAv1] 2024-02-18 02:25:09.125      918 [AMFEncoderCoreAv1]   Debug: AMFEncoderCoreAv1Impl::QueryOutput()
[AMFEncoderCoreAv1] 2024-02-18 02:25:09.125      918 [AMFEncoderCoreAv1]   Debug: AMFEncoderCoreAv1Impl::SubmitInput() : format (NV12), memory (DX11), width (1920), height (1080)
[AMFPreAnalysisImpl] 2024-02-18 02:25:09.126      918 [AMFPreAnalysisImpl]   Debug: AMFPreAnalysisImpl::SubmitInput() : format (NV12), memory (DX11), width (1920), height (1080)
[AMFDecoderUVDImpl] 2024-02-18 02:25:09.127     3E38 [AMFDecoderUVDImpl]   Debug: AMFDecoderUVDImpl::SubmitInput()
[AMFEncoderCoreAv1] 2024-02-18 02:25:09.128      918 [AMFEncoderCoreAv1]   Debug: AMFEncoderCoreAv1Impl::QueryOutput()
[AMFEncoderCoreAv1] 2024-02-18 02:25:09.128      918 [AMFEncoderCoreAv1]   Debug: AMFEncoderCoreAv1Impl::SubmitInput() : format (NV12), memory (DX11), width (1920), height (1080)
[AMFDecoderUVDImpl] 2024-02-18 02:25:09.128     3E38 [AMFDecoderUVDImpl]   Debug: AMFDecoderUVDImpl::SubmitInput()
[AMFPreAnalysisImpl] 2024-02-18 02:25:09.129      918 [AMFPreAnalysisImpl]   Debug: AMFPreAnalysisImpl::SubmitInput() : format (NV12), memory (DX11), width (1920), height (1080)
[AMFEncoderCoreAv1] 2024-02-18 02:25:09.130      918 [AMFEncoderCoreAv1]   Debug: AMFEncoderCoreAv1Impl::QueryOutput()
[AMFEncoderCoreAv1] 2024-02-18 02:25:09.130      918 [AMFEncoderCoreAv1]   Debug: AMFEncoderCoreAv1Impl::SubmitInput() : format (NV12), memory (DX11), width (1920), height (1080)
[AMFDecoderUVDImpl] 2024-02-18 02:25:09.130     3E38 [AMFDecoderUVDImpl]   Debug: AMFDecoderUVDImpl::SubmitInput()
[AMFPreAnalysisImpl] 2024-02-18 02:25:09.131      918 [AMFPreAnalysisImpl]   Debug: AMFPreAnalysisImpl::SubmitInput() : format (NV12), memory (DX11), width (1920), height (1080)

But interesting part is that AMF_VIDEO_ENCODER_AV1_RATE_CONTROL_METHOD_QUALITY_VBR seems to be working in general for AV1 encoding. At least it was working when i managed to properly run it in AMD TranscodeHW tool... After bit of beating my head over wall because you MUST provide -Av1AlignmentMode, otherwise it transcode video throwing these errors. It took some time, as this option wasn't written in sample commands in documentation, and it has default value, so i thought it was optional, and not mandatory for manual input. [also option -codec in .md document for AV1 encode was written weirdly and was processed by Terminal as тАУcodec AV1 (yes, without minus sign)]

2024-02-18 03:02:58.217     37D8 [AMFEncoderCoreAv1]   Error: ..\..\..\..\..\runtime\src\components\EncoderCore\EncoderCoreAv1Impl.cpp(1678):Assertion failed:SubmitInput() - Encoder did not get initialized
2024-02-18 03:02:58.217     37D8 [AMFEncoderCoreAv1]   Error: ..\..\..\..\..\runtime\src\components\EncoderCore\EncoderCoreAv1Impl.cpp(1678):Assertion failed:SubmitInput() - Encoder did not get initialized
SubmitInput() returned error: AMF_NOT_INITIALIZED

They are gone if you provide -Av1AlignmentMode though, and there is actual output with %~dp0\TranscodeHW.exe -input %1 -output %~n1_processed%~x1 -codec AV1 -width 1920 -height 1080 -Av1AlignmentMode 2 -AV1RateControlMethod qvbr -AV1TargetBitrate 100000 command

[Also this line in ./HWTranscode.exe -helpdoesn't provide all options for AV1 in Terminal, even though they are documented in repository. ] [-Av1RateControlMethod Rate Control Method (CQP, CBR, VBR, VBR_LAT default = depends on USAGE)] [Aka there are no qvbr, hqvbr and hqcbr options being mentioned... AVC and HEVC options also don't cover all variants... Excuse me for being overly pedantic]