aboutsummaryrefslogtreecommitdiffstats
path: root/ffmpeg_opt.c
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-03-04 23:57:38 +0000
committerMark Thompson <sw@jkqxz.net>2017-06-14 22:27:07 +0100
commit7ce47090ce36fbe72f807d1e35fea3a699adad17 (patch)
tree0c68525328b3904307c35e09b1533d40825edb18 /ffmpeg_opt.c
parent38820631746f86a2252c71ed4a588eb679dd9f40 (diff)
downloadffmpeg-7ce47090ce36fbe72f807d1e35fea3a699adad17.tar.gz
ffmpeg: Support setting the hardware device to use when filtering
This only supports one device globally, but more can be used by passing them with input streams in hw_frames_ctx or by deriving new devices inside a filter graph with hwmap. (cherry picked from commit e669db76108de8d7a36c2274c99da82cc94d1dd1)
Diffstat (limited to 'ffmpeg_opt.c')
-rw-r--r--ffmpeg_opt.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index be9c6fb6ac..bb6001f534 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -98,6 +98,7 @@ const HWAccel hwaccels[] = {
};
int hwaccel_lax_profile_check = 0;
AVBufferRef *hw_device_ctx;
+HWDevice *filter_hw_device;
char *vstats_filename;
char *sdp_filename;
@@ -495,6 +496,20 @@ static int opt_init_hw_device(void *optctx, const char *opt, const char *arg)
}
}
+static int opt_filter_hw_device(void *optctx, const char *opt, const char *arg)
+{
+ if (filter_hw_device) {
+ av_log(NULL, AV_LOG_ERROR, "Only one filter device can be used.\n");
+ return AVERROR(EINVAL);
+ }
+ filter_hw_device = hw_device_get_by_name(arg);
+ if (!filter_hw_device) {
+ av_log(NULL, AV_LOG_ERROR, "Invalid filter device %s.\n", arg);
+ return AVERROR(EINVAL);
+ }
+ return 0;
+}
+
/**
* Parse a metadata specifier passed as 'arg' parameter.
* @param arg metadata string to parse
@@ -3708,6 +3723,8 @@ const OptionDef options[] = {
{ "init_hw_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_init_hw_device },
"initialise hardware device", "args" },
+ { "filter_hw_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_hw_device },
+ "set hardware device used when filtering", "device" },
{ NULL, },
};