[FFmpeg-devel] [PATCH v7 3/3] fftools: add options to dump filter graph
lance.lmwang at gmail.com
lance.lmwang at gmail.com
Mon May 25 02:50:26 EEST 2020
From: Limin Wang <lance.lmwang at gmail.com>
Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
doc/ffmpeg.texi | 12 ++++++++++++
fftools/ffmpeg.c | 1 +
fftools/ffmpeg.h | 1 +
fftools/ffmpeg_filter.c | 11 +++++++++++
fftools/ffmpeg_opt.c | 10 ++++++++++
5 files changed, 35 insertions(+)
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index ed437bb..c7dd73b 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -735,6 +735,18 @@ Technical note -- attachments are implemented as codec extradata, so this
option can actually be used to extract extradata from any stream, not just
attachments.
+ at item dump_filtergraph @var{options} (@emph{global})
+Dump graph to stderr with more options
+
+options is a ':'-separated list of @var{key=value} pairs.
+
+Set the graph with graphviz DOT format by @var{fmt=dot|DOT},
+set the filename of filtergraph to output by @var{filename=path}.
+
+ at example
+ffmpeg -dump_filtergraph fmt=dot:filename=./test.tmp -i INPUT
+ at end example
+
@item -noautorotate
Disable automatically rotating video based on file metadata.
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index f697460..2c611a7 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -625,6 +625,7 @@ static void ffmpeg_cleanup(int ret)
av_err2str(AVERROR(errno)));
}
av_freep(&vstats_filename);
+ av_freep(&dump_filtergraph);
av_freep(&input_streams);
av_freep(&input_files);
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 38205a1..000c682 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -578,6 +578,7 @@ extern int nb_filtergraphs;
extern char *vstats_filename;
extern char *sdp_filename;
+extern char *dump_filtergraph;
extern float audio_drift_threshold;
extern float dts_delta_threshold;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 8b5b157..c5adfae 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1106,6 +1106,17 @@ int configure_filtergraph(FilterGraph *fg)
if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
goto fail;
+ if (dump_filtergraph) {
+ char *dump = avfilter_graph_dump(fg->graph, dump_filtergraph);
+ if (!dump) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+ fputs(dump, stderr);
+ fflush(stderr);
+ av_free(dump);
+ }
+
/* limit the lists of allowed formats to the ones selected, to
* make sure they stay the same if the filtergraph is reconfigured later */
for (i = 0; i < fg->nb_outputs; i++) {
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 60bb437..e4ebc88 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -143,6 +143,7 @@ HWDevice *filter_hw_device;
char *vstats_filename;
char *sdp_filename;
+char *dump_filtergraph;
float audio_drift_threshold = 0.1;
float dts_delta_threshold = 10;
@@ -2914,6 +2915,13 @@ static int opt_vstats_file(void *optctx, const char *opt, const char *arg)
return 0;
}
+static int opt_dumpgraph(void *optctx, const char *opt, const char *arg)
+{
+ av_free (dump_filtergraph);
+ dump_filtergraph = av_strdup(arg);
+ return 0;
+}
+
static int opt_vstats(void *optctx, const char *opt, const char *arg)
{
char filename[40];
@@ -3548,6 +3556,8 @@ const OptionDef options[] = {
{ "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC |
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(dump_attachment) },
"extract an attachment into a file", "filename" },
+ { "dump_filtergraph",HAS_ARG | OPT_EXPERT, { .func_arg = opt_dumpgraph },
+ "dump filter graph to stderr with options"},
{ "stream_loop", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_INPUT |
OPT_OFFSET, { .off = OFFSET(loop) }, "set number of times input stream shall be looped", "loop count" },
{ "debug_ts", OPT_BOOL | OPT_EXPERT, { &debug_ts },
--
2.6.4
More information about the ffmpeg-devel
mailing list