35 #include "libavfilter/avfilter.h"
36 #include "libavfilter/buffersink.h"
37 #include "libavfilter/buffersrc.h"
39 #include "libavutil/avassert.h"
40 #include "libavutil/avstring.h"
41 #include "libavutil/bprint.h"
42 #include "libavutil/channel_layout.h"
43 #include "libavutil/display.h"
44 #include "libavutil/opt.h"
45 #include "libavutil/pixdesc.h"
46 #include "libavutil/pixfmt.h"
47 #include "libavutil/imgutils.h"
48 #include "libavutil/samplefmt.h"
52 static const enum AVPixelFormat mjpeg_formats[] =
53 { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P,
54 AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P,
56 static const enum AVPixelFormat ljpeg_formats[] =
57 { AV_PIX_FMT_BGR24 , AV_PIX_FMT_BGRA , AV_PIX_FMT_BGR0,
58 AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P,
59 AV_PIX_FMT_YUV420P , AV_PIX_FMT_YUV444P , AV_PIX_FMT_YUV422P,
62 if (codec_id == AV_CODEC_ID_MJPEG) {
64 }
else if (codec_id == AV_CODEC_ID_LJPEG) {
67 return default_formats;
71 enum AVPixelFormat
choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx, AVCodec *codec,
enum AVPixelFormat target)
73 if (codec && codec->pix_fmts) {
74 const enum AVPixelFormat *p = codec->pix_fmts;
75 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(target);
77 int has_alpha = desc ? desc->nb_components % 2 == 0 : 0;
78 enum AVPixelFormat best= AV_PIX_FMT_NONE;
80 if (enc_ctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
83 for (; *p != AV_PIX_FMT_NONE; p++) {
84 best= avcodec_find_best_pix_fmt_of_2(best, *p, target, has_alpha, NULL);
88 if (*p == AV_PIX_FMT_NONE) {
89 if (target != AV_PIX_FMT_NONE)
90 av_log(NULL, AV_LOG_WARNING,
91 "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n",
92 av_get_pix_fmt_name(target),
94 av_get_pix_fmt_name(best));
103 if (codec && codec->sample_fmts) {
104 const enum AVSampleFormat *p = codec->sample_fmts;
105 for (; *p != -1; p++) {
106 if (*p == st->codecpar->format)
110 if((codec->capabilities & AV_CODEC_CAP_LOSSLESS) && av_get_sample_fmt_name(st->codecpar->format) > av_get_sample_fmt_name(codec->sample_fmts[0]))
111 av_log(NULL, AV_LOG_ERROR,
"Conversion will not be lossless.\n");
112 if(av_get_sample_fmt_name(st->codecpar->format))
113 av_log(NULL, AV_LOG_WARNING,
114 "Incompatible sample format '%s' for codec '%s', auto-selecting format '%s'\n",
115 av_get_sample_fmt_name(st->codecpar->format),
117 av_get_sample_fmt_name(codec->sample_fmts[0]));
118 st->codecpar->format = codec->sample_fmts[0];
126 AVDictionaryEntry *strict_dict = av_dict_get(ost->
encoder_opts,
"strict", NULL, 0);
129 av_opt_set(ost->
enc_ctx,
"strict", strict_dict->value, 0);
132 avfilter_graph_set_auto_convert(ofilter->
graph->
graph,
133 AVFILTER_AUTO_CONVERT_NONE);
134 if (ost->
enc_ctx->pix_fmt == AV_PIX_FMT_NONE)
136 return av_strdup(av_get_pix_fmt_name(ost->
enc_ctx->pix_fmt));
138 if (ost->
enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
140 }
else if (ost->
enc && ost->
enc->pix_fmts) {
141 const enum AVPixelFormat *p;
142 AVIOContext *s = NULL;
146 if (avio_open_dyn_buf(&s) < 0)
149 p = ost->
enc->pix_fmts;
150 if (ost->
enc_ctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
154 for (; *p != AV_PIX_FMT_NONE; p++) {
155 const char *name = av_get_pix_fmt_name(*p);
156 avio_printf(s,
"%s|", name);
158 len = avio_close_dyn_buf(s, &ret);
167 #define DEF_CHOOSE_FORMAT(suffix, type, var, supported_list, none, get_name) \
168 static char *choose_ ## suffix (OutputFilter *ofilter) \
170 if (ofilter->var != none) { \
171 get_name(ofilter->var); \
172 return av_strdup(name); \
173 } else if (ofilter->supported_list) { \
175 AVIOContext *s = NULL; \
179 if (avio_open_dyn_buf(&s) < 0) \
182 for (p = ofilter->supported_list; *p != none; p++) { \
184 avio_printf(s, "%s|", name); \
186 len = avio_close_dyn_buf(s, &ret); \
223 if (!(fg->
inputs[0] = av_mallocz(
sizeof(*fg->
inputs[0]))))
234 ist->filters[ist->nb_filters - 1] = fg->
inputs[0];
244 AVFilterContext *ctx = inout->filter_ctx;
245 AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads;
246 int nb_pads = in ? ctx->nb_inputs : ctx->nb_outputs;
250 if (avio_open_dyn_buf(&pb) < 0)
253 avio_printf(pb,
"%s", ctx->filter->name);
255 avio_printf(pb,
":%s", avfilter_pad_get_name(pads, inout->pad_idx));
257 avio_close_dyn_buf(pb, &res);
264 enum AVMediaType type = avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx);
268 if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) {
269 av_log(NULL, AV_LOG_FATAL,
"Only video and audio filters supported "
278 int file_idx = strtol(in->name, &p, 0);
281 av_log(NULL, AV_LOG_FATAL,
"Invalid file index %d in filtergraph description %s.\n",
287 for (i = 0; i < s->nb_streams; i++) {
288 enum AVMediaType stream_type = s->streams[i]->codecpar->codec_type;
289 if (stream_type != type &&
290 !(stream_type == AVMEDIA_TYPE_SUBTITLE &&
291 type == AVMEDIA_TYPE_VIDEO ))
299 av_log(NULL, AV_LOG_FATAL,
"Stream specifier '%s' in filtergraph description %s "
305 av_log(NULL, AV_LOG_FATAL,
"Stream specifier '%s' in filtergraph description %s "
306 "matches a disabled input stream.\n", p, fg->
graph_desc);
319 av_log(NULL, AV_LOG_FATAL,
"Cannot find a matching stream for "
320 "unlabeled input pad %d on filter %s\n", in->pad_idx,
321 in->filter_ctx->name);
329 ist->
st->discard = AVDISCARD_NONE;
350 AVFilterInOut *inputs, *outputs, *cur;
351 AVFilterGraph *graph;
356 graph = avfilter_graph_alloc();
358 return AVERROR(ENOMEM);
359 graph->nb_threads = 1;
361 ret = avfilter_graph_parse2(graph, fg->
graph_desc, &inputs, &outputs);
365 for (cur = inputs; cur; cur = cur->next)
368 for (cur = outputs; cur;) {
384 avfilter_inout_free(&inputs);
385 avfilter_graph_free(&graph);
390 AVFilterContext **last_filter,
int *pad_idx,
391 const char *filter_name)
393 AVFilterGraph *graph = (*last_filter)->graph;
394 AVFilterContext *ctx;
395 const AVFilter *trim;
396 enum AVMediaType type = avfilter_pad_get_type((*last_filter)->output_pads, *pad_idx);
397 const char *name = (type == AVMEDIA_TYPE_VIDEO) ?
"trim" :
"atrim";
400 if (duration == INT64_MAX && start_time == AV_NOPTS_VALUE)
403 trim = avfilter_get_by_name(name);
405 av_log(NULL, AV_LOG_ERROR,
"%s filter not present, cannot limit "
406 "recording time.\n", name);
407 return AVERROR_FILTER_NOT_FOUND;
410 ctx = avfilter_graph_alloc_filter(graph, trim, filter_name);
412 return AVERROR(ENOMEM);
414 if (duration != INT64_MAX) {
415 ret = av_opt_set_int(ctx,
"durationi", duration,
416 AV_OPT_SEARCH_CHILDREN);
418 if (ret >= 0 && start_time != AV_NOPTS_VALUE) {
419 ret = av_opt_set_int(ctx,
"starti", start_time,
420 AV_OPT_SEARCH_CHILDREN);
423 av_log(ctx, AV_LOG_ERROR,
"Error configuring the %s filter", name);
427 ret = avfilter_init_str(ctx, NULL);
431 ret = avfilter_link(*last_filter, *pad_idx, ctx, 0);
441 const char *filter_name,
const char *args)
443 AVFilterGraph *graph = (*last_filter)->graph;
444 AVFilterContext *ctx;
447 ret = avfilter_graph_create_filter(&ctx,
448 avfilter_get_by_name(filter_name),
449 filter_name, args, NULL, graph);
453 ret = avfilter_link(*last_filter, *pad_idx, ctx, 0);
467 AVFilterContext *last_filter = out->filter_ctx;
468 int pad_idx = out->pad_idx;
472 snprintf(name,
sizeof(name),
"out_%d_%d", ost->
file_index, ost->
index);
473 ret = avfilter_graph_create_filter(&ofilter->
filter,
474 avfilter_get_by_name(
"buffersink"),
475 name, NULL, NULL, fg->
graph);
482 AVFilterContext *filter;
483 AVDictionaryEntry *e = NULL;
485 snprintf(args,
sizeof(args),
"%d:%d",
488 while ((e = av_dict_get(ost->
sws_dict,
"", e,
489 AV_DICT_IGNORE_SUFFIX))) {
490 av_strlcatf(args,
sizeof(args),
":%s=%s", e->key, e->value);
493 snprintf(name,
sizeof(name),
"scaler_out_%d_%d",
495 if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name(
"scale"),
496 name, args, NULL, fg->
graph)) < 0)
498 if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
501 last_filter = filter;
506 AVFilterContext *filter;
507 snprintf(name,
sizeof(name),
"format_out_%d_%d",
509 ret = avfilter_graph_create_filter(&filter,
510 avfilter_get_by_name(
"format"),
511 "format", pix_fmts, NULL, fg->
graph);
515 if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
518 last_filter = filter;
523 AVFilterContext *fps;
526 snprintf(args,
sizeof(args),
"fps=%d/%d", ost->
frame_rate.num,
528 snprintf(name,
sizeof(name),
"fps_out_%d_%d",
530 ret = avfilter_graph_create_filter(&fps, avfilter_get_by_name(
"fps"),
531 name, args, NULL, fg->
graph);
535 ret = avfilter_link(last_filter, pad_idx, fps, 0);
542 snprintf(name,
sizeof(name),
"trim_out_%d_%d",
545 &last_filter, &pad_idx, name);
550 if ((ret = avfilter_link(last_filter, pad_idx, ofilter->
filter, 0)) < 0)
560 AVCodecContext *codec = ost->
enc_ctx;
561 AVFilterContext *last_filter = out->filter_ctx;
562 int pad_idx = out->pad_idx;
567 snprintf(name,
sizeof(name),
"out_%d_%d", ost->
file_index, ost->
index);
568 ret = avfilter_graph_create_filter(&ofilter->
filter,
569 avfilter_get_by_name(
"abuffersink"),
570 name, NULL, NULL, fg->
graph);
573 if ((ret = av_opt_set_int(ofilter->
filter,
"all_channel_counts", 1, AV_OPT_SEARCH_CHILDREN)) < 0)
576 #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \
577 AVFilterContext *filt_ctx; \
579 av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
580 "similarly to -af " filter_name "=%s.\n", arg); \
582 ret = avfilter_graph_create_filter(&filt_ctx, \
583 avfilter_get_by_name(filter_name), \
584 filter_name, arg, NULL, fg->graph); \
588 ret = avfilter_link(last_filter, pad_idx, filt_ctx, 0); \
592 last_filter = filt_ctx; \
598 av_bprint_init(&pan_buf, 256, 8192);
599 av_bprintf(&pan_buf,
"0x%"PRIx64,
606 av_bprint_finalize(&pan_buf, NULL);
609 if (codec->channels && !codec->channel_layout)
610 codec->channel_layout = av_get_default_channel_layout(codec->channels);
612 sample_fmts = choose_sample_fmts(ofilter);
614 channel_layouts = choose_channel_layouts(ofilter);
616 AVFilterContext *format;
621 av_strlcatf(args,
sizeof(args),
"sample_fmts=%s:",
624 av_strlcatf(args,
sizeof(args),
"sample_rates=%s:",
627 av_strlcatf(args,
sizeof(args),
"channel_layouts=%s:",
630 av_freep(&sample_fmts);
632 av_freep(&channel_layouts);
634 snprintf(name,
sizeof(name),
"format_out_%d_%d",
636 ret = avfilter_graph_create_filter(&format,
637 avfilter_get_by_name(
"aformat"),
638 name, args, NULL, fg->
graph);
642 ret = avfilter_link(last_filter, pad_idx, format, 0);
646 last_filter = format;
653 snprintf(args,
sizeof(args),
"%f",
audio_volume / 256.);
661 for (i=0; i<of->
ctx->nb_streams; i++)
662 if (of->
ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
665 if (i<of->ctx->nb_streams) {
666 snprintf(args,
sizeof(args),
"%s", ost->
apad);
671 snprintf(name,
sizeof(name),
"trim for output stream %d:%d",
674 &last_filter, &pad_idx, name);
678 if ((ret = avfilter_link(last_filter, pad_idx, ofilter->
filter, 0)) < 0)
687 av_log(NULL, AV_LOG_FATAL,
"Filter %s has an unconnected output\n", ofilter->
name);
691 switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) {
694 default: av_assert0(0);
706 av_log(NULL, AV_LOG_FATAL,
"Filter %s has an unconnected output\n", output->
name);
724 for (i = 0; i < avf->nb_streams; i++) {
725 if (avf->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
726 w = FFMAX(w, avf->streams[i]->codecpar->width);
727 h = FFMAX(h, avf->streams[i]->codecpar->height);
734 av_log(avf, AV_LOG_INFO,
"sub2video: using %dx%d canvas\n", w, h);
744 ifilter->
format = AV_PIX_FMT_RGB32;
748 return AVERROR(ENOMEM);
757 AVFilterContext *last_filter;
758 const AVFilter *buffer_filt = avfilter_get_by_name(
"buffer");
767 int ret, pad_idx = 0;
768 int64_t tsoffset = 0;
769 AVBufferSrcParameters *par = av_buffersrc_parameters_alloc();
772 return AVERROR(ENOMEM);
773 memset(par, 0,
sizeof(*par));
774 par->format = AV_PIX_FMT_NONE;
776 if (ist->
dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
777 av_log(NULL, AV_LOG_ERROR,
"Cannot connect video filter to audio input\n");
778 ret = AVERROR(EINVAL);
785 if (ist->
dec_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
793 sar = (AVRational){0,1};
794 av_bprint_init(&args, 0, AV_BPRINT_SIZE_AUTOMATIC);
796 "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:"
797 "pixel_aspect=%d/%d:sws_param=flags=%d",
799 tb.num, tb.den, sar.num, sar.den,
800 SWS_BILINEAR + ((ist->
dec_ctx->flags&AV_CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0));
801 if (fr.num && fr.den)
802 av_bprintf(&args,
":frame_rate=%d/%d", fr.num, fr.den);
803 snprintf(name,
sizeof(name),
"graph %d input from stream %d:%d", fg->
index,
807 if ((ret = avfilter_graph_create_filter(&ifilter->
filter, buffer_filt, name,
808 args.str, NULL, fg->
graph)) < 0)
811 ret = av_buffersrc_parameters_set(ifilter->
filter, par);
815 last_filter = ifilter->
filter;
820 if (fabs(theta - 90) < 1.0) {
821 ret =
insert_filter(&last_filter, &pad_idx,
"transpose",
"clock");
822 }
else if (fabs(theta - 180) < 1.0) {
827 }
else if (fabs(theta - 270) < 1.0) {
828 ret =
insert_filter(&last_filter, &pad_idx,
"transpose",
"cclock");
829 }
else if (fabs(theta) > 1.0) {
831 snprintf(rotate_buf,
sizeof(rotate_buf),
"%f*PI/180", theta);
832 ret =
insert_filter(&last_filter, &pad_idx,
"rotate", rotate_buf);
839 AVFilterContext *yadif;
841 snprintf(name,
sizeof(name),
"deinterlace_in_%d_%d",
843 if ((ret = avfilter_graph_create_filter(&yadif,
844 avfilter_get_by_name(
"yadif"),
849 if ((ret = avfilter_link(last_filter, 0, yadif, 0)) < 0)
855 snprintf(name,
sizeof(name),
"trim_in_%d_%d",
860 tsoffset += f->
ctx->start_time;
864 &last_filter, &pad_idx, name);
868 if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0)
880 AVFilterContext *last_filter;
881 const AVFilter *abuffer_filt = avfilter_get_by_name(
"abuffer");
886 int ret, pad_idx = 0;
887 int64_t tsoffset = 0;
889 if (ist->
dec_ctx->codec_type != AVMEDIA_TYPE_AUDIO) {
890 av_log(NULL, AV_LOG_ERROR,
"Cannot connect audio filter to non audio input\n");
891 return AVERROR(EINVAL);
894 av_bprint_init(&args, 0, AV_BPRINT_SIZE_AUTOMATIC);
895 av_bprintf(&args,
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s",
898 av_get_sample_fmt_name(ifilter->
format));
900 av_bprintf(&args,
":channel_layout=0x%"PRIx64,
903 av_bprintf(&args,
":channels=%d", ifilter->
channels);
904 snprintf(name,
sizeof(name),
"graph_%d_in_%d_%d", fg->
index,
907 if ((ret = avfilter_graph_create_filter(&ifilter->
filter, abuffer_filt,
908 name, args.str, NULL,
911 last_filter = ifilter->
filter;
913 #define AUTO_INSERT_FILTER_INPUT(opt_name, filter_name, arg) do { \
914 AVFilterContext *filt_ctx; \
916 av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
917 "similarly to -af " filter_name "=%s.\n", arg); \
919 snprintf(name, sizeof(name), "graph_%d_%s_in_%d_%d", \
920 fg->index, filter_name, ist->file_index, ist->st->index); \
921 ret = avfilter_graph_create_filter(&filt_ctx, \
922 avfilter_get_by_name(filter_name), \
923 name, arg, NULL, fg->graph); \
927 ret = avfilter_link(last_filter, 0, filt_ctx, 0); \
931 last_filter = filt_ctx; \
935 char args[256] = {0};
941 av_strlcatf(args,
sizeof(args),
":first_pts=0");
961 av_log(NULL, AV_LOG_WARNING,
"-vol has been deprecated. Use the volume "
962 "audio filter instead.\n");
964 snprintf(args,
sizeof(args),
"%f",
audio_volume / 256.);
968 snprintf(name,
sizeof(name),
"trim for input stream %d:%d",
973 tsoffset += f->
ctx->start_time;
977 &last_filter, &pad_idx, name);
981 if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0)
991 av_log(NULL, AV_LOG_ERROR,
992 "No decoder for stream #%d:%d, filtering impossible\n",
994 return AVERROR_DECODER_NOT_FOUND;
996 switch (avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx)) {
999 default: av_assert0(0);
1010 avfilter_graph_free(&fg->
graph);
1015 AVFilterInOut *inputs, *outputs, *cur;
1021 if (!(fg->
graph = avfilter_graph_alloc()))
1022 return AVERROR(ENOMEM);
1027 AVDictionaryEntry *e = NULL;
1032 while ((e = av_dict_get(ost->
sws_dict,
"", e,
1033 AV_DICT_IGNORE_SUFFIX))) {
1034 av_strlcatf(args,
sizeof(args),
"%s=%s:", e->key, e->value);
1037 args[strlen(args)-1] = 0;
1038 fg->
graph->scale_sws_opts = av_strdup(args);
1041 while ((e = av_dict_get(ost->
swr_opts,
"", e,
1042 AV_DICT_IGNORE_SUFFIX))) {
1043 av_strlcatf(args,
sizeof(args),
"%s=%s:", e->key, e->value);
1046 args[strlen(args)-1] = 0;
1047 av_opt_set(fg->
graph,
"aresample_swr_opts", args, 0);
1051 AV_DICT_IGNORE_SUFFIX))) {
1052 av_strlcatf(args,
sizeof(args),
"%s=%s:", e->key, e->value);
1055 args[strlen(args) - 1] =
'\0';
1057 e = av_dict_get(ost->
encoder_opts,
"threads", NULL, 0);
1059 av_opt_set(fg->
graph,
"threads", e->value, 0);
1064 if ((ret = avfilter_graph_parse2(fg->
graph, graph_desc, &inputs, &outputs)) < 0)
1070 for (i = 0; i < fg->
graph->nb_filters; i++) {
1071 fg->
graph->filters[i]->hw_device_ctx = av_buffer_ref(device);
1072 if (!fg->
graph->filters[i]->hw_device_ctx) {
1073 ret = AVERROR(ENOMEM);
1079 if (simple && (!inputs || inputs->next || !outputs || outputs->next)) {
1080 const char *num_inputs;
1081 const char *num_outputs;
1084 }
else if (outputs->next) {
1091 }
else if (inputs->next) {
1096 av_log(NULL, AV_LOG_ERROR,
"Simple filtergraph '%s' was expected "
1097 "to have exactly 1 input and 1 output."
1098 " However, it had %s input(s) and %s output(s)."
1099 " Please adjust, or use a complex filtergraph (-filter_complex) instead.\n",
1100 graph_desc, num_inputs, num_outputs);
1101 ret = AVERROR(EINVAL);
1105 for (cur = inputs, i = 0; cur; cur = cur->next, i++)
1107 avfilter_inout_free(&inputs);
1108 avfilter_inout_free(&outputs);
1111 avfilter_inout_free(&inputs);
1113 for (cur = outputs, i = 0; cur; cur = cur->next, i++)
1115 avfilter_inout_free(&outputs);
1117 if ((ret = avfilter_graph_config(fg->
graph, NULL)) < 0)
1124 AVFilterContext *sink = ofilter->
filter;
1126 ofilter->
format = av_buffersink_get_format(sink);
1128 ofilter->
width = av_buffersink_get_w(sink);
1129 ofilter->
height = av_buffersink_get_h(sink);
1131 ofilter->
sample_rate = av_buffersink_get_sample_rate(sink);
1132 ofilter->
channel_layout = av_buffersink_get_channel_layout(sink);
1142 av_log(NULL, AV_LOG_ERROR,
"Encoder (codec %s) not found for output stream #%d:%d\n",
1144 ret = AVERROR(EINVAL);
1147 if (ost->
enc->type == AVMEDIA_TYPE_AUDIO &&
1148 !(ost->
enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE))
1157 ret = av_buffersrc_add_frame(fg->
inputs[i]->
filter, tmp);
1158 av_frame_free(&tmp);
1167 ret = av_buffersrc_add_frame(fg->
inputs[i]->
filter, NULL);
1181 avsubtitle_free(&tmp);
1197 ifilter->
format = frame->format;
1199 ifilter->
width = frame->width;
1200 ifilter->
height = frame->height;
1204 ifilter->
channels = frame->channels;
1207 if (frame->hw_frames_ctx) {
1208 ifilter->
hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);
1210 return AVERROR(ENOMEM);