ffmpeg:hardware_acceleration_using_gpu:amd_gpu
This is an old revision of the document!
Table of Contents
ffmpeg - Hardware transcoding using GPUs - AMD GPU
ffmpeg -i "input.mkv" -vaapi_device /dev/dri/renderD128 -vcodec hevc_vaapi -vf format='nv12|vaapi,hwupload' -map 0 -c:a copy -c:s copy -qp 23 "output.mkv"
NOTE:
- -vaapi_device /dev/dri/renderD128, which is a shortcut to -init_hw_device vaapi=vaapi0:/dev/dri/renderD128 -filter_hw_device vaapi0, initializes a new hardware device of type vaapi.
- -vf 'format=nv12,hwupload' creates the filtergraph and uses it to filter the stream.
- The encoders only accept input as VAAPI surfaces.
- If the input is in normal memory, it will need to be uploaded before giving the frames to the encoder; in the ffmpeg utility, the hwupload filter can be used for this.
- It will upload to a surface with the same layout as the software frame, so it may be necessary to add a format filter immediately before to get the input into the right format (hardware generally wants the nv12 layout).
- The hwupload filter also requires a device to upload to, which needs to be defined before the filter graph is created, which is done with -vaapi_device.
AMD GPUs
h264_amf hevc_amf
Decoding
-hwaccel d3d11va
Encoding
For video resolution <= 4K
-c:v libx264 or -c:v h264_amf
For video resolution > 4K
-c:v libx265 or -c:v hevc_amf
Examples
#1 - A corrupt 1920×1080 video:
ffmpeg -y -vsync 0 -i "input.mp4" -c:a copy -c:v h264_amf -pix_fmt yuv420p "output.mp4"
#2 - a 7680×3840 H.265 video with incompatible profile for VHT - a stutter playback 7260×3630 60fps 10bit video
ffmpeg -y -vsync 0 -i "input.mp4" -c:a copy -c:v hevc_amf -pix_fmt yuv420p "output.mp4"
#3 - a 7680×7680 video not hardware decoded because is H.264 encoded
ffmpeg -y -vsync 0 -i "input.mp4" -c:a copy -c:v hevc_amf -pix_fmt yuv420p "output.mp4"
ffmpeg/hardware_acceleration_using_gpu/amd_gpu.1708341814.txt.gz · Last modified: 2024/02/19 11:23 by peter