@@ -973,8 +973,20 @@ 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}.
-@item dumpgraph
-Dump graph to stderr.
+@item dumpgraph @var{filename}
+Set the filename of filtergraph for dump.
+
+It is "ASCII" format by default. for Graphviz DOT output format,
+you can convert it to png by GraphViz tool:
+@example
+dot -Tpng dump_fg_filename -o dump_graph.png
+@end example
+
+@item dumpgraph_format @var{format}
+Set the output format of filtergraph for dump. Support format: "DOT", "ASCII".
+
+DOT is the text file format of the suite GraphViz, ASCII is the text file format
+of ASCII style.
@end table
@@ -47,7 +47,8 @@ typedef struct {
AVClass *class; ///< class for private options
char *graph_str;
char *graph_filename;
- char *dump_graph;
+ char *dump_fg_filename;
+ char *dump_fg_format;
AVFilterGraph *graph;
AVFilterContext **sinks;
int *sink_stream_map;
@@ -300,11 +301,16 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
if ((ret = avfilter_graph_config(lavfi->graph, avctx)) < 0)
goto end;
- if (lavfi->dump_graph) {
- char *dump = avfilter_graph_dump(lavfi->graph, lavfi->dump_graph);
+ if (lavfi->dump_fg_filename) {
+ char *dump = avfilter_graph_dump(lavfi->graph, lavfi->dump_fg_format);
+ FILE *fg_file = fopen(lavfi->dump_fg_filename, "w");
+
+ if (!fg_file)
+ FAIL(AVERROR(ENOMEM));
if (dump != NULL) {
- fputs(dump, stderr);
- fflush(stderr);
+ fputs(dump, fg_file);
+ fflush(fg_file);
+ fclose(fg_file);
av_free(dump);
} else {
FAIL(AVERROR(ENOMEM));
@@ -493,7 +499,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", "set dump graph filename", OFFSET(dump_fg_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
+ { "dumpgraph_format", "set dump graph format, DOT or ASCII", OFFSET(dump_fg_format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
{ NULL },
};