ffmpeg-build-script
ffmpeg-build-script copied to clipboard
[Question] How to HWencode with AMF ?
trafficstars
My PC has a 5700G, running Ubuntu 20.04.3.
I used Docker build instructions and succesfully build latest ffmpeg docker image. Thank you for this. I also installed amdgpu-pro by this command:
amdgpu-install --accept-eula --usecase=amf,graphics,multimedia,dkms,opencl --opencl=rocr,legacy --vulkan=pro
And now I am trying to HW encode a video file, but I am getting this error:
stulluk ~/Videos $ rm -f output.mp4 ; docker run --rm -v$(pwd):/tmp ffmpeg:default -i /tmp/VID_20220203_201617.mp4 -c:v h264_amf /tmp/output.mp4
ffmpeg version 5.0 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
configuration: --enable-libdav1d --enable-libsvtav1 --enable-libvpx --enable-libaom --enable-libzimg --enable-lv2 --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libtheora --enable-libwebp --enable-amf --disable-debug --disable-doc --disable-shared --enable-pthreads --enable-static --enable-small --enable-version3 --extra-cflags='-I/app/workspace/include -I/app/workspace/include/lilv-0' --extra-ldexeflags= --extra-ldflags=-L/app/workspace/lib --extra-libs='-ldl -lpthread -lm -lz' --pkgconfigdir=/app/workspace/lib/pkgconfig --pkg-config-flags=--static --prefix=/app/workspace --extra-version=
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/VID_20220203_201617.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2022-02-03T17:30:18.000000Z
location : +40.8954+029.1963/
location-eng : +40.8954+029.1963/
com.android.version: 9
Duration: 00:14:00.98, start: 0.000000, bitrate: 20099 kb/s
Stream #0:0[0x1](eng): Video: h264 (avc1 / 0x31637661), yuvj420p(pc, smpte170m, progressive), 1920x1080, 20000 kb/s, SAR 1:1 DAR 16:9, 29.30 fps, 29.33 tbr, 90k tbn (default)
Metadata:
creation_time : 2022-02-03T17:30:18.000000Z
handler_name : VideoHandle
vendor_id : [0][0][0][0]
Stream #0:1[0x2](eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 96 kb/s (default)
Metadata:
creation_time : 2022-02-03T17:30:18.000000Z
handler_name : SoundHandle
vendor_id : [0][0][0][0]
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_amf))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95e6a4c00] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95e6e8040] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95e72afc0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95e76df40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95e7aefc0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95e7f1f40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95e834ec0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95e875f40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95e8b8ec0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95e8f9f40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95e93cec0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95e97fe40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95e9c0ec0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95ea03e40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95ea46dc0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95ea87e40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55b95e696840] [swscaler @ 0x55b95eacadc0] deprecated pixel format used, make sure you did set range correctly
[h264_amf @ 0x55b95c9279c0] DLL libamfrt64.so.1 failed to open
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
[aac @ 0x55b95c9543c0] Qavg: 13289.050
[aac @ 0x55b95c9543c0] 2 frames left in the queue on closing
Conversion failed!
stulluk ~/Videos $
Searching internet, I found this: https://wiki.archlinux.org/title/FFmpeg#AMD_AMF
And on my host, here is amdgpu-pro related files:
stulluk ~/Videos $ tree /opt/amdgpu-pro/
/opt/amdgpu-pro/
├── bin
│ └── clinfo
├── etc
│ └── vulkan
│ └── icd.d
│ ├── amd_icd32.json
│ └── amd_icd64.json
└── lib
├── i386-linux-gnu
│ ├── amdvlk32.so -> amdvlk32.so.1.0
│ └── amdvlk32.so.1.0
└── x86_64-linux-gnu
├── amdvlk64.so -> amdvlk64.so.1.0
├── amdvlk64.so.1.0
├── libamdocl-orca64.so
├── libamfrt64.so -> libamfrt64.so.1
├── libamfrt64.so.1 -> libamfrt64.so.1.4.23
├── libamfrt64.so.1.4.23
├── libOpenCL.so.1 -> libOpenCL.so.1.2
└── libOpenCL.so.1.2
7 directories, 13 files
stulluk ~/Videos $
So how can I let the docker container to use this libamfrt64.so.1 ? Via some kind of bind mounting ?
Or, is there a better way to do this?