[FFmpeg-devel] [PATCH] ffmpeg_qsv: use -hwaccel_device to specify a device for VAAPI backend

Haihao Xiang haihao.xiang at intel.com
Wed Sep 2 07:01:03 EEST 2020


According to the FFmpeg documentation, -hwaccel_device can be used to
select a device for hardware acceleration

Example:
ffmpeg -hwaccel qsv -hwaccel_device /dev/dri/renderD129 -c:v h264_qsv \
-i in.h264 -c:v hevc_qsv out.h265
---
 fftools/ffmpeg_qsv.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fftools/ffmpeg_qsv.c b/fftools/ffmpeg_qsv.c
index 960c88b69d..b7e7ab0e53 100644
--- a/fftools/ffmpeg_qsv.c
+++ b/fftools/ffmpeg_qsv.c
@@ -55,6 +55,14 @@ static int qsv_device_init(InputStream *ist)
             return err;
     }
 
+#if CONFIG_VAAPI
+    else if (ist->hwaccel_device && !strncmp(ist->hwaccel_device, "/dev/dri/", 9)) {
+        err = av_dict_set(&dict, "child_device", ist->hwaccel_device, 0);
+        if (err < 0)
+            return err;
+    }
+#endif
+
     err = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_QSV,
                                  ist->hwaccel_device, dict, 0);
     if (err < 0) {
-- 
2.25.1



More information about the ffmpeg-devel mailing list