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)",
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,
"Failed 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,
"Failed to open output file '%s': %s\n",
150 outfilename, strerror(errno));
157 struct line *
line, *last_line, *first_line;
159 last_line = first_line =
av_malloc(
sizeof(
struct line));
161 fprintf(stderr,
"Memory allocation failure\n");
165 while (fgets(last_line->
data,
sizeof(last_line->
data), infile)) {
166 struct line *new_line =
av_malloc(
sizeof(
struct line));
168 fprintf(stderr,
"Memory allocation failure\n");
171 count += strlen(last_line->
data);
172 last_line->
next = new_line;
173 last_line = new_line;
179 fprintf(stderr,
"Memory allocation failure\n");
183 for (line = first_line; line->
next; line = line->
next) {
184 size_t l = strlen(line->
data);
185 memcpy(p, line->
data, l);
194 fprintf(stderr,
"Failed to parse the graph description\n");
AVFilterContext ** filters
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
ptrdiff_t const GLvoid * data
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
AVFilterPad * dstpad
input pad on the dest filter
const char * name
Pad name.
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...
static FilteringContext * filter_ctx
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
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.
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
AVFilterPad * srcpad
output pad on the source 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