* [FFmpeg-devel] [PATCH 2/2] fftools/ffplay_renderer: Add device selection support
[not found] <20240109154101.316950-1-quinkblack@foxmail.com>
@ 2024-01-09 15:41 ` Zhao Zhili
0 siblings, 0 replies; only message in thread
From: Zhao Zhili @ 2024-01-09 15:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
The device can be selected by GPU name or index. For example,
ffplay -hwaccel cuda \
-vulkan_params device="NVIDIA GeForce RTX 3060" \
foo.mp4
ffplay -hwaccel cuda -vulkan_params device="0" foo.mp4
Please note that select device by index only supported by hwcontext,
not by libplacebo.
---
fftools/ffplay_renderer.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/fftools/ffplay_renderer.c b/fftools/ffplay_renderer.c
index 4e9e33b675..e1c2f07896 100644
--- a/fftools/ffplay_renderer.c
+++ b/fftools/ffplay_renderer.c
@@ -209,6 +209,16 @@ static int add_device_extension(const AVDictionary *opt,
return av_dict_set(dict, dev_ext_key, ext_list, AV_DICT_DONT_STRDUP_VAL);
}
+static const char *select_device(const AVDictionary *opt)
+{
+ const AVDictionaryEntry *entry;
+
+ entry = av_dict_get(opt, "device", NULL, 0);
+ if (entry)
+ return entry->value;
+ return NULL;
+}
+
static int create_vk_by_hwcontext(VkRenderer *renderer,
const char **ext, unsigned num_ext,
const AVDictionary *opt)
@@ -229,7 +239,7 @@ static int create_vk_by_hwcontext(VkRenderer *renderer,
}
ret = av_hwdevice_ctx_create(&ctx->hw_device_ref, AV_HWDEVICE_TYPE_VULKAN,
- NULL, dict, 0);
+ select_device(opt), dict, 0);
av_dict_free(&dict);
if (ret < 0)
return ret;
@@ -367,6 +377,7 @@ static int create_vk_by_placebo(VkRenderer *renderer,
.opt_extensions = optional_device_exts,
.num_opt_extensions = FF_ARRAY_ELEMS(optional_device_exts),
.extra_queues = VK_QUEUE_VIDEO_DECODE_BIT_KHR,
+ .device_name = select_device(opt),
));
if (!ctx->placebo_vulkan)
return AVERROR_EXTERNAL;
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-09 7:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20240109154101.316950-1-quinkblack@foxmail.com>
2024-01-09 15:41 ` [FFmpeg-devel] [PATCH 2/2] fftools/ffplay_renderer: Add device selection support Zhao Zhili
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git