GPUOpen-LibrariesAndSDKs / AMF

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

Error setting 4K framesize for AVC encoder on NAVI GPU (RX 5700) #193

Closed hgalaATmagix closed 4 years ago

hgalaATmagix commented 4 years ago

I get the following error when trying to encode 4K material using the AMF AVC encoder, using both the sample application (SimpleEncoder), and our own application (MAGIX VEGAS Pro).

SimpleEncoder.exe 2019-12-04 11:15:34.196 4780 [DriverParameterUVEH264Adapter] Error: ..........\runtime\src\components\EncoderUVE\DriverParameterUVEH264Adapter.cpp(308):AMF_ERROR 1 : AMF_FAIL: Failed to set UVEH264 param(2). err 0x80000002 2019-12-04 11:15:34.205 4780 [SimpleEncoder] Error: d:\code.etc\amf-master\amf\public\samples\cppsamples\simpleencoder\simpleencoder.cpp(186):AMF_ERROR 1 : AMF_FAIL: SetProperty(AMF_VIDEO_ENCODER_FRAMESIZE, 3840x2160) failed

Is this a known issue? I am able to encode 4K HEVC, and HD AVC fine. Also, this used to work fine on the older GPUs (tested on RX 470, WX 9100).

GPU driver version is 26.20.13025.10004 from 10/4/2019, and OS is Windows 10, v1903

MikhailAMD commented 4 years ago

Try to set compliant profile level (5.1) before resolution

hgalaATmagix commented 4 years ago

Thanks, but doing so produces the following set of errors:

D:\code.etc\AMF-master\amf\bin\vs2017x32Debug>SimpleEncoder.exe 2019-12-04 11:57:01.309 2E38 [DriverParameterUVEH264Adapter] Error: ..\..\..\..\..\runtime\src\components\EncoderUVE\DriverParameterUVEH264Adapter.cpp(308):AMF_ERROR 1 : AMF_FAIL: Failed to set UVEH264 param(2). err 0x80000002 2019-12-04 11:57:03.081 2E38 [AMFDeviceDX9Impl] Error: ..\..\..\..\..\runtime\src\core\DeviceDX9Impl.cpp(141):COM failed, HR = 80004005:CreateNativeSurface()-->CreateOffscreenPlainSurfaceEx 2019-12-04 11:57:03.088 2E38 [AMFDeviceDX9Impl] Error: ..\..\..\..\..\runtime\src\core\DeviceDX9Impl.cpp(200):AMF_ERROR 1 : AMF_FAIL: CreateNativeSurface(format, width, height, renderTarget, (void**)&pSurface) 2019-12-04 11:57:03.094 2E38 [AMFSurfaceImpl] Error: ..\..\..\..\..\runtime\src\core\SurfaceImpl.cpp(487):AMF_ERROR 1 : AMF_FAIL: AllocPlanes()- CreateSurface 2019-12-04 11:57:03.096 2E38 [AMFContextImpl] Error: ..\..\..\..\..\runtime\src\core\ContextImpl.cpp(929):AMF_ERROR 1 : AMF_FAIL: pSurface->Alloc(type, format, width, height, usage, access) 2019-12-04 11:57:03.102 2E38 [SimpleEncoder] Error: d:\code.etc\amf-master\amf\public\samples\cppsamples\simpleencoder\simpleencoder.cpp(243):AMF_ERROR 1 : AMF_FAIL: AllocSurface() failed

hgalaATmagix commented 4 years ago

Also, I tried this with the latest version of ffmpeg, and ran into possibly a similar issue (it works fine on the WX 9100, and with hevc_amf codec): D:\code.etc\ffmpeg-20191203-12bbfc4-win64-static\bin>ffmpeg -i d:\media\C0121.MP4 -c:v h264_amf -c:a copy d:\output1.mkv ffmpeg version git-2019-12-03-12bbfc4 Copyright (c) 2000-2019 the FFmpeg developers built with gcc 9.2.1 (GCC) 20191125 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf libavutil 56. 36.101 / 56. 36.101 libavcodec 58. 64.101 / 58. 64.101 libavformat 58. 35.101 / 58. 35.101 libavdevice 58. 9.101 / 58. 9.101 libavfilter 7. 67.100 / 7. 67.100 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100 libpostproc 55. 6.100 / 55. 6.100 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002a45dc688c0] st: 0 edit list: 1 Missing key frame while searching for timestamp: 1001 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002a45dc688c0] st: 0 edit list 1 Cannot find an index entry before timestamp: 1001. Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'd:\media\C0121.MP4': Metadata: major_brand : XAVC minor_version : 16785407 compatible_brands: XAVCmp42isom creation_time : 2015-04-09T23:59:59.000000Z Duration: 00:00:15.04, start: 0.000000, bitrate: 97191 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 3840x2160 [SAR 1:1 DAR 16:9], 97092 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default) Metadata: creation_time : 2015-04-09T23:59:59.000000Z handler_name : Video Media Handler encoder : AVC Coding Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default) Metadata: creation_time : 2015-04-09T23:59:59.000000Z handler_name : Sound Media Handler Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_amf)) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help [h264_amf @ 000002a45e278680] encoder->Init() failed with error 1 Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed!

MikhailAMD commented 4 years ago

Did you try to change profile level?

hgalaATmagix commented 4 years ago

Yes, as I indicated above. By setting the profile level prior to the frame size, it allows the 'encoder->SetProperty(AMF_VIDEO_ENCODER_FRAMESIZE, ::AMFConstructSize(widthIn, heightIn)' to succeed, but encoder->Init() subsequently fails with the following error: _498 [DriverParameterUVEH264Adapter] Error: ..........\runtime\src\components\EncoderUVE\DriverParameterUVEH264Adapter.cpp(308):AMF_ERROR 1 : AMFFAIL: Failed to set UVEH264 param(2). err 0x80000002

hgalaATmagix commented 4 years ago

Just out of curiosity, I also updated my drivers to the latest Adrenalin set (19.12.1-dec2), but that did not change anything.

MikhailAMD commented 4 years ago

I see the trace you mentioned but Init() returns AMF_OK. It is an internal issue and will be resolved in the next public driver (this week). In FFmpeg - probably they don't set level - or you should add it to the command line. In any case, the next driver will have automatic level adjustment.

hgalaATmagix commented 4 years ago

I have been able to get past and encode 4K AVC successfully inside VEGAS and ffmpeg using the tips you provided. The SimpleEncoder sample application still seems to have other issues as indicated above, but our code is not based on that, so I am closing this issue now . Thank you for all your help.