39 printf(
"Convert a libavfilter graph to a dot file\n");
40 printf(
"Usage: graph2dot [OPTIONS]\n");
43 "-i INFILE set INFILE as input file, stdin if omitted\n"
44 "-o OUTFILE set OUTFILE as output file, stdout if omitted\n"
45 "-h print this help\n");
57 fprintf(outfile,
"digraph G {\n");
58 fprintf(outfile,
"node [shape=box]\n");
59 fprintf(outfile,
"rankdir=LR\n");
62 char filter_ctx_label[128];
65 snprintf(filter_ctx_label,
sizeof(filter_ctx_label),
"%s\\n(%s)",
69 for (j = 0; j < filter_ctx->output_count; j++) {
72 char dst_filter_ctx_label[128];
75 snprintf(dst_filter_ctx_label,
sizeof(dst_filter_ctx_label),
80 fprintf(outfile,
"\"%s\" -> \"%s\" [ label= \"inpad:%s -> outpad:%s\\n",
81 filter_ctx_label, dst_filter_ctx_label,
87 "fmt:%s w:%d h:%d tb:%d/%d",
96 "fmt:%s sr:%d cl:%s tb:%d/%d",
101 fprintf(outfile,
"\" ];\n");
105 fprintf(outfile,
"}\n");
108 int main(
int argc,
char **argv)
110 const char *outfilename =
NULL;
111 const char *infilename =
NULL;
114 char *graph_string =
NULL;
120 while ((c =
getopt(argc, argv,
"hi:o:")) != -1) {
136 if (!infilename || !strcmp(infilename,
"-"))
137 infilename =
"/dev/stdin";
138 infile = fopen(infilename,
"r");
140 fprintf(stderr,
"Impossible to open input file '%s': %s\n",
141 infilename, strerror(errno));
145 if (!outfilename || !strcmp(outfilename,
"-"))
146 outfilename =
"/dev/stdout";
147 outfile = fopen(outfilename,
"w");
149 fprintf(stderr,
"Impossible to open output file '%s': %s\n",
150 outfilename, strerror(errno));
156 unsigned int count = 0;
157 struct line *
line, *last_line, *first_line;
159 last_line = first_line =
av_malloc(
sizeof(
struct line));
161 while (fgets(last_line->
data,
sizeof(last_line->
data), infile)) {
162 struct line *new_line =
av_malloc(
sizeof(
struct line));
163 count += strlen(last_line->
data);
164 last_line->
next = new_line;
165 last_line = new_line;
171 for (line = first_line; line->
next; line = line->
next) {
172 unsigned int l = strlen(line->
data);
173 memcpy(p, line->
data, l);
182 fprintf(stderr,
"Impossible to parse the graph description\n");