40 printf(
"Convert a libavfilter graph to a dot file.\n");
41 printf(
"Usage: graph2dot [OPTIONS]\n");
44 "-i INFILE set INFILE as input file, stdin if omitted\n" 45 "-o OUTFILE set OUTFILE as output file, stdout if omitted\n" 46 "-h print this help\n");
58 fprintf(outfile,
"digraph G {\n");
59 fprintf(outfile,
"node [shape=box]\n");
60 fprintf(outfile,
"rankdir=LR\n");
63 char filter_ctx_label[128];
66 snprintf(filter_ctx_label,
sizeof(filter_ctx_label),
"%s (%s)",
73 char dst_filter_ctx_label[128];
76 snprintf(dst_filter_ctx_label,
sizeof(dst_filter_ctx_label),
81 fprintf(outfile,
"\"%s\" -> \"%s\"",
82 filter_ctx_label, dst_filter_ctx_label);
86 " [ label= \"fmt:%s w:%d h:%d tb:%d/%d\" ]",
94 " [ label= \"fmt:%s sr:%d cl:%s\" ]",
98 fprintf(outfile,
";\n");
102 fprintf(outfile,
"}\n");
105 int main(
int argc,
char **argv)
107 const char *outfilename =
NULL;
108 const char *infilename =
NULL;
111 char *graph_string =
NULL;
117 while ((c =
getopt(argc, argv,
"hi:o:")) != -1) {
133 if (!infilename || !strcmp(infilename,
"-"))
134 infilename =
"/dev/stdin";
135 infile = fopen(infilename,
"r");
137 fprintf(stderr,
"Failed to open input file '%s': %s\n",
138 infilename, strerror(errno));
142 if (!outfilename || !strcmp(outfilename,
"-"))
143 outfilename =
"/dev/stdout";
144 outfile = fopen(outfilename,
"w");
146 fprintf(stderr,
"Failed to open output file '%s': %s\n",
147 outfilename, strerror(errno));
153 unsigned int count = 0;
154 struct line *
line, *last_line, *first_line;
156 last_line = first_line =
av_malloc(
sizeof(
struct line));
158 while (fgets(last_line->
data,
sizeof(last_line->
data), infile)) {
159 struct line *new_line =
av_malloc(
sizeof(
struct line));
160 count += strlen(last_line->
data);
161 last_line->
next = new_line;
162 last_line = new_line;
168 for (line = first_line; line->
next; line = line->
next) {
169 unsigned int l = strlen(line->
data);
170 memcpy(p, line->
data, l);
179 fprintf(stderr,
"Failed 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 ...
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Main libavfilter public API header.
memory handling functions
void av_log_set_level(int level)
Set the log level.
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
int h
agreed upon image height
char * name
name of this filter instance
static void print_digraph(FILE *outfile, AVFilterGraph *graph)
void avfilter_register_all(void)
Initialize the filter system.
int main(int argc, char **argv)
A link between two filters.
int sample_rate
samples per second
unsigned nb_outputs
number of output pads
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
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 w
agreed upon image width
audio channel layout utility functions
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)
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.
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
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
const AVFilter * filter
the AVFilter of which this is an instance
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.