diff options
author | Zhengxu <zhengxu.maxwell@gmail.com> | 2017-01-05 14:48:06 +0800 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2017-01-11 20:21:09 +0000 |
commit | 1a79b8f8d2b5d26c60c237d6e585873238e46914 (patch) | |
tree | 59a1daa4903c2684326db6f0f226bd232fdad44c /ffmpeg_qsv.c | |
parent | f55da2200dbf98311969e0f345edbc82177d4836 (diff) | |
download | ffmpeg-1a79b8f8d2b5d26c60c237d6e585873238e46914.tar.gz |
ffmpeg: Add an option "qsv_device" to choose proper node for QSV child device (vaapi or dxva2)
Reason: For some cases, such as 2 or more graphics cards existing, the
default command line may fail because ffmpeg does not open the correct
device node:
ffmpeg -hwaccel qsv -c:v h264_qsv -i test.264 -c:v h264_qsv out.264
Let user choose the proper one by running like below:
ffmpeg -hwaccel qsv -qsv_device /dev/dri/renderD128 -c:v h264_qsv \
-i test.264 -c:v h264_qsv out.264
Signed-off-by: ChaoX A Liu <chaox.a.liu@gmail.com>
Signed-off-by: Huang, Zhengxu <zhengxu.maxwell@gmail.com>
Signed-off-by: Andrew, Zhang <huazh407@gmail.com>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
Diffstat (limited to 'ffmpeg_qsv.c')
-rw-r--r-- | ffmpeg_qsv.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/ffmpeg_qsv.c b/ffmpeg_qsv.c index 68ff5bd5dc..86824b60f2 100644 --- a/ffmpeg_qsv.c +++ b/ffmpeg_qsv.c @@ -28,6 +28,8 @@ #include "ffmpeg.h" +char *qsv_device = NULL; + static int qsv_get_buffer(AVCodecContext *s, AVFrame *frame, int flags) { InputStream *ist = s->opaque; @@ -44,15 +46,26 @@ static void qsv_uninit(AVCodecContext *s) static int qsv_device_init(InputStream *ist) { int err; + AVDictionary *dict = NULL; + + if (qsv_device) { + err = av_dict_set(&dict, "child_device", qsv_device, 0); + if (err < 0) + return err; + } err = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_QSV, - ist->hwaccel_device, NULL, 0); + ist->hwaccel_device, dict, 0); if (err < 0) { av_log(NULL, AV_LOG_ERROR, "Error creating a QSV device\n"); - return err; + goto err_out; } - return 0; +err_out: + if (dict) + av_dict_free(&dict); + + return err; } int qsv_init(AVCodecContext *s) |