FFmpeg
ffmpeg_filter.c
Go to the documentation of this file.
1 /*
2  * ffmpeg filter configuration
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <stdint.h>
22 
23 #include "ffmpeg.h"
24 
25 #include "libavfilter/avfilter.h"
26 #include "libavfilter/buffersink.h"
27 #include "libavfilter/buffersrc.h"
28 
29 #include "libavutil/avassert.h"
30 #include "libavutil/avstring.h"
31 #include "libavutil/bprint.h"
33 #include "libavutil/display.h"
34 #include "libavutil/opt.h"
35 #include "libavutil/pixdesc.h"
36 #include "libavutil/pixfmt.h"
37 #include "libavutil/imgutils.h"
38 #include "libavutil/samplefmt.h"
39 
40 // FIXME: YUV420P etc. are actually supported with full color range,
41 // yet the latter information isn't available here.
42 static const enum AVPixelFormat *get_compliance_normal_pix_fmts(const AVCodec *codec, const enum AVPixelFormat default_formats[])
43 {
44  static const enum AVPixelFormat mjpeg_formats[] =
47 
48  if (!strcmp(codec->name, "mjpeg")) {
49  return mjpeg_formats;
50  } else {
51  return default_formats;
52  }
53 }
54 
55 static enum AVPixelFormat
56 choose_pixel_fmt(const AVCodec *codec, enum AVPixelFormat target,
57  int strict_std_compliance)
58 {
59  if (codec && codec->pix_fmts) {
60  const enum AVPixelFormat *p = codec->pix_fmts;
62  //FIXME: This should check for AV_PIX_FMT_FLAG_ALPHA after PAL8 pixel format without alpha is implemented
63  int has_alpha = desc ? desc->nb_components % 2 == 0 : 0;
64  enum AVPixelFormat best= AV_PIX_FMT_NONE;
65 
66  if (strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
67  p = get_compliance_normal_pix_fmts(codec, p);
68  }
69  for (; *p != AV_PIX_FMT_NONE; p++) {
70  best = av_find_best_pix_fmt_of_2(best, *p, target, has_alpha, NULL);
71  if (*p == target)
72  break;
73  }
74  if (*p == AV_PIX_FMT_NONE) {
75  if (target != AV_PIX_FMT_NONE)
77  "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n",
78  av_get_pix_fmt_name(target),
79  codec->name,
80  av_get_pix_fmt_name(best));
81  return best;
82  }
83  }
84  return target;
85 }
86 
87 /* May return NULL (no pixel format found), a static string or a string
88  * backed by the bprint. Nothing has been written to the AVBPrint in case
89  * NULL is returned. The AVBPrint provided should be clean. */
90 static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint)
91 {
92  OutputStream *ost = ofilter->ost;
93  AVCodecContext *enc = ost->enc_ctx;
94  const AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
95  if (strict_dict)
96  // used by choose_pixel_fmt() and below
97  av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0);
98 
99  if (ost->keep_pix_fmt) {
102  if (ost->enc_ctx->pix_fmt == AV_PIX_FMT_NONE)
103  return NULL;
104  return av_get_pix_fmt_name(ost->enc_ctx->pix_fmt);
105  }
106  if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
108  ost->enc_ctx->strict_std_compliance));
109  } else if (enc->codec->pix_fmts) {
110  const enum AVPixelFormat *p;
111 
112  p = enc->codec->pix_fmts;
113  if (ost->enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
115  }
116 
117  for (; *p != AV_PIX_FMT_NONE; p++) {
118  const char *name = av_get_pix_fmt_name(*p);
119  av_bprintf(bprint, "%s%c", name, p[1] == AV_PIX_FMT_NONE ? '\0' : '|');
120  }
121  if (!av_bprint_is_complete(bprint))
122  report_and_exit(AVERROR(ENOMEM));
123  return bprint->str;
124  } else
125  return NULL;
126 }
127 
128 /* Define a function for appending a list of allowed formats
129  * to an AVBPrint. If nonempty, the list will have a header. */
130 #define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name) \
131 static void choose_ ## name (OutputFilter *ofilter, AVBPrint *bprint) \
132 { \
133  if (ofilter->var == none && !ofilter->supported_list) \
134  return; \
135  av_bprintf(bprint, #name "="); \
136  if (ofilter->var != none) { \
137  av_bprintf(bprint, printf_format, get_name(ofilter->var)); \
138  } else { \
139  const type *p; \
140  \
141  for (p = ofilter->supported_list; *p != none; p++) { \
142  av_bprintf(bprint, printf_format "|", get_name(*p)); \
143  } \
144  if (bprint->len > 0) \
145  bprint->str[--bprint->len] = '\0'; \
146  } \
147  av_bprint_chars(bprint, ':', 1); \
148 }
149 
150 //DEF_CHOOSE_FORMAT(pix_fmts, enum AVPixelFormat, format, formats, AV_PIX_FMT_NONE,
151 // GET_PIX_FMT_NAME)
152 
155 
157  "%d", )
158 
159 static void choose_channel_layouts(OutputFilter *ofilter, AVBPrint *bprint)
160 {
161  if (av_channel_layout_check(&ofilter->ch_layout)) {
162  av_bprintf(bprint, "channel_layouts=");
163  av_channel_layout_describe_bprint(&ofilter->ch_layout, bprint);
164  } else if (ofilter->ch_layouts) {
165  const AVChannelLayout *p;
166 
167  av_bprintf(bprint, "channel_layouts=");
168  for (p = ofilter->ch_layouts; p->nb_channels; p++) {
170  av_bprintf(bprint, "|");
171  }
172  if (bprint->len > 0)
173  bprint->str[--bprint->len] = '\0';
174  } else
175  return;
176  av_bprint_chars(bprint, ':', 1);
177 }
178 
180 {
181  FilterGraph *fg = av_mallocz(sizeof(*fg));
182  OutputFilter *ofilter;
183  InputFilter *ifilter;
184 
185  if (!fg)
186  report_and_exit(AVERROR(ENOMEM));
187  fg->index = nb_filtergraphs;
188 
189  ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
190  ofilter->ost = ost;
191  ofilter->graph = fg;
192  ofilter->format = -1;
193 
194  ost->filter = ofilter;
195 
196  ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
197  ifilter->ist = ist;
198  ifilter->graph = fg;
199  ifilter->format = -1;
200 
201  ifilter->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW);
202  if (!ifilter->frame_queue)
203  report_and_exit(AVERROR(ENOMEM));
204 
205  GROW_ARRAY(ist->filters, ist->nb_filters);
206  ist->filters[ist->nb_filters - 1] = ifilter;
207 
209  filtergraphs[nb_filtergraphs - 1] = fg;
210 
211  return 0;
212 }
213 
214 static char *describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in)
215 {
216  AVFilterContext *ctx = inout->filter_ctx;
217  AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads;
218  int nb_pads = in ? ctx->nb_inputs : ctx->nb_outputs;
219  char *res;
220 
221  if (nb_pads > 1)
222  res = av_strdup(ctx->filter->name);
223  else
224  res = av_asprintf("%s:%s", ctx->filter->name,
225  avfilter_pad_get_name(pads, inout->pad_idx));
226  if (!res)
227  report_and_exit(AVERROR(ENOMEM));
228  return res;
229 }
230 
232 {
233  InputStream *ist = NULL;
235  InputFilter *ifilter;
236  int i;
237 
238  // TODO: support other filter types
240  av_log(NULL, AV_LOG_FATAL, "Only video and audio filters supported "
241  "currently.\n");
242  exit_program(1);
243  }
244 
245  if (in->name) {
247  AVStream *st = NULL;
248  char *p;
249  int file_idx = strtol(in->name, &p, 0);
250 
251  if (file_idx < 0 || file_idx >= nb_input_files) {
252  av_log(NULL, AV_LOG_FATAL, "Invalid file index %d in filtergraph description %s.\n",
253  file_idx, fg->graph_desc);
254  exit_program(1);
255  }
256  s = input_files[file_idx]->ctx;
257 
258  for (i = 0; i < s->nb_streams; i++) {
259  enum AVMediaType stream_type = s->streams[i]->codecpar->codec_type;
260  if (stream_type != type &&
261  !(stream_type == AVMEDIA_TYPE_SUBTITLE &&
262  type == AVMEDIA_TYPE_VIDEO /* sub2video hack */))
263  continue;
264  if (check_stream_specifier(s, s->streams[i], *p == ':' ? p + 1 : p) == 1) {
265  st = s->streams[i];
266  break;
267  }
268  }
269  if (!st) {
270  av_log(NULL, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s "
271  "matches no streams.\n", p, fg->graph_desc);
272  exit_program(1);
273  }
274  ist = input_files[file_idx]->streams[st->index];
275  if (ist->user_set_discard == AVDISCARD_ALL) {
276  av_log(NULL, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s "
277  "matches a disabled input stream.\n", p, fg->graph_desc);
278  exit_program(1);
279  }
280  } else {
281  /* find the first unused stream of corresponding type */
282  for (ist = ist_iter(NULL); ist; ist = ist_iter(ist)) {
283  if (ist->user_set_discard == AVDISCARD_ALL)
284  continue;
285  if (ist->dec_ctx->codec_type == type && ist->discard)
286  break;
287  }
288  if (!ist) {
289  av_log(NULL, AV_LOG_FATAL, "Cannot find a matching stream for "
290  "unlabeled input pad %d on filter %s\n", in->pad_idx,
291  in->filter_ctx->name);
292  exit_program(1);
293  }
294  }
295  av_assert0(ist);
296 
297  ist->discard = 0;
299  ist->processing_needed = 1;
300  ist->st->discard = AVDISCARD_NONE;
301 
302  ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
303  ifilter->ist = ist;
304  ifilter->graph = fg;
305  ifilter->format = -1;
306  ifilter->type = ist->st->codecpar->codec_type;
307  ifilter->name = describe_filter_link(fg, in, 1);
308 
309  ifilter->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW);
310  if (!ifilter->frame_queue)
311  report_and_exit(AVERROR(ENOMEM));
312 
313  GROW_ARRAY(ist->filters, ist->nb_filters);
314  ist->filters[ist->nb_filters - 1] = ifilter;
315 }
316 
318 {
319  AVFilterInOut *inputs, *outputs, *cur;
320  AVFilterGraph *graph;
321  int ret = 0;
322 
323  /* this graph is only used for determining the kinds of inputs
324  * and outputs we have, and is discarded on exit from this function */
325  graph = avfilter_graph_alloc();
326  if (!graph)
327  return AVERROR(ENOMEM);
328  graph->nb_threads = 1;
329 
331  if (ret < 0)
332  goto fail;
333 
334  for (cur = inputs; cur; cur = cur->next)
335  init_input_filter(fg, cur);
336 
337  for (cur = outputs; cur;) {
338  OutputFilter *const ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
339 
340  ofilter->graph = fg;
341  ofilter->out_tmp = cur;
343  cur->pad_idx);
344  ofilter->name = describe_filter_link(fg, cur, 0);
345  cur = cur->next;
346  ofilter->out_tmp->next = NULL;
347  }
348 
349 fail:
351  avfilter_graph_free(&graph);
352  return ret;
353 }
354 
355 static int insert_trim(int64_t start_time, int64_t duration,
356  AVFilterContext **last_filter, int *pad_idx,
357  const char *filter_name)
358 {
359  AVFilterGraph *graph = (*last_filter)->graph;
361  const AVFilter *trim;
362  enum AVMediaType type = avfilter_pad_get_type((*last_filter)->output_pads, *pad_idx);
363  const char *name = (type == AVMEDIA_TYPE_VIDEO) ? "trim" : "atrim";
364  int ret = 0;
365 
366  if (duration == INT64_MAX && start_time == AV_NOPTS_VALUE)
367  return 0;
368 
369  trim = avfilter_get_by_name(name);
370  if (!trim) {
371  av_log(NULL, AV_LOG_ERROR, "%s filter not present, cannot limit "
372  "recording time.\n", name);
374  }
375 
376  ctx = avfilter_graph_alloc_filter(graph, trim, filter_name);
377  if (!ctx)
378  return AVERROR(ENOMEM);
379 
380  if (duration != INT64_MAX) {
381  ret = av_opt_set_int(ctx, "durationi", duration,
383  }
384  if (ret >= 0 && start_time != AV_NOPTS_VALUE) {
385  ret = av_opt_set_int(ctx, "starti", start_time,
387  }
388  if (ret < 0) {
389  av_log(ctx, AV_LOG_ERROR, "Error configuring the %s filter", name);
390  return ret;
391  }
392 
394  if (ret < 0)
395  return ret;
396 
397  ret = avfilter_link(*last_filter, *pad_idx, ctx, 0);
398  if (ret < 0)
399  return ret;
400 
401  *last_filter = ctx;
402  *pad_idx = 0;
403  return 0;
404 }
405 
406 static int insert_filter(AVFilterContext **last_filter, int *pad_idx,
407  const char *filter_name, const char *args)
408 {
409  AVFilterGraph *graph = (*last_filter)->graph;
411  int ret;
412 
414  avfilter_get_by_name(filter_name),
415  filter_name, args, NULL, graph);
416  if (ret < 0)
417  return ret;
418 
419  ret = avfilter_link(*last_filter, *pad_idx, ctx, 0);
420  if (ret < 0)
421  return ret;
422 
423  *last_filter = ctx;
424  *pad_idx = 0;
425  return 0;
426 }
427 
429 {
430  OutputStream *ost = ofilter->ost;
431  OutputFile *of = output_files[ost->file_index];
432  AVFilterContext *last_filter = out->filter_ctx;
433  AVBPrint bprint;
434  int pad_idx = out->pad_idx;
435  int ret;
436  const char *pix_fmts;
437  char name[255];
438 
439  snprintf(name, sizeof(name), "out_%d_%d", ost->file_index, ost->index);
441  avfilter_get_by_name("buffersink"),
442  name, NULL, NULL, fg->graph);
443 
444  if (ret < 0)
445  return ret;
446 
447  if ((ofilter->width || ofilter->height) && ofilter->ost->autoscale) {
448  char args[255];
450  const AVDictionaryEntry *e = NULL;
451 
452  snprintf(args, sizeof(args), "%d:%d",
453  ofilter->width, ofilter->height);
454 
455  while ((e = av_dict_iterate(ost->sws_dict, e))) {
456  av_strlcatf(args, sizeof(args), ":%s=%s", e->key, e->value);
457  }
458 
459  snprintf(name, sizeof(name), "scaler_out_%d_%d",
460  ost->file_index, ost->index);
462  name, args, NULL, fg->graph)) < 0)
463  return ret;
464  if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
465  return ret;
466 
467  last_filter = filter;
468  pad_idx = 0;
469  }
470 
472  if ((pix_fmts = choose_pix_fmts(ofilter, &bprint))) {
474 
476  avfilter_get_by_name("format"),
477  "format", pix_fmts, NULL, fg->graph);
478  av_bprint_finalize(&bprint, NULL);
479  if (ret < 0)
480  return ret;
481  if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
482  return ret;
483 
484  last_filter = filter;
485  pad_idx = 0;
486  }
487 
488  if (ost->frame_rate.num && 0) {
489  AVFilterContext *fps;
490  char args[255];
491 
492  snprintf(args, sizeof(args), "fps=%d/%d", ost->frame_rate.num,
493  ost->frame_rate.den);
494  snprintf(name, sizeof(name), "fps_out_%d_%d",
495  ost->file_index, ost->index);
497  name, args, NULL, fg->graph);
498  if (ret < 0)
499  return ret;
500 
501  ret = avfilter_link(last_filter, pad_idx, fps, 0);
502  if (ret < 0)
503  return ret;
504  last_filter = fps;
505  pad_idx = 0;
506  }
507 
508  snprintf(name, sizeof(name), "trim_out_%d_%d",
509  ost->file_index, ost->index);
511  &last_filter, &pad_idx, name);
512  if (ret < 0)
513  return ret;
514 
515 
516  if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0)
517  return ret;
518 
519  return 0;
520 }
521 
523 {
524  OutputStream *ost = ofilter->ost;
525  OutputFile *of = output_files[ost->file_index];
526  AVCodecContext *codec = ost->enc_ctx;
527  AVFilterContext *last_filter = out->filter_ctx;
528  int pad_idx = out->pad_idx;
529  AVBPrint args;
530  char name[255];
531  int ret;
532 
533  snprintf(name, sizeof(name), "out_%d_%d", ost->file_index, ost->index);
535  avfilter_get_by_name("abuffersink"),
536  name, NULL, NULL, fg->graph);
537  if (ret < 0)
538  return ret;
539  if ((ret = av_opt_set_int(ofilter->filter, "all_channel_counts", 1, AV_OPT_SEARCH_CHILDREN)) < 0)
540  return ret;
541 
542 #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \
543  AVFilterContext *filt_ctx; \
544  \
545  av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
546  "similarly to -af " filter_name "=%s.\n", arg); \
547  \
548  ret = avfilter_graph_create_filter(&filt_ctx, \
549  avfilter_get_by_name(filter_name), \
550  filter_name, arg, NULL, fg->graph); \
551  if (ret < 0) \
552  goto fail; \
553  \
554  ret = avfilter_link(last_filter, pad_idx, filt_ctx, 0); \
555  if (ret < 0) \
556  goto fail; \
557  \
558  last_filter = filt_ctx; \
559  pad_idx = 0; \
560 } while (0)
562 #if FFMPEG_OPT_MAP_CHANNEL
563  if (ost->audio_channels_mapped) {
564  AVChannelLayout mapped_layout = { 0 };
565  int i;
566  av_channel_layout_default(&mapped_layout, ost->audio_channels_mapped);
567  av_channel_layout_describe_bprint(&mapped_layout, &args);
568  for (i = 0; i < ost->audio_channels_mapped; i++)
569  if (ost->audio_channels_map[i] != -1)
570  av_bprintf(&args, "|c%d=c%d", i, ost->audio_channels_map[i]);
571 
572  AUTO_INSERT_FILTER("-map_channel", "pan", args.str);
573  av_bprint_clear(&args);
574  }
575 #endif
576 
579 
580  choose_sample_fmts(ofilter, &args);
581  choose_sample_rates(ofilter, &args);
582  choose_channel_layouts(ofilter, &args);
583  if (!av_bprint_is_complete(&args)) {
584  ret = AVERROR(ENOMEM);
585  goto fail;
586  }
587  if (args.len) {
589 
590  snprintf(name, sizeof(name), "format_out_%d_%d",
591  ost->file_index, ost->index);
593  avfilter_get_by_name("aformat"),
594  name, args.str, NULL, fg->graph);
595  if (ret < 0)
596  goto fail;
597 
598  ret = avfilter_link(last_filter, pad_idx, format, 0);
599  if (ret < 0)
600  goto fail;
601 
602  last_filter = format;
603  pad_idx = 0;
604  }
605 
606  if (ost->apad && of->shortest) {
607  int i;
608 
609  for (i = 0; i < of->nb_streams; i++)
611  break;
612 
613  if (i < of->nb_streams) {
614  AUTO_INSERT_FILTER("-apad", "apad", ost->apad);
615  }
616  }
617 
618  snprintf(name, sizeof(name), "trim for output stream %d:%d",
619  ost->file_index, ost->index);
621  &last_filter, &pad_idx, name);
622  if (ret < 0)
623  goto fail;
624 
625  if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0)
626  goto fail;
627 fail:
628  av_bprint_finalize(&args, NULL);
629 
630  return ret;
631 }
632 
635 {
636  if (!ofilter->ost) {
637  av_log(NULL, AV_LOG_FATAL, "Filter %s has an unconnected output\n", ofilter->name);
638  exit_program(1);
639  }
640 
641  switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) {
642  case AVMEDIA_TYPE_VIDEO: return configure_output_video_filter(fg, ofilter, out);
643  case AVMEDIA_TYPE_AUDIO: return configure_output_audio_filter(fg, ofilter, out);
644  default: av_assert0(0); return 0;
645  }
646 }
647 
649 {
650  int i;
651  for (i = 0; i < nb_filtergraphs; i++) {
652  int n;
653  for (n = 0; n < filtergraphs[i]->nb_outputs; n++) {
655  if (!output->ost) {
656  av_log(NULL, AV_LOG_FATAL, "Filter %s has an unconnected output\n", output->name);
657  exit_program(1);
658  }
659  }
660  }
661 }
662 
663 static int sub2video_prepare(InputStream *ist, InputFilter *ifilter)
664 {
666  int i, w, h;
667 
668  /* Compute the size of the canvas for the subtitles stream.
669  If the subtitles codecpar has set a size, use it. Otherwise use the
670  maximum dimensions of the video streams in the same file. */
671  w = ifilter->width;
672  h = ifilter->height;
673  if (!(w && h)) {
674  for (i = 0; i < avf->nb_streams; i++) {
676  w = FFMAX(w, avf->streams[i]->codecpar->width);
677  h = FFMAX(h, avf->streams[i]->codecpar->height);
678  }
679  }
680  if (!(w && h)) {
681  w = FFMAX(w, 720);
682  h = FFMAX(h, 576);
683  }
684  av_log(avf, AV_LOG_INFO, "sub2video: using %dx%d canvas\n", w, h);
685  }
686  ist->sub2video.w = ifilter->width = w;
687  ist->sub2video.h = ifilter->height = h;
688 
689  ifilter->width = ist->dec_ctx->width ? ist->dec_ctx->width : ist->sub2video.w;
690  ifilter->height = ist->dec_ctx->height ? ist->dec_ctx->height : ist->sub2video.h;
691 
692  /* rectangles are AV_PIX_FMT_PAL8, but we have no guarantee that the
693  palettes for all rectangles are identical or compatible */
694  ifilter->format = AV_PIX_FMT_RGB32;
695 
696  ist->sub2video.frame = av_frame_alloc();
697  if (!ist->sub2video.frame)
698  return AVERROR(ENOMEM);
699  ist->sub2video.last_pts = INT64_MIN;
700  ist->sub2video.end_pts = INT64_MIN;
701 
702  /* sub2video structure has been (re-)initialized.
703  Mark it as such so that the system will be
704  initialized with the first received heartbeat. */
705  ist->sub2video.initialize = 1;
706 
707  return 0;
708 }
709 
711  AVFilterInOut *in)
712 {
713  AVFilterContext *last_filter;
714  const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
715  const AVPixFmtDescriptor *desc;
716  InputStream *ist = ifilter->ist;
718  AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
719  ist->st->time_base;
720  AVRational fr = ist->framerate;
721  AVRational sar;
722  AVBPrint args;
723  char name[255];
724  int ret, pad_idx = 0;
725  int64_t tsoffset = 0;
727 
728  if (!par)
729  return AVERROR(ENOMEM);
730  memset(par, 0, sizeof(*par));
731  par->format = AV_PIX_FMT_NONE;
732 
733  if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
734  av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n");
735  ret = AVERROR(EINVAL);
736  goto fail;
737  }
738 
739  if (!fr.num)
740  fr = ist->framerate_guessed;
741 
743  ret = sub2video_prepare(ist, ifilter);
744  if (ret < 0)
745  goto fail;
746  }
747 
748  sar = ifilter->sample_aspect_ratio;
749  if(!sar.den)
750  sar = (AVRational){0,1};
752  av_bprintf(&args,
753  "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:"
754  "pixel_aspect=%d/%d",
755  ifilter->width, ifilter->height, ifilter->format,
756  tb.num, tb.den, sar.num, sar.den);
757  if (fr.num && fr.den)
758  av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den);
759  snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
760  ist->file_index, ist->st->index);
761 
762 
763  if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name,
764  args.str, NULL, fg->graph)) < 0)
765  goto fail;
766  par->hw_frames_ctx = ifilter->hw_frames_ctx;
767  ret = av_buffersrc_parameters_set(ifilter->filter, par);
768  if (ret < 0)
769  goto fail;
770  av_freep(&par);
771  last_filter = ifilter->filter;
772 
773  desc = av_pix_fmt_desc_get(ifilter->format);
774  av_assert0(desc);
775 
776  // TODO: insert hwaccel enabled filters like transpose_vaapi into the graph
777  if (ist->autorotate && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
778  int32_t *displaymatrix = ifilter->displaymatrix;
779  double theta;
780 
781  if (!displaymatrix)
783  theta = get_rotation(displaymatrix);
784 
785  if (fabs(theta - 90) < 1.0) {
786  ret = insert_filter(&last_filter, &pad_idx, "transpose",
787  displaymatrix[3] > 0 ? "cclock_flip" : "clock");
788  } else if (fabs(theta - 180) < 1.0) {
789  if (displaymatrix[0] < 0) {
790  ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL);
791  if (ret < 0)
792  return ret;
793  }
794  if (displaymatrix[4] < 0) {
795  ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
796  }
797  } else if (fabs(theta - 270) < 1.0) {
798  ret = insert_filter(&last_filter, &pad_idx, "transpose",
799  displaymatrix[3] < 0 ? "clock_flip" : "cclock");
800  } else if (fabs(theta) > 1.0) {
801  char rotate_buf[64];
802  snprintf(rotate_buf, sizeof(rotate_buf), "%f*PI/180", theta);
803  ret = insert_filter(&last_filter, &pad_idx, "rotate", rotate_buf);
804  } else if (fabs(theta) < 1.0) {
805  if (displaymatrix && displaymatrix[4] < 0) {
806  ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
807  }
808  }
809  if (ret < 0)
810  return ret;
811  }
812 
813  snprintf(name, sizeof(name), "trim_in_%d_%d",
814  ist->file_index, ist->st->index);
815  if (copy_ts) {
816  tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
817  if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
818  tsoffset += f->ctx->start_time;
819  }
820  ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?
821  AV_NOPTS_VALUE : tsoffset, f->recording_time,
822  &last_filter, &pad_idx, name);
823  if (ret < 0)
824  return ret;
825 
826  if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0)
827  return ret;
828  return 0;
829 fail:
830  av_freep(&par);
831 
832  return ret;
833 }
834 
836  AVFilterInOut *in)
837 {
838  AVFilterContext *last_filter;
839  const AVFilter *abuffer_filt = avfilter_get_by_name("abuffer");
840  InputStream *ist = ifilter->ist;
842  AVBPrint args;
843  char name[255];
844  int ret, pad_idx = 0;
845  int64_t tsoffset = 0;
846 
847  if (ist->dec_ctx->codec_type != AVMEDIA_TYPE_AUDIO) {
848  av_log(NULL, AV_LOG_ERROR, "Cannot connect audio filter to non audio input\n");
849  return AVERROR(EINVAL);
850  }
851 
853  av_bprintf(&args, "time_base=%d/%d:sample_rate=%d:sample_fmt=%s",
854  1, ifilter->sample_rate,
855  ifilter->sample_rate,
856  av_get_sample_fmt_name(ifilter->format));
857  if (av_channel_layout_check(&ifilter->ch_layout) &&
859  av_bprintf(&args, ":channel_layout=");
861  } else
862  av_bprintf(&args, ":channels=%d", ifilter->ch_layout.nb_channels);
863  snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index,
864  ist->file_index, ist->st->index);
865 
866  if ((ret = avfilter_graph_create_filter(&ifilter->filter, abuffer_filt,
867  name, args.str, NULL,
868  fg->graph)) < 0)
869  return ret;
870  last_filter = ifilter->filter;
871 
872 #define AUTO_INSERT_FILTER_INPUT(opt_name, filter_name, arg) do { \
873  AVFilterContext *filt_ctx; \
874  \
875  av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
876  "similarly to -af " filter_name "=%s.\n", arg); \
877  \
878  snprintf(name, sizeof(name), "graph_%d_%s_in_%d_%d", \
879  fg->index, filter_name, ist->file_index, ist->st->index); \
880  ret = avfilter_graph_create_filter(&filt_ctx, \
881  avfilter_get_by_name(filter_name), \
882  name, arg, NULL, fg->graph); \
883  if (ret < 0) \
884  return ret; \
885  \
886  ret = avfilter_link(last_filter, 0, filt_ctx, 0); \
887  if (ret < 0) \
888  return ret; \
889  \
890  last_filter = filt_ctx; \
891 } while (0)
892 
893  snprintf(name, sizeof(name), "trim for input stream %d:%d",
894  ist->file_index, ist->st->index);
895  if (copy_ts) {
896  tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
897  if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
898  tsoffset += f->ctx->start_time;
899  }
900  ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?
901  AV_NOPTS_VALUE : tsoffset, f->recording_time,
902  &last_filter, &pad_idx, name);
903  if (ret < 0)
904  return ret;
905 
906  if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0)
907  return ret;
908 
909  return 0;
910 }
911 
913  AVFilterInOut *in)
914 {
915  if (!ifilter->ist->dec) {
917  "No decoder for stream #%d:%d, filtering impossible\n",
918  ifilter->ist->file_index, ifilter->ist->st->index);
920  }
921  switch (avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx)) {
922  case AVMEDIA_TYPE_VIDEO: return configure_input_video_filter(fg, ifilter, in);
923  case AVMEDIA_TYPE_AUDIO: return configure_input_audio_filter(fg, ifilter, in);
924  default: av_assert0(0); return 0;
925  }
926 }
927 
929 {
930  int i;
931  for (i = 0; i < fg->nb_outputs; i++)
932  fg->outputs[i]->filter = (AVFilterContext *)NULL;
933  for (i = 0; i < fg->nb_inputs; i++)
934  fg->inputs[i]->filter = (AVFilterContext *)NULL;
936 }
937 
939 {
940  return f->nb_inputs == 0 &&
941  (!strcmp(f->filter->name, "buffer") ||
942  !strcmp(f->filter->name, "abuffer"));
943 }
944 
945 static int graph_is_meta(AVFilterGraph *graph)
946 {
947  for (unsigned i = 0; i < graph->nb_filters; i++) {
948  const AVFilterContext *f = graph->filters[i];
949 
950  /* in addition to filters flagged as meta, also
951  * disregard sinks and buffersources (but not other sources,
952  * since they introduce data we are not aware of)
953  */
954  if (!((f->filter->flags & AVFILTER_FLAG_METADATA_ONLY) ||
955  f->nb_outputs == 0 ||
957  return 0;
958  }
959  return 1;
960 }
961 
963 {
964  AVFilterInOut *inputs, *outputs, *cur;
965  int ret, i, simple = filtergraph_is_simple(fg);
966  const char *graph_desc = simple ? fg->outputs[0]->ost->avfilter :
967  fg->graph_desc;
968 
970  if (!(fg->graph = avfilter_graph_alloc()))
971  return AVERROR(ENOMEM);
972 
973  if (simple) {
974  OutputStream *ost = fg->outputs[0]->ost;
975 
976  if (filter_nbthreads) {
977  ret = av_opt_set(fg->graph, "threads", filter_nbthreads, 0);
978  if (ret < 0)
979  goto fail;
980  } else {
981  const AVDictionaryEntry *e = NULL;
982  e = av_dict_get(ost->encoder_opts, "threads", NULL, 0);
983  if (e)
984  av_opt_set(fg->graph, "threads", e->value, 0);
985  }
986 
987  if (av_dict_count(ost->sws_dict)) {
988  ret = av_dict_get_string(ost->sws_dict,
989  &fg->graph->scale_sws_opts,
990  '=', ':');
991  if (ret < 0)
992  goto fail;
993  }
994 
995  if (av_dict_count(ost->swr_opts)) {
996  char *args;
997  ret = av_dict_get_string(ost->swr_opts, &args, '=', ':');
998  if (ret < 0)
999  goto fail;
1000  av_opt_set(fg->graph, "aresample_swr_opts", args, 0);
1001  av_free(args);
1002  }
1003  } else {
1005  }
1006 
1007  if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, &outputs)) < 0)
1008  goto fail;
1009 
1011  if (ret < 0)
1012  goto fail;
1013 
1014  if (simple && (!inputs || inputs->next || !outputs || outputs->next)) {
1015  const char *num_inputs;
1016  const char *num_outputs;
1017  if (!outputs) {
1018  num_outputs = "0";
1019  } else if (outputs->next) {
1020  num_outputs = ">1";
1021  } else {
1022  num_outputs = "1";
1023  }
1024  if (!inputs) {
1025  num_inputs = "0";
1026  } else if (inputs->next) {
1027  num_inputs = ">1";
1028  } else {
1029  num_inputs = "1";
1030  }
1031  av_log(NULL, AV_LOG_ERROR, "Simple filtergraph '%s' was expected "
1032  "to have exactly 1 input and 1 output."
1033  " However, it had %s input(s) and %s output(s)."
1034  " Please adjust, or use a complex filtergraph (-filter_complex) instead.\n",
1035  graph_desc, num_inputs, num_outputs);
1036  ret = AVERROR(EINVAL);
1037  goto fail;
1038  }
1039 
1040  for (cur = inputs, i = 0; cur; cur = cur->next, i++)
1041  if ((ret = configure_input_filter(fg, fg->inputs[i], cur)) < 0) {
1044  goto fail;
1045  }
1047 
1048  for (cur = outputs, i = 0; cur; cur = cur->next, i++)
1049  configure_output_filter(fg, fg->outputs[i], cur);
1051 
1054  if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
1055  goto fail;
1056 
1057  fg->is_meta = graph_is_meta(fg->graph);
1058 
1059  /* limit the lists of allowed formats to the ones selected, to
1060  * make sure they stay the same if the filtergraph is reconfigured later */
1061  for (i = 0; i < fg->nb_outputs; i++) {
1062  OutputFilter *ofilter = fg->outputs[i];
1063  AVFilterContext *sink = ofilter->filter;
1064 
1065  ofilter->format = av_buffersink_get_format(sink);
1066 
1067  ofilter->width = av_buffersink_get_w(sink);
1068  ofilter->height = av_buffersink_get_h(sink);
1069 
1070  ofilter->sample_rate = av_buffersink_get_sample_rate(sink);
1072  ret = av_buffersink_get_ch_layout(sink, &ofilter->ch_layout);
1073  if (ret < 0)
1074  goto fail;
1075  }
1076 
1077  fg->reconfiguration = 1;
1078 
1079  for (i = 0; i < fg->nb_outputs; i++) {
1080  OutputStream *ost = fg->outputs[i]->ost;
1081  if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO &&
1082  !(ost->enc_ctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE))
1083  av_buffersink_set_frame_size(ost->filter->filter,
1084  ost->enc_ctx->frame_size);
1085  }
1086 
1087  for (i = 0; i < fg->nb_inputs; i++) {
1088  AVFrame *tmp;
1089  while (av_fifo_read(fg->inputs[i]->frame_queue, &tmp, 1) >= 0) {
1091  av_frame_free(&tmp);
1092  if (ret < 0)
1093  goto fail;
1094  }
1095  }
1096 
1097  /* send the EOFs for the finished inputs */
1098  for (i = 0; i < fg->nb_inputs; i++) {
1099  if (fg->inputs[i]->eof) {
1101  if (ret < 0)
1102  goto fail;
1103  }
1104  }
1105 
1106  /* process queued up subtitle packets */
1107  for (i = 0; i < fg->nb_inputs; i++) {
1108  InputStream *ist = fg->inputs[i]->ist;
1109  if (ist->sub2video.sub_queue && ist->sub2video.frame) {
1110  AVSubtitle tmp;
1111  while (av_fifo_read(ist->sub2video.sub_queue, &tmp, 1) >= 0) {
1112  sub2video_update(ist, INT64_MIN, &tmp);
1113  avsubtitle_free(&tmp);
1114  }
1115  }
1116  }
1117 
1118  return 0;
1119 
1120 fail:
1121  cleanup_filtergraph(fg);
1122  return ret;
1123 }
1124 
1126 {
1127  AVFrameSideData *sd;
1128  int ret;
1129 
1130  av_buffer_unref(&ifilter->hw_frames_ctx);
1131 
1132  ifilter->format = frame->format;
1133 
1134  ifilter->width = frame->width;
1135  ifilter->height = frame->height;
1136  ifilter->sample_aspect_ratio = frame->sample_aspect_ratio;
1137 
1138  ifilter->sample_rate = frame->sample_rate;
1139  ret = av_channel_layout_copy(&ifilter->ch_layout, &frame->ch_layout);
1140  if (ret < 0)
1141  return ret;
1142 
1143  av_freep(&ifilter->displaymatrix);
1145  if (sd)
1146  ifilter->displaymatrix = av_memdup(sd->data, sizeof(int32_t) * 9);
1147 
1148  if (frame->hw_frames_ctx) {
1149  ifilter->hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);
1150  if (!ifilter->hw_frames_ctx)
1151  return AVERROR(ENOMEM);
1152  }
1153 
1154  return 0;
1155 }
1156 
1158 {
1159  return !fg->graph_desc;
1160 }
AVSubtitle
Definition: avcodec.h:2308
formats
formats
Definition: signature.h:48
init_complex_filtergraph
int init_complex_filtergraph(FilterGraph *fg)
Definition: ffmpeg_filter.c:317
InputFilter::sample_aspect_ratio
AVRational sample_aspect_ratio
Definition: ffmpeg.h:270
AVCodec
AVCodec.
Definition: codec.h:204
AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AV_BPRINT_SIZE_UNLIMITED
#define AV_BPRINT_SIZE_UNLIMITED
av_buffersink_get_ch_layout
int av_buffersink_get_ch_layout(const AVFilterContext *ctx, AVChannelLayout *out)
Definition: buffersink.c:241
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
OutputFilter::graph
struct FilterGraph * graph
Definition: ffmpeg.h:284
av_bprint_is_complete
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Definition: bprint.h:215
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
nb_input_files
int nb_input_files
Definition: ffmpeg.c:136
opt.h
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:58
AVFilterGraph::nb_threads
int nb_threads
Maximum number of threads used by filters in this graph.
Definition: avfilter.h:904
avfilter_pad_get_name
const char * avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx)
Get the name of an AVFilterPad.
Definition: avfilter.c:963
InputStream::framerate_guessed
AVRational framerate_guessed
Definition: ffmpeg.h:342
InputFilter::width
int width
Definition: ffmpeg.h:269
InputFilter::displaymatrix
int32_t * displaymatrix
Definition: ffmpeg.h:276
out
FILE * out
Definition: movenc.c:54
av_bprint_init
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition: bprint.c:69
av_frame_get_side_data
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:691
FilterGraph::graph_desc
const char * graph_desc
Definition: ffmpeg.h:307
ALLOC_ARRAY_ELEM
#define ALLOC_ARRAY_ELEM(array, nb_elems)
Definition: cmdutils.h:445
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:947
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2858
FilterGraph::inputs
InputFilter ** inputs
Definition: ffmpeg.h:315
AVStream::discard
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition: avformat.h:1010
av_dict_count
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
Definition: dict.c:37
InputStream::dec_ctx
AVCodecContext * dec_ctx
Definition: ffmpeg.h:337
InputStream::user_set_discard
int user_set_discard
Definition: ffmpeg.h:325
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:225
av_asprintf
char * av_asprintf(const char *fmt,...)
Definition: avstring.c:116
ist_iter
InputStream * ist_iter(InputStream *prev)
Definition: ffmpeg.c:594
AVCodec::pix_fmts
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
Definition: codec.h:226
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:116
OutputFile::start_time
int64_t start_time
start time in microseconds == AV_TIME_BASE units
Definition: ffmpeg.h:642
InputFilter::ch_layout
AVChannelLayout ch_layout
Definition: ffmpeg.h:273
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
AVFilterInOut::next
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
Definition: avfilter.h:1049
pixdesc.h
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1284
init_simple_filtergraph
int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
Definition: ffmpeg_filter.c:179
w
uint8_t w
Definition: llviddspenc.c:38
av_buffersrc_add_frame
int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
Add a frame to the buffer source.
Definition: buffersrc.c:159
FilterGraph::index
int index
Definition: ffmpeg.h:306
check_filter_outputs
void check_filter_outputs(void)
Definition: ffmpeg_filter.c:648
InputStream::nb_filters
int nb_filters
Definition: ffmpeg.h:401
ffmpeg.h
FilterGraph::nb_inputs
int nb_inputs
Definition: ffmpeg.h:316
AV_FRAME_DATA_DISPLAYMATRIX
@ AV_FRAME_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: frame.h:85
filter
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
Definition: filter_design.txt:228
AVChannelLayout::order
enum AVChannelOrder order
Channel order used in this layout.
Definition: channel_layout.h:306
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilterContext::output_pads
AVFilterPad * output_pads
array of output pads
Definition: avfilter.h:426
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
InputStream::decoding_needed
int decoding_needed
Definition: ffmpeg.h:326
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:311
av_strlcatf
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
Definition: avstring.c:104
ost
static AVStream * ost
Definition: vaapi_transcode.c:45
sample_rate
sample_rate
Definition: ffmpeg_filter.c:156
av_channel_layout_describe_bprint
int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout, AVBPrint *bp)
bprint variant of av_channel_layout_describe().
Definition: channel_layout.c:732
avfilter_graph_free
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
Definition: avfiltergraph.c:119
InputFilter::ist
struct InputStream * ist
Definition: ffmpeg.h:259
OutputFile::nb_streams
int nb_streams
Definition: ffmpeg.h:637
configure_filtergraph
int configure_filtergraph(FilterGraph *fg)
Definition: ffmpeg_filter.c:962
AUTO_INSERT_FILTER
#define AUTO_INSERT_FILTER(opt_name, filter_name, arg)
av_memdup
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
Definition: mem.c:312
exit_program
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
Definition: cmdutils.c:99
InputStream
Definition: ffmpeg.h:321
filter_nbthreads
char * filter_nbthreads
Definition: ffmpeg_opt.c:86
avfilter_graph_create_filter
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
Create and add a filter instance into an existing graph.
Definition: avfiltergraph.c:138
av_buffersink_set_frame_size
void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size)
Set the frame size for an audio buffer sink.
Definition: buffersink.c:204
avfilter_graph_alloc_filter
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
Definition: avfiltergraph.c:165
AVCodecContext::codec
const struct AVCodec * codec
Definition: avcodec.h:407
AVCodecContext::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:2059
report_and_exit
void report_and_exit(int ret)
Reports an error corresponding to the provided AVERROR code and calls exit_program() with the corresp...
Definition: cmdutils.c:93
InputStream::sub2video
struct InputStream::sub2video sub2video
fail
#define fail()
Definition: checkasm.h:134
InputFilter::type
enum AVMediaType type
Definition: ffmpeg.h:262
avfilter_graph_alloc
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
Definition: avfiltergraph.c:82
AV_PIX_FMT_FLAG_HWACCEL
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:128
samplefmt.h
AVDISCARD_NONE
@ AVDISCARD_NONE
discard nothing
Definition: defs.h:70
AV_BPRINT_SIZE_AUTOMATIC
#define AV_BPRINT_SIZE_AUTOMATIC
OutputFilter::sample_rate
int sample_rate
Definition: ffmpeg.h:295
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
AV_PKT_DATA_DISPLAYMATRIX
@ AV_PKT_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: packet.h:109
av_opt_set
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:487
graph_is_meta
static int graph_is_meta(AVFilterGraph *graph)
Definition: ffmpeg_filter.c:945
InputStream::sub2video::last_pts
int64_t last_pts
Definition: ffmpeg.h:390
AVRational::num
int num
Numerator.
Definition: rational.h:59
InputFile
Definition: ffmpeg.h:434
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:49
avsubtitle_free
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
Definition: avcodec.c:409
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:104
AVFilterContext::input_pads
AVFilterPad * input_pads
array of input pads
Definition: avfilter.h:422
check_stream_specifier
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
Definition: cmdutils.c:887
OutputFile::shortest
int shortest
Definition: ffmpeg.h:644
avfilter_inout_free
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
Definition: graphparser.c:212
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_fifo_read
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
Read data from a FIFO.
Definition: fifo.c:240
duration
int64_t duration
Definition: movenc.c:64
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:60
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
OutputFilter::width
int width
Definition: ffmpeg.h:292
s
#define s(width, name)
Definition: cbs_vp9.c:256
FilterGraph::outputs
OutputFilter ** outputs
Definition: ffmpeg.h:317
InputStream::framerate
AVRational framerate
Definition: ffmpeg.h:376
configure_input_audio_filter
static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
Definition: ffmpeg_filter.c:835
format
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
AVDictionaryEntry::key
char * key
Definition: dict.h:90
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:128
AV_CHANNEL_ORDER_UNSPEC
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
Definition: channel_layout.h:112
InputFilter
Definition: ffmpeg.h:257
av_buffersink_get_format
int av_buffersink_get_format(const AVFilterContext *ctx)
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:172
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:296
OutputFilter::ost
struct OutputStream * ost
Definition: ffmpeg.h:283
OutputStream::avfilter
char * avfilter
Definition: ffmpeg.h:579
ctx
AVFormatContext * ctx
Definition: movenc.c:48
InputStream::filters
InputFilter ** filters
Definition: ffmpeg.h:400
nb_streams
static int nb_streams
Definition: ffprobe.c:308
InputFilter::graph
struct FilterGraph * graph
Definition: ffmpeg.h:260
av_get_sample_fmt_name
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.
Definition: samplefmt.c:51
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:76
AVFormatContext
Format I/O context.
Definition: avformat.h:1216
avfilter_get_by_name
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
Definition: allfilters.c:602
OutputFilter::height
int height
Definition: ffmpeg.h:292
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1108
OutputFilter::name
uint8_t * name
Definition: ffmpeg.h:285
fabs
static __device__ float fabs(float a)
Definition: cuda_runtime.h:182
avfilter_graph_config
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
Definition: avfiltergraph.c:1167
AVStream::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avformat.h:978
NULL
#define NULL
Definition: coverity.c:32
InputStream::sub2video::w
int w
Definition: ffmpeg.h:394
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
InputStream::st
AVStream * st
Definition: ffmpeg.h:323
avfilter_graph_set_auto_convert
void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags)
Enable or disable automatic format conversion inside the graph.
Definition: avfiltergraph.c:160
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
AVFilterGraph::filters
AVFilterContext ** filters
Definition: avfilter.h:880
AVFilterContext::name
char * name
name of this filter instance
Definition: avfilter.h:420
InputFilter::eof
int eof
Definition: ffmpeg.h:278
AV_CODEC_CAP_VARIABLE_FRAME_SIZE
#define AV_CODEC_CAP_VARIABLE_FRAME_SIZE
Audio encoder supports receiving a different number of samples in each call.
Definition: codec.h:134
AVFilterGraph
Definition: avfilter.h:878
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
avfilter_graph_parse2
int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs)
Add a graph described by a string to a graph.
Definition: graphparser.c:418
InputStream::sub2video::sub_queue
AVFifo * sub_queue
queue of AVSubtitle* before filter init
Definition: ffmpeg.h:392
FilterGraph::nb_outputs
int nb_outputs
Definition: ffmpeg.h:318
InputStream::sub2video::initialize
unsigned int initialize
marks if sub2video_update should force an initialization
Definition: ffmpeg.h:395
av_opt_set_int
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
Definition: opt.c:624
input_files
InputFile ** input_files
Definition: ffmpeg.c:135
OutputFile::streams
OutputStream ** streams
Definition: ffmpeg.h:636
FilterGraph
Definition: ffmpeg.h:305
AVFormatContext::nb_streams
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1272
InputFilter::filter
AVFilterContext * filter
Definition: ffmpeg.h:258
AVFilterInOut::pad_idx
int pad_idx
index of the filt_ctx pad to use for linking
Definition: avfilter.h:1046
AVFilterGraph::scale_sws_opts
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
Definition: avfilter.h:883
f
f
Definition: af_crystalizer.c:122
AVMediaType
AVMediaType
Definition: avutil.h:199
av_bprint_finalize
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:235
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:301
av_buffersrc_parameters_alloc
AVBufferSrcParameters * av_buffersrc_parameters_alloc(void)
Allocate a new AVBufferSrcParameters instance.
Definition: buffersrc.c:86
InputStream::file_index
int file_index
Definition: ffmpeg.h:322
AVFilterInOut::filter_ctx
AVFilterContext * filter_ctx
filter context associated to this input/output
Definition: avfilter.h:1043
output_files
OutputFile ** output_files
Definition: ffmpeg.c:138
avfilter_link
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
Definition: avfilter.c:148
AVBufferSrcParameters::hw_frames_ctx
AVBufferRef * hw_frames_ctx
Video with a hwaccel pixel format only.
Definition: buffersrc.h:106
start_time
static int64_t start_time
Definition: ffplay.c:331
FilterGraph::graph
AVFilterGraph * graph
Definition: ffmpeg.h:309
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
insert_trim
static int insert_trim(int64_t start_time, int64_t duration, AVFilterContext **last_filter, int *pad_idx, const char *filter_name)
Definition: ffmpeg_filter.c:355
copy_ts
int copy_ts
Definition: ffmpeg_opt.c:76
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
AVFrameSideData::data
uint8_t * data
Definition: frame.h:233
sub2video_update
void sub2video_update(InputStream *ist, int64_t heartbeat_pts, AVSubtitle *sub)
Definition: ffmpeg.c:220
AV_OPT_SEARCH_CHILDREN
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
Definition: opt.h:563
OutputFilter::filter
AVFilterContext * filter
Definition: ffmpeg.h:282
AV_PIX_FMT_RGB32
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:432
filter_is_buffersrc
static int filter_is_buffersrc(const AVFilterContext *f)
Definition: ffmpeg_filter.c:938
FF_COMPLIANCE_UNOFFICIAL
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
Definition: defs.h:61
OutputFilter::type
enum AVMediaType type
Definition: ffmpeg.h:289
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
sample_rates
sample_rates
Definition: ffmpeg_filter.c:156
avfilter_init_str
int avfilter_init_str(AVFilterContext *filter, const char *args)
Initialize a filter with the supplied parameters.
Definition: avfilter.c:929
buffersink.h
av_channel_layout_default
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
Definition: channel_layout.c:962
ifilter_parameters_from_frame
int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
Definition: ffmpeg_filter.c:1125
av_buffersink_get_w
int av_buffersink_get_w(const AVFilterContext *ctx)
bprint.h
av_buffersrc_parameters_set
int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *param)
Initialize the buffersrc or abuffersrc filter with the provided parameters.
Definition: buffersrc.c:97
DECODING_FOR_FILTER
#define DECODING_FOR_FILTER
Definition: ffmpeg.h:328
configure_input_filter
static int configure_input_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
Definition: ffmpeg_filter.c:912
choose_channel_layouts
static void choose_channel_layouts(OutputFilter *ofilter, AVBPrint *bprint)
Definition: ffmpeg_filter.c:159
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
configure_output_filter
static int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
Definition: ffmpeg_filter.c:633
AVCodecParameters::height
int height
Definition: codec_par.h:129
display.h
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
choose_pixel_fmt
static enum AVPixelFormat choose_pixel_fmt(const AVCodec *codec, enum AVPixelFormat target, int strict_std_compliance)
Definition: ffmpeg_filter.c:56
InputStream::processing_needed
int processing_needed
Definition: ffmpeg.h:329
hw_device_setup_for_filter
int hw_device_setup_for_filter(FilterGraph *fg)
Definition: ffmpeg_hw.c:551
InputFile::ctx
AVFormatContext * ctx
Definition: ffmpeg.h:437
tb
#define tb
Definition: regdef.h:68
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:264
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:211
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
init_input_filter
static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
Definition: ffmpeg_filter.c:231
filtergraphs
FilterGraph ** filtergraphs
Definition: ffmpeg.c:141
AVCodecContext::height
int height
Definition: avcodec.h:571
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:608
av_buffersink_get_h
int av_buffersink_get_h(const AVFilterContext *ctx)
AVFilter
Filter definition.
Definition: avfilter.h:171
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:948
AV_LOG_FATAL
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:174
pixfmt.h
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
InputFilter::name
uint8_t * name
Definition: ffmpeg.h:261
OutputFilter::ch_layout
AVChannelLayout ch_layout
Definition: ffmpeg.h:296
av_channel_layout_check
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
Definition: channel_layout.c:906
InputFile::streams
InputStream ** streams
Definition: ffmpeg.h:458
insert_filter
static int insert_filter(AVFilterContext **last_filter, int *pad_idx, const char *filter_name, const char *args)
Definition: ffmpeg_filter.c:406
av_stream_get_side_data
uint8_t * av_stream_get_side_data(const AVStream *st, enum AVPacketSideDataType type, size_t *size)
Get side information from stream.
Definition: avformat.c:140
av_bprintf
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:94
av_fifo_alloc2
AVFifo * av_fifo_alloc2(size_t nb_elems, size_t elem_size, unsigned int flags)
Allocate and initialize an AVFifo with a given element size.
Definition: fifo.c:47
get_compliance_normal_pix_fmts
static enum AVPixelFormat * get_compliance_normal_pix_fmts(const AVCodec *codec, const enum AVPixelFormat default_formats[])
Definition: ffmpeg_filter.c:42
InputFilter::sample_rate
int sample_rate
Definition: ffmpeg.h:272
avfilter_pad_get_type
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
Definition: avfilter.c:968
OutputFilter::format
int format
Definition: ffmpeg.h:294
configure_input_video_filter
static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
Definition: ffmpeg_filter.c:710
AVCodecContext
main external API structure.
Definition: avcodec.h:398
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:956
av_find_best_pix_fmt_of_2
enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
Compute what kind of losses will occur when converting from one specific pixel format to another.
Definition: pixdesc.c:3137
DEF_CHOOSE_FORMAT
#define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name)
Definition: ffmpeg_filter.c:130
channel_layout.h
AVBufferSrcParameters
This structure contains the parameters describing the frames that will be passed to this filter.
Definition: buffersrc.h:73
av_buffersink_get_sample_rate
int av_buffersink_get_sample_rate(const AVFilterContext *ctx)
InputFilter::format
int format
Definition: ffmpeg.h:267
AVBufferSrcParameters::format
int format
video: the pixel format, value corresponds to enum AVPixelFormat audio: the sample format,...
Definition: buffersrc.h:78
describe_filter_link
static char * describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in)
Definition: ffmpeg_filter.c:214
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
avfilter.h
av_bprint_clear
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
Definition: bprint.c:227
av_channel_layout_uninit
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
Definition: channel_layout.c:632
FilterGraph::is_meta
int is_meta
Definition: ffmpeg.h:313
AVFILTER_FLAG_METADATA_ONLY
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition: avfilter.h:143
InputFilter::height
int height
Definition: ffmpeg.h:269
GROW_ARRAY
#define GROW_ARRAY(array, nb_elems)
Definition: cmdutils.h:442
AVERROR_FILTER_NOT_FOUND
#define AVERROR_FILTER_NOT_FOUND
Filter not found.
Definition: error.h:60
InputStream::discard
int discard
Definition: ffmpeg.h:324
AVFilterContext
An instance of a filter.
Definition: avfilter.h:415
av_channel_layout_copy
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
Definition: channel_layout.c:639
OutputFilter
Definition: ffmpeg.h:281
cleanup_filtergraph
static void cleanup_filtergraph(FilterGraph *fg)
Definition: ffmpeg_filter.c:928
InputStream::sub2video::frame
AVFrame * frame
Definition: ffmpeg.h:393
AVERROR_DECODER_NOT_FOUND
#define AVERROR_DECODER_NOT_FOUND
Decoder not found.
Definition: error.h:54
AVCodecContext::codec_type
enum AVMediaType codec_type
Definition: avcodec.h:406
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:280
desc
const char * desc
Definition: libsvtav1.c:83
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
start_at_zero
int start_at_zero
Definition: ffmpeg_opt.c:77
OutputFilter::out_tmp
AVFilterInOut * out_tmp
Definition: ffmpeg.h:288
auto_conversion_filters
int auto_conversion_filters
Definition: ffmpeg_opt.c:89
InputStream::sub2video::h
int h
Definition: ffmpeg.h:394
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:231
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
OutputStream::autoscale
int autoscale
Definition: ffmpeg.h:558
InputFilter::hw_frames_ctx
AVBufferRef * hw_frames_ctx
Definition: ffmpeg.h:275
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
AVDictionaryEntry
Definition: dict.h:89
InputStream::sub2video::end_pts
int64_t end_pts
Definition: ffmpeg.h:391
choose_pix_fmts
static const char * choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint)
Definition: ffmpeg_filter.c:90
FilterGraph::reconfiguration
int reconfiguration
Definition: ffmpeg.h:310
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
av_dict_get_string
int av_dict_get_string(const AVDictionary *m, char **buffer, const char key_val_sep, const char pairs_sep)
Get dictionary entries as a string.
Definition: dict.c:250
filtergraph_is_simple
int filtergraph_is_simple(FilterGraph *fg)
Definition: ffmpeg_filter.c:1157
InputFilter::frame_queue
AVFifo * frame_queue
Definition: ffmpeg.h:264
nb_filtergraphs
int nb_filtergraphs
Definition: ffmpeg.c:142
AVFilterInOut::name
char * name
unique name for this input/output in the list
Definition: avfilter.h:1040
d
d
Definition: ffmpeg_filter.c:156
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:571
int32_t
int32_t
Definition: audioconvert.c:56
imgutils.h
OutputStream
Definition: muxing.c:54
OutputStream::st
AVStream * st
Definition: muxing.c:55
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
configure_output_video_filter
static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
Definition: ffmpeg_filter.c:428
h
h
Definition: vp9dsp_template.c:2038
av_bprint_chars
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
Definition: bprint.c:140
AVFILTER_AUTO_CONVERT_NONE
@ AVFILTER_AUTO_CONVERT_NONE
all automatic conversions disabled
Definition: avfilter.h:1011
AVDictionaryEntry::value
char * value
Definition: dict.h:91
AVFilterGraph::nb_filters
unsigned nb_filters
Definition: avfilter.h:881
get_rotation
double get_rotation(int32_t *displaymatrix)
Definition: cmdutils.c:997
avstring.h
OutputFile::recording_time
int64_t recording_time
desired length of the resulting file in microseconds == AV_TIME_BASE units
Definition: ffmpeg.h:641
AVFilterInOut
A linked-list of the inputs/outputs of the filter chain.
Definition: avfilter.h:1038
InputStream::dec
const AVCodec * dec
Definition: ffmpeg.h:338
snprintf
#define snprintf
Definition: snprintf.h:34
buffersrc.h
av_dict_iterate
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition: dict.c:42
configure_output_audio_filter
static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
Definition: ffmpeg_filter.c:522
AV_FIFO_FLAG_AUTO_GROW
#define AV_FIFO_FLAG_AUTO_GROW
Automatically resize the FIFO on writes, so that the data fits.
Definition: fifo.h:67
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:2778
filter_complex_nbthreads
int filter_complex_nbthreads
Definition: ffmpeg_opt.c:87
OutputFile
Definition: ffmpeg.h:630
sub2video_prepare
static int sub2video_prepare(InputStream *ist, InputFilter *ifilter)
Definition: ffmpeg_filter.c:663
InputStream::autorotate
int autorotate
Definition: ffmpeg.h:380