23 #undef HAVE_AV_CONFIG_H
30 printf(
"Convert a libavfilter graph to a dot file\n");
31 printf(
"Usage: graph2dot [OPTIONS]\n");
34 "-i INFILE set INFILE as input file, stdin if omitted\n"
35 "-o OUTFILE set OUTFILE as output file, stdout if omitted\n"
36 "-h print this help\n");
48 fprintf(outfile,
"digraph G {\n");
49 fprintf(outfile,
"node [shape=box]\n");
50 fprintf(outfile,
"rankdir=LR\n");
53 char filter_ctx_label[128];
56 snprintf(filter_ctx_label,
sizeof(filter_ctx_label),
"%s (%s)",
63 char dst_filter_ctx_label[128];
66 snprintf(dst_filter_ctx_label,
sizeof(dst_filter_ctx_label),
"%s (%s)",
70 fprintf(outfile,
"\"%s\" -> \"%s\"", filter_ctx_label, dst_filter_ctx_label);
72 fprintf(outfile,
" [ label= \"fmt:%s w:%d h:%d tb:%d/%d\" ]",
78 fprintf(outfile,
" [ label= \"fmt:%s sr:%"PRId64
" cl:%s\" ]",
89 int main(
int argc,
char **argv)
91 const char *outfilename =
NULL;
92 const char *infilename =
NULL;
95 char *graph_string =
NULL;
101 while ((c = getopt(argc, argv,
"hi:o:")) != -1) {
110 outfilename = optarg;
117 if (!infilename || !strcmp(infilename,
"-"))
118 infilename =
"/dev/stdin";
119 infile = fopen(infilename,
"r");
121 fprintf(stderr,
"Impossible to open input file '%s': %s\n", infilename, strerror(errno));
125 if (!outfilename || !strcmp(outfilename,
"-"))
126 outfilename =
"/dev/stdout";
127 outfile = fopen(outfilename,
"w");
129 fprintf(stderr,
"Impossible to open output file '%s': %s\n", outfilename, strerror(errno));
135 unsigned int count = 0;
136 struct line *
line, *last_line, *first_line;
138 last_line = first_line =
av_malloc(
sizeof(
struct line));
140 while (fgets(last_line->
data,
sizeof(last_line->
data), infile)) {
141 struct line *new_line =
av_malloc(
sizeof(
struct line));
142 count += strlen(last_line->
data);
143 last_line->
next = new_line;
144 last_line = new_line;
150 for (line = first_line; line->
next; line = line->
next) {
151 unsigned int l = strlen(line->
data);
152 memcpy(p, line->
data, l);
161 fprintf(stderr,
"Impossible to parse the graph description\n");
AVFilterContext ** filters
void * av_mallocz(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.
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)
audio conversion routines
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.
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)
const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB]
The array of all the pixel format descriptors.
int w
agreed upon image width
unsigned output_count
number of output pads
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
int64_t sample_rate
samples per second
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
const char * name
filter name
AVFilterLink ** outputs
array of pointers to output links
enum AVMediaType type
filter media type
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
uint64_t channel_layout
channel layout of current buffer (see libavutil/audioconvert.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_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.