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 12:22] – 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> | <code bash> | ||
+ | ffmpeg -hwaccel vaapi -hwaccel_device / | ||
+ | |||
+ | |||
ffmpeg -i " | ffmpeg -i " | ||
</ | </ | ||
- | |||
- | <WRAP info> | ||
- | **NOTE:** | ||
- | |||
- | * **-vaapi_device / | ||
- | |||
- | * **-vcodec hevc_vaapi** | ||
- | |||
- | * **-vf ' | ||
- | * 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**. | ||
- | |||
- | * **-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. | ||
- | |||
- | </ | ||
---- | ---- | ||
- | <WRAP info> | + | ===== Step-by-step guide to the above mentioned method ===== |
- | **NOTE: | + | |
+ | ==== Determine | ||
<code bash> | <code bash> | ||
Line 67: | Line 50: | ||
</ | </ | ||
- | | + | <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> | ||
+ | ffmpeg -i " | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE:** | ||
+ | |||
+ | * **-vaapi_device / | ||
+ | |||
+ | * **-vcodec hevc_vaapi** | ||
+ | |||
+ | * **-vf ' | ||
+ | * 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**. | ||
+ | |||
+ | * **-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 146: | Line 221: | ||
===== References ===== | ===== References ===== | ||
- | https:// | + | * [[https:// |
ffmpeg/hardware_acceleration_using_gpu/amd_gpu.1708345359.txt.gz · Last modified: 2024/02/19 12:22 by peter