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 ...
Check which pixel formats are supported:
ffmpeg -pix_fmts
returns
Pixel formats: I.... = Supported Input format for conversion .O... = Supported Output format for conversion ..H.. = Hardware accelerated format ...P. = Paletted format ....B = Bitstream format FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL BIT_DEPTHS ----- IO... yuv420p 3 12 8-8-8 IO... yuyv422 3 16 8-8-8 ... ... IO... nv12 3 12 8-8-8 IO... p010le 3 15 10-10-10
NOTE: When using a different pixel format, usually the following options will need to be set:
Format | Chroma sampling | Packed or planar | Bits per channel |
---|---|---|---|
NV12 | 4:2:0 | Planar | 8 |
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"
Format | Chroma sampling | Packed or planar | Bits per channel |
---|---|---|---|
P010 | 4:2:0 | Planar | 10 |
ffmpeg -i "input.mkv" -vaapi_device /dev/dri/renderD128 -vf 'format=p010,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 main10 -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=p010,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 main10 -c:v hevc_vaapi -c:a copy -c:s copy -rc_mode CQP -global_quality 25 -v verbose "output.mkv"
Format | Chroma sampling | Packed or planar | Bits per channel |
---|---|---|---|
P010 | 4:2:0 | Planar | 16 |
ffmpeg -i "input.mkv" -vaapi_device /dev/dri/renderD128 -vf 'format=p016,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 rext -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=p016,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 rext -c:v hevc_vaapi -c:a copy -c:s copy -rc_mode CQP -global_quality 25 -v verbose "output.mkv"