Alkl58 / NotEnoughAV1Encodes

GUI for AV1 (aomenc, rav1e & svt-av1)
MIT License
546 stars 24 forks source link

[Feature]AMF/VCE hardware encoding #135

Open ccxx369 opened 1 year ago

ccxx369 commented 1 year ago

Supports AV1 HEVC hardware encoding(AMF/VCE) on AMD Radeon RX7000 Series

Sacred-Shadow commented 1 year ago

@Alkl58 AV1 FFmpeg support meanwhile AMD cards. https://trac.ffmpeg.org/wiki/Encode/AV1 image

Can you add now the av1_amf?

Sacred-Shadow commented 1 year ago

Gibt es hierzu schon eine zeitliche Aussicht?

32bitx64bit commented 12 months ago

1+ OBS has supported AMF AV1 for awhile now, its about time us AMD users get a hardware encoder!

Alkl58 commented 10 months ago

AMF AV1 has been added in the latest release.

I am not able to test it, as I don't have a AMD GPU.

I put the following comment in the code, might worth a read for you:

        /*
         * The implementation is pretty questionable
         * There is basically no documentation available online
         * Some unassuring things I found:
         *      - https://trac.ffmpeg.org/ticket/10389 (av1_amf ignores most quality/bitrate settings except for b:v)
         *      - https://trac.ffmpeg.org/ticket/10266 (Issues when using av1_amf to encode a video)*
         *        *does this mean that amd amf only supports 1080p!?
         *      - Supported pixel formats: nv12 yuv420p d3d11 dxva2_vld (no 422/444 ... really?!)
         *  
         *  It's unclear which arguments should be mixed with which.
         */

https://github.com/Alkl58/NotEnoughAV1Encodes/blob/master/NotEnoughAV1Encodes/Encoders/AMFAV1.cs

ccxx369 commented 10 months ago

Error: No output detected The graphics card is RX 7900XT

