diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-07-16 12:38:24 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-08-30 11:53:50 +0200 |
commit | 3c397a1d4624dc96651696a7b6d6d5a972665fd2 (patch) | |
tree | f2e2ce0490fd0508a83fe46052c180a788a09645 /fftools/ffmpeg_filter.c | |
parent | bff48e8d693d4cf8fc3828937fbd9be8c1881b1d (diff) | |
download | ffmpeg-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.c | 24 |
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); |