ffmpeg:hardware_acceleration_using_gpu:amd_gpu
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ffmpeg:hardware_acceleration_using_gpu:amd_gpu [2024/02/19 11:23] – peter | ffmpeg:hardware_acceleration_using_gpu:amd_gpu [2024/05/15 00:03] (current) – peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== ffmpeg - Hardware transcoding using GPUs - AMD GPU ====== | ====== ffmpeg - Hardware transcoding using GPUs - AMD GPU ====== | ||
+ | |||
+ | ===== Basic method ===== | ||
+ | |||
+ | <code bash> | ||
+ | ffmpeg -hwaccel vaapi -hwaccel_device / | ||
+ | |||
+ | |||
+ | ffmpeg -i " | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Step-by-step guide to the above mentioned method ===== | ||
+ | |||
+ | ==== Determine which codecs can be used with GPU hardware video encoding acceleration ==== | ||
+ | |||
+ | <code bash> | ||
+ | vainfo | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | < | ||
+ | vainfo | ||
+ | libva info: VA-API version 1.16.0 | ||
+ | libva info: User environment variable requested driver ' | ||
+ | libva info: Trying to open / | ||
+ | libva info: Found init function __vaDriverInit_1_16 | ||
+ | libva info: va_openDriver() returns 0 | ||
+ | vainfo: VA-API version: 1.16 (libva 2.12.0) | ||
+ | vainfo: Driver version: Mesa Gallium driver 23.3.0-devel for Radeon RX 7900 XTX (navi31, LLVM 17.0.4, DRM 3.54, 6.5.0-15-generic) | ||
+ | vainfo: Supported profile and entrypoints | ||
+ | VAProfileH264ConstrainedBaseline: | ||
+ | VAProfileH264ConstrainedBaseline: | ||
+ | VAProfileH264Main | ||
+ | VAProfileH264Main | ||
+ | VAProfileH264High | ||
+ | VAProfileH264High | ||
+ | VAProfileHEVCMain | ||
+ | VAProfileHEVCMain | ||
+ | VAProfileHEVCMain10 | ||
+ | VAProfileHEVCMain10 | ||
+ | VAProfileJPEGBaseline | ||
+ | VAProfileVP9Profile0 | ||
+ | VAProfileVP9Profile2 | ||
+ | VAProfileAV1Profile0 | ||
+ | VAProfileAV1Profile0 | ||
+ | VAProfileNone | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | In this case this shows the following as able to hardware encode: < | ||
+ | VAProfileH264ConstrainedBaseline: | ||
+ | VAProfileH264Main | ||
+ | VAProfileH264High | ||
+ | VAProfileHEVCMain | ||
+ | VAProfileHEVCMain10 | ||
+ | VAProfileAV1Profile0 | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Check what vaapi encoders are supported by ffmpeg ==== | ||
+ | |||
+ | <code bash> | ||
+ | ffmpeg -encoders | grep vaapi | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | < | ||
+ | ffmpeg version N-113695-g32538dafca Copyright (c) 2000-2024 the FFmpeg developers | ||
+ | built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04) | ||
+ | configuration: | ||
+ | libavutil | ||
+ | libavcodec | ||
+ | libavformat | ||
+ | libavdevice | ||
+ | libavfilter | ||
+ | libswscale | ||
+ | libswresample | ||
+ | libpostproc | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | < | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ---- | ||
+ | |||
<code bash> | <code bash> | ||
Line 9: | Line 124: | ||
* **-vaapi_device / | * **-vaapi_device / | ||
+ | |||
+ | * **-vcodec hevc_vaapi** | ||
* **-vf ' | * **-vf ' | ||
Line 15: | Line 132: | ||
* 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). | * 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**. | * 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**. | ||
+ | |||
+ | * **-map 0 -c:a copy -c:s copy**: | ||
+ | * **-map 0:a -c:a copy**: This causes to copy the audio streams without modification to the new file. | ||
+ | |||
+ | * **-qp 23**: The video quality. | ||
+ | * The lower the value, the better will be the video quality, but also the files will be larger. | ||
+ | * The default value is 25 which is fairly good. | ||
+ | * For high-definition videos a value between 21-23 works best and produces good results. | ||
</ | </ | ||
Line 20: | Line 145: | ||
---- | ---- | ||
+ | |||
+ | |||
+ | ---- | ||
===== AMD GPUs ===== | ===== AMD GPUs ===== | ||
Line 91: | Line 219: | ||
---- | ---- | ||
+ | ===== References ===== | ||
+ | * [[https:// |
ffmpeg/hardware_acceleration_using_gpu/amd_gpu.1708341814.txt.gz · Last modified: 2024/02/19 11:23 by peter