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 (%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\"",
81 filter_ctx_label, dst_filter_ctx_label);
85 " [ label= \"fmt:%s w:%d h:%d tb:%d/%d\" ]",
93 " [ label= \"fmt:%s sr:%d cl:%s\" ]",
97 fprintf(outfile,
";\n");
101 fprintf(outfile,
"}\n");
104 int main(
int argc,
char **argv)
106 const char *outfilename =
NULL;
107 const char *infilename =
NULL;
110 char *graph_string =
NULL;
116 while ((c =
getopt(argc, argv,
"hi:o:")) != -1) {
132 if (!infilename || !strcmp(infilename,
"-"))
133 infilename =
"/dev/stdin";
134 infile = fopen(infilename,
"r");
136 fprintf(stderr,
"Impossible to open input file '%s': %s\n",
137 infilename, strerror(errno));
141 if (!outfilename || !strcmp(outfilename,
"-"))
142 outfilename =
"/dev/stdout";
143 outfile = fopen(outfilename,
"w");
145 fprintf(stderr,
"Impossible to open output file '%s': %s\n",
146 outfilename, strerror(errno));
152 unsigned int count = 0;
153 struct line *
line, *last_line, *first_line;
155 last_line = first_line =
av_malloc(
sizeof(
struct line));
157 while (fgets(last_line->
data,
sizeof(last_line->
data), infile)) {
158 struct line *new_line =
av_malloc(
sizeof(
struct line));
159 count += strlen(last_line->
data);
160 last_line->
next = new_line;
161 last_line = new_line;
167 for (line = first_line; line->
next; line = line->
next) {
168 unsigned int l = strlen(line->
data);
169 memcpy(p, line->
data, l);
178 fprintf(stderr,
"Impossible to parse the graph description\n");
AVFilterContext ** filters
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
void avfilter_register_all(void)
Initialize the filter system.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
memory handling functions
int h
agreed upon image height
char * name
name of this filter instance
static void print_digraph(FILE *outfile, AVFilterGraph *graph)
int main(int argc, char **argv)
A link between two filters.
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
int sample_rate
samples per second
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
void av_log_set_level(int level)
int w
agreed upon image width
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
int format
agreed upon media format
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static int getopt(int argc, char *argv[], char *opts)
const char * name
filter name
AVFilterLink ** outputs
array of pointers to output links
enum AVMediaType type
filter media type
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVFilterContext * dst
dest filter
AVFilter * filter
the AVFilter of which this is an instance
int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut *inputs, AVFilterInOut *outputs, void *log_ctx)
Add a graph described by a string to a graph.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.