aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_filter.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-07-16 12:38:24 +0200
committerAnton Khirnov <anton@khirnov.net>2023-08-30 11:53:50 +0200
commit3c397a1d4624dc96651696a7b6d6d5a972665fd2 (patch)
treef2e2ce0490fd0508a83fe46052c180a788a09645 /fftools/ffmpeg_filter.c
parentbff48e8d693d4cf8fc3828937fbd9be8c1881b1d (diff)
downloadffmpeg-3c397a1d4624dc96651696a7b6d6d5a972665fd2.tar.gz
fftools/ffmpeg: move sending filtergraph commands to a separate function
Stop accessing filtergraph internals from keyboard reading code.
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r--fftools/ffmpeg_filter.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 283ba44c2b..9bf870b615 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1741,6 +1741,30 @@ int filtergraph_is_simple(const FilterGraph *fg)
return fgp->is_simple;
}
+void fg_send_command(FilterGraph *fg, double time, const char *target,
+ const char *command, const char *arg, int all_filters)
+{
+ int ret;
+
+ if (!fg->graph)
+ return;
+
+ if (time < 0) {
+ char response[4096];
+ ret = avfilter_graph_send_command(fg->graph, target, command, arg,
+ response, sizeof(response),
+ all_filters ? 0 : AVFILTER_CMD_FLAG_ONE);
+ fprintf(stderr, "Command reply for stream %d: ret:%d res:\n%s",
+ fg->index, ret, response);
+ } else if (!all_filters) {
+ fprintf(stderr, "Queuing commands only on filters supporting the specific command is unsupported\n");
+ } else {
+ ret = avfilter_graph_queue_command(fg->graph, target, command, arg, 0, time);
+ if (ret < 0)
+ fprintf(stderr, "Queuing command failed with error %s\n", av_err2str(ret));
+ }
+}
+
static int fg_output_step(OutputFilterPriv *ofp, int flush)
{
FilterGraphPriv *fgp = fgp_from_fg(ofp->ofilter.graph);