ffmpeg -i "input.mkv" -vaapi_device /dev/dri/renderD128 -vf 'format=nv12,hwupload,scale_vaapi=w=1920:h=1080' -map 0:v -metadata:s:v:0 language=eng -map 0:a -metadata:s:a:0 language=eng -map 0:s? -metadata:s:s:0 language=eng -profile:v main -c:v hevc_vaapi -c:a copy -c:s copy -rc_mode CQP -global_quality 25 -v verbose "output.mkv" ffmpeg -i "input.mkv" -vaapi_device /dev/dri/renderD128 -vf 'format=nv12,hwupload,scale_vaapi=w=1920:h=1080' -map 0:v -metadata:s:v:0 language=eng -map 0:a:m:language:eng? -metadata:s:a:0 language=eng -map 0:s? -metadata:s:s:0 language=eng -profile:v main -c:v hevc_vaapi -c:a copy -c:s copy -rc_mode CQP -global_quality 25 -v verbose "output.mkv"
ffmpeg -i "input.mkv" \ -vaapi_device /dev/dri/renderD128 \ -vf 'format=nv12,hwupload,scale_vaapi=w=1920:h=1080' \ -map 0:v -metadata:s:v:0 language=eng \ -map 0:a -metadata:s:a:0 language=eng \ -map 0:s? -metadata:s:s:0 language=eng \ -c:v hevc_vaapi \ -c:a copy \ -c:s copy \ -rc_mode CQP \ -global_quality 25 \ -profile:v main \ -v verbose \ "output.mkv"
NOTE:
Instead of using the H.265 codec, optionally select any other code that the GPU supports.
To figure out for which codecs the GPU supports, run the following command:
vainfo
This returns something like this:
VAProfileH264ConstrainedBaseline: VAEntrypointVLD VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice VAProfileH264Main : VAEntrypointVLD VAProfileH264Main : VAEntrypointEncSlice VAProfileH264High : VAEntrypointVLD VAProfileH264High : VAEntrypointEncSlice VAProfileHEVCMain : VAEntrypointVLD VAProfileHEVCMain : VAEntrypointEncSlice VAProfileHEVCMain10 : VAEntrypointVLD VAProfileHEVCMain10 : VAEntrypointEncSlice VAProfileJPEGBaseline : VAEntrypointVLD VAProfileVP9Profile0 : VAEntrypointVLD VAProfileVP9Profile2 : VAEntrypointVLD VAProfileAV1Profile0 : VAEntrypointVLD VAProfileAV1Profile0 : VAEntrypointEncSlice VAProfileNone : VAEntrypointVideoProc
For all entries with a value of VAEntrypointEncSlice hardware encoding is supported and can be used.
Run the following to see all possible modes:
ffmpeg -h encoder=hevc_vaapi
This returns all H.265 VAAPI options. These are the available rate control modes:
... -rc_mode <int> E..V....... Set rate control mode (from 0 to 6) (default auto) auto 0 E..V....... Choose mode automatically based on other parameters CQP 1 E..V....... Constant-quality CBR 2 E..V....... Constant-bitrate VBR 3 E..V....... Variable-bitrate ICQ 4 E..V....... Intelligent constant-quality QVBR 5 E..V....... Quality-defined variable-bitrate AVBR 6 E..V....... Average variable-bitrate ...