log 2024/1/31 21:18:55 : ========================================================== 2024/1/31 21:18:55 : INFO - Started Async Task - UID: MIpQgKmbOnPUXpy 2024/1/31 21:18:55 : INFO - Input: G:\视频\Unknown.mp4 2024/1/31 21:18:55 : INFO - Output: C:\Users\My-On\Desktop\Unknown.mkv 2024/1/31 21:18:55 : INFO - Temp Folder: C:\Users\My-On\AppData\Local\Temp\NEAV1E\MIpQgKmbOnPUXpy 2024/1/31 21:18:55 : ========================================================== 2024/1/31 21:18:55 : DEBUG - GetFrameCount() 2024/1/31 21:18:55 : INFO - GetFrameCount() => 3630 2024/1/31 21:18:55 : DEBUG - ExtractSubtitles.Extract() 2024/1/31 21:18:55 : WARN - ExtractSubtitles.Extract() => File already exist - Resuming? 2024/1/31 21:18:55 : WARN - Queue is being processed in Parallel 2024/1/31 21:18:55 : DEBUG - EncodeAudio.Encode() 2024/1/31 21:18:55 : INFO - EncodeAudio.Encode() => Command: -map 0:a:0 -c:a:0 copy -ac:a:0 2 -metadata:s:a:0 language=und 2024/1/31 21:18:56 : DEBUG - EncodeAudio.Encode() => ExitCode: 0 2024/1/31 21:18:56 : TRACE - GetVFRTimeStamps() 2024/1/31 21:18:56 : TRACE - GetVFRTimeStamps() => return 2024/1/31 21:18:56 : TRACE - VideoEncode.Encode() 2024/1/31 21:18:56 : INFO - VideoEncode.Encode() => Chunk: G:\视频\Unknown.mp4 2024/1/31 21:18:56 : INFO - VideoEncode.Encode() => Command: /C ffmpeg.exe -y -i "G:\视频\Unknown.mp4" -an -sn -map_metadata -1 -pix_fmt yuv420p -c:v av1_amf -quality speed -rc cqp -qp 24 "C:\Users\My-On\AppData\Local\Temp\NEAV1E\MIpQgKmbOnPUXpy\Video\000000.ivf" 2024/1/31 21:18:56 : TRACE - VideoEncode.Encode() => Added PID: 13576 Chunk: G:\视频\Unknown.mp4 2024/1/31 21:19:01 : TRACE - VideoEncode.Encode() => Removed PID: 13576 Chunk: G:\视频\Unknown.mp4 2024/1/31 21:19:01 : INFO - VideoEncode.Encode() => Exit Code: 0 Chunk: G:\视频\Unknown.mp4 2024/1/31 21:19:01 : DEBUG - VideoMuxer.Concat() 2024/1/31 21:19:01 : DEBUG - VideoMuxer.Concat() => Reading Chunk Directory by *.webm files 2024/1/31 21:19:01 : DEBUG - VideoMuxer.Concat() => Writing chunks.txt ... 2024/1/31 21:19:01 : DEBUG - VideoMuxer.Concat() => Wrote 0 Chunk(s) to chunks.txt 2024/1/31 21:19:01 : DEBUG - VideoMuxer.Concat() => Command: ffmpeg.exe -y -f concat -safe 0 -i "C:\Users\My-On\AppData\Local\Temp\NEAV1E\MIpQgKmbOnPUXpy\chunks.txt" -c copy "C:\Users\My-On\AppData\Local\Temp\NEAV1E\MIpQgKmbOnPUXpy\temp_mux.mkv" 2024/1/31 21:19:01 : DEBUG - VideoMuxer.Concat() => MuxWithMKVMerge? : True 2024/1/31 21:19:01 : DEBUG - VideoMuxer.Concat() => MuxWithFFmpeg? : False 2024/1/31 21:19:01 : DEBUG - VideoMuxer.Concat() => AudioCommand? : --default-track 0:yes "C:\Users\My-On\AppData\Local\Temp\NEAV1E\MIpQgKmbOnPUXpy\Audio\audio.mkv" 2024/1/31 21:19:01 : DEBUG - VideoMuxer.Concat() => SubsCommand? : 2024/1/31 21:19:01 : DEBUG - VideoMuxer.Concat() => VFRCommand? : 2024/1/31 21:19:01 : FATAL - VideoMuxer.Concat() => Exit Code: 2 2024/1/31 21:19:01 : FATAL - VideoMuxer.Concat() => STDOUT: mkvmerge v82.0 ('I'm The President') 64-bit 閿欒: 鏂囦欢 锝:\Users\My-On\AppData\Local\Temp\NEAV1E\MIpQgKmbOnPUXpy\temp_mux.mkv锝?鏃犳硶浠ヨ鍙栨ā寮忔墦寮€: open file error銆?

Alkl58 commented 10 months ago

Could you try manually executing the following from CMD?: ffmpeg.exe -y -i "G:\视频\Unknown.mp4" -an -sn -map_metadata -1 -pix_fmt yuv420p -c:v av1_amf -quality speed -rc cqp -qp 24 "C:\Users\My-On\AppData\Local\Temp\NEAV1E\MIpQgKmbOnPUXpy\Video\000000.ivf (You may have to change output path)

If you are willing to help, I would like to send you a zip file with a bunch of tests you can execute.

ccxx369 commented 10 months ago

ffmpeg version 2023-11-15-git-78f55457c9-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers built with gcc 12.2.0 (Rev10, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 58. 32.100 / 58. 32.100 libavcodec 60. 33.100 / 60. 33.100 libavformat 60. 17.100 / 60. 17.100 libavdevice 60. 4.100 / 60. 4.100 libavfilter 9. 13.100 / 9. 13.100 libswscale 7. 6.100 / 7. 6.100 libswresample 4. 13.100 / 4. 13.100 libpostproc 57. 4.100 / 57. 4.100 [in#0 @ 000002381833d380] Error opening input: No such file or directory Error opening input file G:\视频\Unknown.mp4. Error opening input files: No such file or directory

Alkl58 commented 10 months ago

Are you sure that the input file G:\视频\Unknown.mp4 exists?

ccxx369 commented 10 months ago

yes,of course

Alkl58 commented 10 months ago

Does the following work: ffmpeg.exe -y -i "G:\视频\Unknown.mp4" -pix_fmt yuv420p -c:v libx264 -crf 22 outtest.mp4?

Because the error message clearly states that it couldn't open the input file. (Maybe permission issue?)

ccxx369 commented 10 months ago

Perfect operation C:\Users\My-On>ffmpeg.exe -y -i "G:\视频\Unknown.mp4" -pix_fmt yuv420p -c:v libx264 -crf 22 outtest.mp4 ffmpeg version 2023-11-15-git-78f55457c9-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers built with gcc 12.2.0 (Rev10, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 58. 32.100 / 58. 32.100 libavcodec 60. 33.100 / 60. 33.100 libavformat 60. 17.100 / 60. 17.100 libavdevice 60. 4.100 / 60. 4.100 libavfilter 9. 13.100 / 9. 13.100 libswscale 7. 6.100 / 7. 6.100 libswresample 4. 13.100 / 4. 13.100 libpostproc 57. 4.100 / 57. 4.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'G:\视频\Unknown.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.76.100 Duration: 00:02:01.00, start: 0.000000, bitrate: 6021 kb/s Stream #0:00x1: Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 5853 kb/s, 30 fps, 30 tbr, 15360 tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] Stream #0:10x2: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (aac (native) -> aac (native)) Press [q] to stop, [?] for help [libx264 @ 000002222e756400] using SAR=1/1 [libx264 @ 000002222e756400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512 [libx264 @ 000002222e756400] profile High, level 4.0, 4:2:0, 8-bit [libx264 @ 000002222e756400] 264 - core 164 r3161 a354f11 - H.264/MPEG-4 AVC codec - Copyleft 2003-2023 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=34 lookahead_threads=5 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=22.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 Output #0, mp4, to 'outtest.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf60.17.100 Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 15360 tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] encoder : Lavc60.33.100 libx264 Side data: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] encoder : Lavc60.33.100 aac [out#0/mp4 @ 000002222e9fee40] video:19827kB audio:1896kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.605903% frame= 3630 fps=363 q=-1.0 Lsize= 21855kB time=00:02:00.98 bitrate=1479.9kbits/s speed=12.1x [libx264 @ 000002222e756400] frame I:15 Avg QP:13.77 size:278813 [libx264 @ 000002222e756400] frame P:915 Avg QP:17.67 size: 10017 [libx264 @ 000002222e756400] frame B:2700 Avg QP:23.58 size: 2576 [libx264 @ 000002222e756400] consecutive B-frames: 0.8% 0.0% 0.0% 99.2% [libx264 @ 000002222e756400] mb I I16..4: 36.5% 25.1% 38.4% [libx264 @ 000002222e756400] mb P I16..4: 0.9% 1.2% 0.1% P16..4: 15.2% 4.2% 2.8% 0.0% 0.0% skip:75.6% [libx264 @ 000002222e756400] mb B I16..4: 0.3% 0.4% 0.0% B16..8: 15.0% 0.6% 0.1% direct: 0.2% skip:83.4% L0:37.4% L1:62.0% BI: 0.6% [libx264 @ 000002222e756400] 8x8 transform intra:47.2% inter:75.8% [libx264 @ 000002222e756400] coded y,uvDC,uvAC intra: 37.4% 42.3% 20.3% inter: 2.5% 2.3% 0.1% [libx264 @ 000002222e756400] i16 v,h,dc,p: 37% 8% 31% 25% [libx264 @ 000002222e756400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 7% 53% 2% 2% 4% 1% 3% 1% [libx264 @ 000002222e756400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 15% 23% 6% 7% 6% 7% 5% 7% [libx264 @ 000002222e756400] i8c dc,h,v,p: 64% 10% 22% 4% [libx264 @ 000002222e756400] Weighted P-Frames: Y:0.0% UV:0.0% [libx264 @ 000002222e756400] ref P L0: 68.6% 5.3% 17.8% 8.3% [libx264 @ 000002222e756400] ref B L0: 73.7% 24.0% 2.2% [libx264 @ 000002222e756400] ref B L1: 91.3% 8.7% [libx264 @ 000002222e756400] kb/s:1342.31 [aac @ 000002222e7f98c0] Qavg: 348.694