60 "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n",
74 for (; *p != -1; p++) {
83 "Incompatible sample format '%s' for codec '%s', auto-selecting format '%s'\n",
136 #define DEF_CHOOSE_FORMAT(type, var, supported_list, none, get_name, separator)\
137 static char *choose_ ## var ## s(OutputStream *ost) \
139 if (ost->st->codec->var != none) { \
140 get_name(ost->st->codec->var); \
141 return av_strdup(name); \
142 } else if (ost->enc->supported_list) { \
144 AVIOContext *s = NULL; \
148 if (avio_open_dyn_buf(&s) < 0) \
151 for (p = ost->enc->supported_list; *p != none; p++) { \
153 avio_printf(s, "%s" separator, name); \
155 len = avio_close_dyn_buf(s, &ret); \
197 ist->filters[ist->nb_filters - 1] = fg->
inputs[0];
222 int file_idx = strtol(in->
name, &p, 0);
233 if (stream_type != type &&
255 if (i == nb_input_streams) {
257 "unlabeled input pad %d on filter %s\n", in->
pad_idx,
302 snprintf(args,
sizeof(args),
"%d:%d:flags=0x%X",
306 snprintf(name,
sizeof(name),
"scaler for output stream %d:%d",
311 if ((ret =
avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
320 snprintf(name,
sizeof(name),
"pixel format for output stream %d:%d",
324 "format", pix_fmts,
NULL,
327 if ((ret =
avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
341 snprintf(name,
sizeof(name),
"fps for output stream %d:%d",
367 char *
sample_fmts, *sample_rates, *channel_layouts;
379 #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \
380 AVFilterContext *filt_ctx; \
382 av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
383 "similarly to -af " filter_name "=%s.\n", arg); \
385 ret = avfilter_graph_create_filter(&filt_ctx, \
386 avfilter_get_by_name(filter_name), \
387 filter_name, arg, NULL, fg->graph); \
391 ret = avfilter_link(last_filter, pad_idx, filt_ctx, 0); \
395 last_filter = filt_ctx; \
415 sample_fmts = choose_sample_fmts(ost);
416 sample_rates = choose_sample_rates(ost);
417 channel_layouts = choose_channel_layouts(ost);
418 if (sample_fmts || sample_rates || channel_layouts) {
427 av_strlcatf(args,
sizeof(args),
"sample_rates=%s:",
430 av_strlcatf(args,
sizeof(args),
"channel_layouts=%s:",
437 snprintf(name,
sizeof(name),
"audio format for output stream %d:%d",
449 last_filter = format;
466 #define DESCRIBE_FILTER_LINK(f, inout, in) \
468 AVFilterContext *ctx = inout->filter_ctx; \
469 AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads; \
470 int nb_pads = in ? ctx->input_count : ctx->output_count; \
473 if (avio_open_dyn_buf(&pb) < 0) \
476 avio_printf(pb, "%s", ctx->filter->name); \
478 avio_printf(pb, ":%s", avfilter_pad_get_name(pads, inout->pad_idx));\
480 avio_close_dyn_buf(pb, &f->name); \
530 memset(image[0], 0, h * linesize[0]);
550 ist->
st->r_frame_rate;
579 "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:"
586 snprintf(name,
sizeof(name),
"graph %d input from stream %d:%d", fg->
index,
596 snprintf(name,
sizeof(name),
"force CFR for input from stream %d:%d",
604 if ((ret =
avfilter_link(setpts, 0, first_filter, pad_idx)) < 0)
607 first_filter = setpts;
623 char args[255],
name[255];
626 snprintf(args,
sizeof(args),
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s"
627 ":channel_layout=0x%"PRIx64,
632 snprintf(name,
sizeof(name),
"graph %d input from stream %d:%d", fg->
index,
640 #define AUTO_INSERT_FILTER_INPUT(opt_name, filter_name, arg) do { \
641 AVFilterContext *filt_ctx; \
643 av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
644 "similarly to -af " filter_name "=%s.\n", arg); \
646 snprintf(name, sizeof(name), "graph %d %s for input stream %d:%d", \
647 fg->index, filter_name, ist->file_index, ist->st->index); \
648 ret = avfilter_graph_create_filter(&filt_ctx, \
649 avfilter_get_by_name(filter_name), \
650 name, arg, NULL, fg->graph); \
654 ret = avfilter_link(filt_ctx, 0, first_filter, pad_idx); \
658 first_filter = filt_ctx; \
662 char args[256] = {0};
687 "audio filter instead.\n");
736 args[strlen(args)-1] = 0;
743 if (simple && (!inputs || inputs->
next || !outputs || outputs->
next)) {
745 "exactly one input and output.\n", graph_desc);
749 for (cur = inputs; !simple && init && cur; cur = cur->
next)
752 for (cur = inputs, i = 0; cur; cur = cur->
next, i++)
757 if (!init || simple) {
760 for (cur = outputs, i = 0; cur; cur = cur->
next, i++)
768 for (cur = outputs; cur;) {