[FFmpeg-devel] [PATCH v7 2/3] avdevice/lavfi: support the dumpgraph with options

lance.lmwang at gmail.com lance.lmwang at gmail.com
Mon May 25 02:50:25 EEST 2020


From: Limin Wang <lance.lmwang at gmail.com>

Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
 doc/indevs.texi     | 19 +++++++++++++++++--
 libavdevice/lavfi.c |  8 +++++---
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 6f5afaf..b4dffc4 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -973,8 +973,17 @@ Set the filename of the filtergraph to be read and sent to the other
 filters. Syntax of the filtergraph is the same as the one specified by
 the option @var{graph}.
 
- at item dumpgraph
-Dump graph to stderr.
+ at item dumpgraph (@emph{bool})
+Dump filter graph with ASCII style to stderr default.
+By default, it is disable.
+
+ at item dumpgraph_opts @var{options}
+Set the options of dump filter graph
+
+it 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}.
 
 @end table
 
@@ -988,6 +997,12 @@ ffplay -f lavfi -graph "color=c=pink [out0]" dummy
 @end example
 
 @item
+dump the filter graph with graphviz DOT output format to ./test.tmp
+ at example
+ffplay -dumpgraph 1 -dumpgraph_opts fmt=dot:filename=./test.tmp -f lavfi color=c=pink
+ at end example
+
+ at item
 As the previous example, but use filename for specifying the graph
 description, and omit the "out0" label:
 @example
diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index c949ff7..9cdfbaa 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -47,7 +47,7 @@ typedef struct {
     AVClass *class;          ///< class for private options
     char          *graph_str;
     char          *graph_filename;
-    char          *dump_graph;
+    char          *dump_graph_opts;
     AVFilterGraph *graph;
     AVFilterContext **sinks;
     int *sink_stream_map;
@@ -57,6 +57,7 @@ typedef struct {
     AVFrame *decoded_frame;
     int nb_sinks;
     AVPacket subcc_packet;
+    int dump_graph;
 } LavfiContext;
 
 static int *create_all_formats(int n)
@@ -301,7 +302,7 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
         goto end;
 
     if (lavfi->dump_graph) {
-        char *dump = avfilter_graph_dump(lavfi->graph, lavfi->dump_graph);
+        char *dump = avfilter_graph_dump(lavfi->graph, lavfi->dump_graph_opts);
         if (dump != NULL) {
             fputs(dump, stderr);
             fflush(stderr);
@@ -493,7 +494,8 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
 static const AVOption options[] = {
     { "graph",     "set libavfilter graph", OFFSET(graph_str),  AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
     { "graph_file","set libavfilter graph filename", OFFSET(graph_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC},
-    { "dumpgraph", "dump graph to stderr",  OFFSET(dump_graph), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
+    { "dumpgraph", "dump graph to stderr",  OFFSET(dump_graph), AV_OPT_TYPE_BOOL, {.str = 0}, 0, 1, DEC },
+    { "dumpgraph_opts", "set the options of dump graph",  OFFSET(dump_graph_opts), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
     { NULL },
 };
 
-- 
2.6.4



More information about the ffmpeg-devel mailing list