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  const AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
94  if (strict_dict)
95  // used by choose_pixel_fmt() and below
96  av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0);
97 
98  if (ost->keep_pix_fmt) {
101  if (ost->enc_ctx->pix_fmt == AV_PIX_FMT_NONE)
102  return NULL;
103  return av_get_pix_fmt_name(ost->enc_ctx->pix_fmt);
104  }
105  if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
106  return av_get_pix_fmt_name(choose_pixel_fmt(ost->enc, ost->enc_ctx->pix_fmt,
107  ost->enc_ctx->strict_std_compliance));
108  } else if (ost->enc && ost->enc->pix_fmts) {
109  const enum AVPixelFormat *p;
110 
111  p = ost->enc->pix_fmts;
112  if (ost->enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
113  p = get_compliance_normal_pix_fmts(ost->enc, p);
114  }
115 
116  for (; *p != AV_PIX_FMT_NONE; p++) {
117  const char *name = av_get_pix_fmt_name(*p);
118  av_bprintf(bprint, "%s%c", name, p[1] == AV_PIX_FMT_NONE ? '\0' : '|');
119  }
120  if (!av_bprint_is_complete(bprint))
121  exit_program(1);
122  return bprint->str;
123  } else
124  return NULL;
125 }
126 
127 /* Define a function for appending a list of allowed formats
128  * to an AVBPrint. If nonempty, the list will have a header. */
129 #define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name) \
130 static void choose_ ## name (OutputFilter *ofilter, AVBPrint *bprint) \
131 { \
132  if (ofilter->var == none && !ofilter->supported_list) \
133  return; \
134  av_bprintf(bprint, #name "="); \
135  if (ofilter->var != none) { \
136  av_bprintf(bprint, printf_format, get_name(ofilter->var)); \
137  } else { \
138  const type *p; \
139  \
140  for (p = ofilter->supported_list; *p != none; p++) { \
141  av_bprintf(bprint, printf_format "|", get_name(*p)); \
142  } \
143  if (bprint->len > 0) \
144  bprint->str[--bprint->len] = '\0'; \
145  } \
146  av_bprint_chars(bprint, ':', 1); \
147 }
148 
149 //DEF_CHOOSE_FORMAT(pix_fmts, enum AVPixelFormat, format, formats, AV_PIX_FMT_NONE,
150 // GET_PIX_FMT_NAME)
151 
154 
156  "%d", )
157 
158 static void choose_channel_layouts(OutputFilter *ofilter, AVBPrint *bprint)
159 {
160  if (av_channel_layout_check(&ofilter->ch_layout)) {
161  av_bprintf(bprint, "channel_layouts=");
162  av_channel_layout_describe_bprint(&ofilter->ch_layout, bprint);
163  } else if (ofilter->ch_layouts) {
164  const AVChannelLayout *p;
165 
166  av_bprintf(bprint, "channel_layouts=");
167  for (p = ofilter->ch_layouts; p->nb_channels; p++) {
169  av_bprintf(bprint, "|");
170  }
171  if (bprint->len > 0)
172  bprint->str[--bprint->len] = '\0';
173  } else
174  return;
175  av_bprint_chars(bprint, ':', 1);
176 }
177 
179 {
180  FilterGraph *fg = av_mallocz(sizeof(*fg));
181  OutputFilter *ofilter;
182  InputFilter *ifilter;
183 
184  if (!fg)
185  exit_program(1);
186  fg->index = nb_filtergraphs;
187 
188  ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
189  ofilter->ost = ost;
190  ofilter->graph = fg;
191  ofilter->format = -1;
192 
193  ost->filter = ofilter;
194 
195  ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
196  ifilter->ist = ist;
197  ifilter->graph = fg;
198  ifilter->format = -1;
199 
200  ifilter->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW);
201  if (!ifilter->frame_queue)
202  exit_program(1);
203 
204  GROW_ARRAY(ist->filters, ist->nb_filters);
205  ist->filters[ist->nb_filters - 1] = ifilter;
206 
208  filtergraphs[nb_filtergraphs - 1] = fg;
209 
210  return 0;
211 }
212 
213 static char *describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in)
214 {
215  AVFilterContext *ctx = inout->filter_ctx;
216  AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads;
217  int nb_pads = in ? ctx->nb_inputs : ctx->nb_outputs;
218  char *res;
219 
220  if (nb_pads > 1)
221  res = av_strdup(ctx->filter->name);
222  else
223  res = av_asprintf("%s:%s", ctx->filter->name,
224  avfilter_pad_get_name(pads, inout->pad_idx));
225  if (!res)
226  exit_program(1);
227  return res;
228 }
229 
231 {
232  InputStream *ist = NULL;
234  InputFilter *ifilter;
235  int i;
236 
237  // TODO: support other filter types
239  av_log(NULL, AV_LOG_FATAL, "Only video and audio filters supported "
240  "currently.\n");
241  exit_program(1);
242  }
243 
244  if (in->name) {
246  AVStream *st = NULL;
247  char *p;
248  int file_idx = strtol(in->name, &p, 0);
249 
250  if (file_idx < 0 || file_idx >= nb_input_files) {
251  av_log(NULL, AV_LOG_FATAL, "Invalid file index %d in filtergraph description %s.\n",
252  file_idx, fg->graph_desc);
253  exit_program(1);
254  }
255  s = input_files[file_idx]->ctx;
256 
257  for (i = 0; i < s->nb_streams; i++) {
258  enum AVMediaType stream_type = s->streams[i]->codecpar->codec_type;
259  if (stream_type != type &&
260  !(stream_type == AVMEDIA_TYPE_SUBTITLE &&
261  type == AVMEDIA_TYPE_VIDEO /* sub2video hack */))
262  continue;
263  if (check_stream_specifier(s, s->streams[i], *p == ':' ? p + 1 : p) == 1) {
264  st = s->streams[i];
265  break;
266  }
267  }
268  if (!st) {
269  av_log(NULL, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s "
270  "matches no streams.\n", p, fg->graph_desc);
271  exit_program(1);
272  }
273  ist = input_streams[input_files[file_idx]->ist_index + st->index];
274  if (ist->user_set_discard == AVDISCARD_ALL) {
275  av_log(NULL, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s "
276  "matches a disabled input stream.\n", p, fg->graph_desc);
277  exit_program(1);
278  }
279  } else {
280  /* find the first unused stream of corresponding type */
281  for (i = 0; i < nb_input_streams; i++) {
282  ist = input_streams[i];
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 (i == nb_input_streams) {
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  exit_program(1);
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_get(ost->sws_dict, "", e,
457  av_strlcatf(args, sizeof(args), ":%s=%s", e->key, e->value);
458  }
459 
460  snprintf(name, sizeof(name), "scaler_out_%d_%d",
461  ost->file_index, ost->index);
463  name, args, NULL, fg->graph)) < 0)
464  return ret;
465  if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
466  return ret;
467 
468  last_filter = filter;
469  pad_idx = 0;
470  }
471 
473  if ((pix_fmts = choose_pix_fmts(ofilter, &bprint))) {
475 
477  avfilter_get_by_name("format"),
478  "format", pix_fmts, NULL, fg->graph);
479  av_bprint_finalize(&bprint, NULL);
480  if (ret < 0)
481  return ret;
482  if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
483  return ret;
484 
485  last_filter = filter;
486  pad_idx = 0;
487  }
488 
489  if (ost->frame_rate.num && 0) {
490  AVFilterContext *fps;
491  char args[255];
492 
493  snprintf(args, sizeof(args), "fps=%d/%d", ost->frame_rate.num,
494  ost->frame_rate.den);
495  snprintf(name, sizeof(name), "fps_out_%d_%d",
496  ost->file_index, ost->index);
498  name, args, NULL, fg->graph);
499  if (ret < 0)
500  return ret;
501 
502  ret = avfilter_link(last_filter, pad_idx, fps, 0);
503  if (ret < 0)
504  return ret;
505  last_filter = fps;
506  pad_idx = 0;
507  }
508 
509  snprintf(name, sizeof(name), "trim_out_%d_%d",
510  ost->file_index, ost->index);
512  &last_filter, &pad_idx, name);
513  if (ret < 0)
514  return ret;
515 
516 
517  if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0)
518  return ret;
519 
520  return 0;
521 }
522 
524 {
525  OutputStream *ost = ofilter->ost;
526  OutputFile *of = output_files[ost->file_index];
527  AVCodecContext *codec = ost->enc_ctx;
528  AVFilterContext *last_filter = out->filter_ctx;
529  int pad_idx = out->pad_idx;
530  AVBPrint args;
531  char name[255];
532  int ret;
533 
534  snprintf(name, sizeof(name), "out_%d_%d", ost->file_index, ost->index);
536  avfilter_get_by_name("abuffersink"),
537  name, NULL, NULL, fg->graph);
538  if (ret < 0)
539  return ret;
540  if ((ret = av_opt_set_int(ofilter->filter, "all_channel_counts", 1, AV_OPT_SEARCH_CHILDREN)) < 0)
541  return ret;
542 
543 #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \
544  AVFilterContext *filt_ctx; \
545  \
546  av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
547  "similarly to -af " filter_name "=%s.\n", arg); \
548  \
549  ret = avfilter_graph_create_filter(&filt_ctx, \
550  avfilter_get_by_name(filter_name), \
551  filter_name, arg, NULL, fg->graph); \
552  if (ret < 0) \
553  goto fail; \
554  \
555  ret = avfilter_link(last_filter, pad_idx, filt_ctx, 0); \
556  if (ret < 0) \
557  goto fail; \
558  \
559  last_filter = filt_ctx; \
560  pad_idx = 0; \
561 } while (0)
563 #if FFMPEG_OPT_MAP_CHANNEL
564  if (ost->audio_channels_mapped) {
565  AVChannelLayout mapped_layout = { 0 };
566  int i;
567  av_channel_layout_default(&mapped_layout, ost->audio_channels_mapped);
568  av_channel_layout_describe_bprint(&mapped_layout, &args);
569  for (i = 0; i < ost->audio_channels_mapped; i++)
570  if (ost->audio_channels_map[i] != -1)
571  av_bprintf(&args, "|c%d=c%d", i, ost->audio_channels_map[i]);
572 
573  AUTO_INSERT_FILTER("-map_channel", "pan", args.str);
574  av_bprint_clear(&args);
575  }
576 #endif
577 
580 
581  choose_sample_fmts(ofilter, &args);
582  choose_sample_rates(ofilter, &args);
583  choose_channel_layouts(ofilter, &args);
584  if (!av_bprint_is_complete(&args)) {
585  ret = AVERROR(ENOMEM);
586  goto fail;
587  }
588  if (args.len) {
590 
591  snprintf(name, sizeof(name), "format_out_%d_%d",
592  ost->file_index, ost->index);
594  avfilter_get_by_name("aformat"),
595  name, args.str, NULL, fg->graph);
596  if (ret < 0)
597  goto fail;
598 
599  ret = avfilter_link(last_filter, pad_idx, format, 0);
600  if (ret < 0)
601  goto fail;
602 
603  last_filter = format;
604  pad_idx = 0;
605  }
606 
607  if (ost->apad && of->shortest) {
608  int i;
609 
610  for (i = 0; i < of->nb_streams; i++)
612  break;
613 
614  if (i < of->nb_streams) {
615  AUTO_INSERT_FILTER("-apad", "apad", ost->apad);
616  }
617  }
618 
619  snprintf(name, sizeof(name), "trim for output stream %d:%d",
620  ost->file_index, ost->index);
622  &last_filter, &pad_idx, name);
623  if (ret < 0)
624  goto fail;
625 
626  if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0)
627  goto fail;
628 fail:
629  av_bprint_finalize(&args, NULL);
630 
631  return ret;
632 }
633 
636 {
637  if (!ofilter->ost) {
638  av_log(NULL, AV_LOG_FATAL, "Filter %s has an unconnected output\n", ofilter->name);
639  exit_program(1);
640  }
641 
642  switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) {
643  case AVMEDIA_TYPE_VIDEO: return configure_output_video_filter(fg, ofilter, out);
644  case AVMEDIA_TYPE_AUDIO: return configure_output_audio_filter(fg, ofilter, out);
645  default: av_assert0(0); return 0;
646  }
647 }
648 
650 {
651  int i;
652  for (i = 0; i < nb_filtergraphs; i++) {
653  int n;
654  for (n = 0; n < filtergraphs[i]->nb_outputs; n++) {
656  if (!output->ost) {
657  av_log(NULL, AV_LOG_FATAL, "Filter %s has an unconnected output\n", output->name);
658  exit_program(1);
659  }
660  }
661  }
662 }
663 
664 static int sub2video_prepare(InputStream *ist, InputFilter *ifilter)
665 {
667  int i, w, h;
668 
669  /* Compute the size of the canvas for the subtitles stream.
670  If the subtitles codecpar has set a size, use it. Otherwise use the
671  maximum dimensions of the video streams in the same file. */
672  w = ifilter->width;
673  h = ifilter->height;
674  if (!(w && h)) {
675  for (i = 0; i < avf->nb_streams; i++) {
677  w = FFMAX(w, avf->streams[i]->codecpar->width);
678  h = FFMAX(h, avf->streams[i]->codecpar->height);
679  }
680  }
681  if (!(w && h)) {
682  w = FFMAX(w, 720);
683  h = FFMAX(h, 576);
684  }
685  av_log(avf, AV_LOG_INFO, "sub2video: using %dx%d canvas\n", w, h);
686  }
687  ist->sub2video.w = ifilter->width = w;
688  ist->sub2video.h = ifilter->height = h;
689 
690  ifilter->width = ist->dec_ctx->width ? ist->dec_ctx->width : ist->sub2video.w;
691  ifilter->height = ist->dec_ctx->height ? ist->dec_ctx->height : ist->sub2video.h;
692 
693  /* rectangles are AV_PIX_FMT_PAL8, but we have no guarantee that the
694  palettes for all rectangles are identical or compatible */
695  ifilter->format = AV_PIX_FMT_RGB32;
696 
697  ist->sub2video.frame = av_frame_alloc();
698  if (!ist->sub2video.frame)
699  return AVERROR(ENOMEM);
700  ist->sub2video.last_pts = INT64_MIN;
701  ist->sub2video.end_pts = INT64_MIN;
702 
703  /* sub2video structure has been (re-)initialized.
704  Mark it as such so that the system will be
705  initialized with the first received heartbeat. */
706  ist->sub2video.initialize = 1;
707 
708  return 0;
709 }
710 
712  AVFilterInOut *in)
713 {
714  AVFilterContext *last_filter;
715  const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
716  const AVPixFmtDescriptor *desc;
717  InputStream *ist = ifilter->ist;
719  AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
720  ist->st->time_base;
721  AVRational fr = ist->framerate;
722  AVRational sar;
723  AVBPrint args;
724  char name[255];
725  int ret, pad_idx = 0;
726  int64_t tsoffset = 0;
728 
729  if (!par)
730  return AVERROR(ENOMEM);
731  memset(par, 0, sizeof(*par));
732  par->format = AV_PIX_FMT_NONE;
733 
734  if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
735  av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n");
736  ret = AVERROR(EINVAL);
737  goto fail;
738  }
739 
740  if (!fr.num)
741  fr = av_guess_frame_rate(input_files[ist->file_index]->ctx, ist->st, NULL);
742 
744  ret = sub2video_prepare(ist, ifilter);
745  if (ret < 0)
746  goto fail;
747  }
748 
749  sar = ifilter->sample_aspect_ratio;
750  if(!sar.den)
751  sar = (AVRational){0,1};
753  av_bprintf(&args,
754  "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:"
755  "pixel_aspect=%d/%d",
756  ifilter->width, ifilter->height, ifilter->format,
757  tb.num, tb.den, sar.num, sar.den);
758  if (fr.num && fr.den)
759  av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den);
760  snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
761  ist->file_index, ist->st->index);
762 
763 
764  if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name,
765  args.str, NULL, fg->graph)) < 0)
766  goto fail;
767  par->hw_frames_ctx = ifilter->hw_frames_ctx;
768  ret = av_buffersrc_parameters_set(ifilter->filter, par);
769  if (ret < 0)
770  goto fail;
771  av_freep(&par);
772  last_filter = ifilter->filter;
773 
774  desc = av_pix_fmt_desc_get(ifilter->format);
775  av_assert0(desc);
776 
777  // TODO: insert hwaccel enabled filters like transpose_vaapi into the graph
778  if (ist->autorotate && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
779  int32_t *displaymatrix = ifilter->displaymatrix;
780  double theta;
781 
782  if (!displaymatrix)
784  theta = get_rotation(displaymatrix);
785 
786  if (fabs(theta - 90) < 1.0) {
787  ret = insert_filter(&last_filter, &pad_idx, "transpose",
788  displaymatrix[3] > 0 ? "cclock_flip" : "clock");
789  } else if (fabs(theta - 180) < 1.0) {
790  if (displaymatrix[0] < 0) {
791  ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL);
792  if (ret < 0)
793  return ret;
794  }
795  if (displaymatrix[4] < 0) {
796  ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
797  }
798  } else if (fabs(theta - 270) < 1.0) {
799  ret = insert_filter(&last_filter, &pad_idx, "transpose",
800  displaymatrix[3] < 0 ? "clock_flip" : "cclock");
801  } else if (fabs(theta) > 1.0) {
802  char rotate_buf[64];
803  snprintf(rotate_buf, sizeof(rotate_buf), "%f*PI/180", theta);
804  ret = insert_filter(&last_filter, &pad_idx, "rotate", rotate_buf);
805  } else if (fabs(theta) < 1.0) {
806  if (displaymatrix && displaymatrix[4] < 0) {
807  ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
808  }
809  }
810  if (ret < 0)
811  return ret;
812  }
813 
814  snprintf(name, sizeof(name), "trim_in_%d_%d",
815  ist->file_index, ist->st->index);
816  if (copy_ts) {
817  tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
818  if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
819  tsoffset += f->ctx->start_time;
820  }
821  ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?
822  AV_NOPTS_VALUE : tsoffset, f->recording_time,
823  &last_filter, &pad_idx, name);
824  if (ret < 0)
825  return ret;
826 
827  if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0)
828  return ret;
829  return 0;
830 fail:
831  av_freep(&par);
832 
833  return ret;
834 }
835 
837  AVFilterInOut *in)
838 {
839  AVFilterContext *last_filter;
840  const AVFilter *abuffer_filt = avfilter_get_by_name("abuffer");
841  InputStream *ist = ifilter->ist;
843  AVBPrint args;
844  char name[255];
845  int ret, pad_idx = 0;
846  int64_t tsoffset = 0;
847 
848  if (ist->dec_ctx->codec_type != AVMEDIA_TYPE_AUDIO) {
849  av_log(NULL, AV_LOG_ERROR, "Cannot connect audio filter to non audio input\n");
850  return AVERROR(EINVAL);
851  }
852 
854  av_bprintf(&args, "time_base=%d/%d:sample_rate=%d:sample_fmt=%s",
855  1, ifilter->sample_rate,
856  ifilter->sample_rate,
857  av_get_sample_fmt_name(ifilter->format));
858  if (av_channel_layout_check(&ifilter->ch_layout) &&
860  av_bprintf(&args, ":channel_layout=");
862  } else
863  av_bprintf(&args, ":channels=%d", ifilter->ch_layout.nb_channels);
864  snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index,
865  ist->file_index, ist->st->index);
866 
867  if ((ret = avfilter_graph_create_filter(&ifilter->filter, abuffer_filt,
868  name, args.str, NULL,
869  fg->graph)) < 0)
870  return ret;
871  last_filter = ifilter->filter;
872 
873 #define AUTO_INSERT_FILTER_INPUT(opt_name, filter_name, arg) do { \
874  AVFilterContext *filt_ctx; \
875  \
876  av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
877  "similarly to -af " filter_name "=%s.\n", arg); \
878  \
879  snprintf(name, sizeof(name), "graph_%d_%s_in_%d_%d", \
880  fg->index, filter_name, ist->file_index, ist->st->index); \
881  ret = avfilter_graph_create_filter(&filt_ctx, \
882  avfilter_get_by_name(filter_name), \
883  name, arg, NULL, fg->graph); \
884  if (ret < 0) \
885  return ret; \
886  \
887  ret = avfilter_link(last_filter, 0, filt_ctx, 0); \
888  if (ret < 0) \
889  return ret; \
890  \
891  last_filter = filt_ctx; \
892 } while (0)
893 
894  if (audio_sync_method > 0) {
895  char args[256] = {0};
896 
897  av_strlcatf(args, sizeof(args), "async=%d", audio_sync_method);
898  if (audio_drift_threshold != 0.1)
899  av_strlcatf(args, sizeof(args), ":min_hard_comp=%f", audio_drift_threshold);
900  if (!fg->reconfiguration)
901  av_strlcatf(args, sizeof(args), ":first_pts=0");
902  AUTO_INSERT_FILTER_INPUT("-async", "aresample", args);
903  }
904 
905  snprintf(name, sizeof(name), "trim for input stream %d:%d",
906  ist->file_index, ist->st->index);
907  if (copy_ts) {
908  tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
909  if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
910  tsoffset += f->ctx->start_time;
911  }
912  ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?
913  AV_NOPTS_VALUE : tsoffset, f->recording_time,
914  &last_filter, &pad_idx, name);
915  if (ret < 0)
916  return ret;
917 
918  if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0)
919  return ret;
920 
921  return 0;
922 }
923 
925  AVFilterInOut *in)
926 {
927  if (!ifilter->ist->dec) {
929  "No decoder for stream #%d:%d, filtering impossible\n",
930  ifilter->ist->file_index, ifilter->ist->st->index);
932  }
933  switch (avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx)) {
934  case AVMEDIA_TYPE_VIDEO: return configure_input_video_filter(fg, ifilter, in);
935  case AVMEDIA_TYPE_AUDIO: return configure_input_audio_filter(fg, ifilter, in);
936  default: av_assert0(0); return 0;
937  }
938 }
939 
941 {
942  int i;
943  for (i = 0; i < fg->nb_outputs; i++)
944  fg->outputs[i]->filter = (AVFilterContext *)NULL;
945  for (i = 0; i < fg->nb_inputs; i++)
946  fg->inputs[i]->filter = (AVFilterContext *)NULL;
948 }
949 
951 {
952  return f->nb_inputs == 0 &&
953  (!strcmp(f->filter->name, "buffer") ||
954  !strcmp(f->filter->name, "abuffer"));
955 }
956 
957 static int graph_is_meta(AVFilterGraph *graph)
958 {
959  for (unsigned i = 0; i < graph->nb_filters; i++) {
960  const AVFilterContext *f = graph->filters[i];
961 
962  /* in addition to filters flagged as meta, also
963  * disregard sinks and buffersources (but not other sources,
964  * since they introduce data we are not aware of)
965  */
966  if (!((f->filter->flags & AVFILTER_FLAG_METADATA_ONLY) ||
967  f->nb_outputs == 0 ||
969  return 0;
970  }
971  return 1;
972 }
973 
975 {
976  AVFilterInOut *inputs, *outputs, *cur;
977  int ret, i, simple = filtergraph_is_simple(fg);
978  const char *graph_desc = simple ? fg->outputs[0]->ost->avfilter :
979  fg->graph_desc;
980 
982  if (!(fg->graph = avfilter_graph_alloc()))
983  return AVERROR(ENOMEM);
984 
985  if (simple) {
986  OutputStream *ost = fg->outputs[0]->ost;
987  char args[512];
988  const AVDictionaryEntry *e = NULL;
989 
990  if (filter_nbthreads) {
991  ret = av_opt_set(fg->graph, "threads", filter_nbthreads, 0);
992  if (ret < 0)
993  goto fail;
994  } else {
995  e = av_dict_get(ost->encoder_opts, "threads", NULL, 0);
996  if (e)
997  av_opt_set(fg->graph, "threads", e->value, 0);
998  }
999 
1000  args[0] = 0;
1001  e = NULL;
1002  while ((e = av_dict_get(ost->sws_dict, "", e,
1004  av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
1005  }
1006  if (strlen(args)) {
1007  args[strlen(args)-1] = 0;
1008  fg->graph->scale_sws_opts = av_strdup(args);
1009  }
1010 
1011  args[0] = 0;
1012  e = NULL;
1013  while ((e = av_dict_get(ost->swr_opts, "", e,
1015  av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
1016  }
1017  if (strlen(args))
1018  args[strlen(args)-1] = 0;
1019  av_opt_set(fg->graph, "aresample_swr_opts", args, 0);
1020  } else {
1022  }
1023 
1024  if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, &outputs)) < 0)
1025  goto fail;
1026 
1028  if (ret < 0)
1029  goto fail;
1030 
1031  if (simple && (!inputs || inputs->next || !outputs || outputs->next)) {
1032  const char *num_inputs;
1033  const char *num_outputs;
1034  if (!outputs) {
1035  num_outputs = "0";
1036  } else if (outputs->next) {
1037  num_outputs = ">1";
1038  } else {
1039  num_outputs = "1";
1040  }
1041  if (!inputs) {
1042  num_inputs = "0";
1043  } else if (inputs->next) {
1044  num_inputs = ">1";
1045  } else {
1046  num_inputs = "1";
1047  }
1048  av_log(NULL, AV_LOG_ERROR, "Simple filtergraph '%s' was expected "
1049  "to have exactly 1 input and 1 output."
1050  " However, it had %s input(s) and %s output(s)."
1051  " Please adjust, or use a complex filtergraph (-filter_complex) instead.\n",
1052  graph_desc, num_inputs, num_outputs);
1053  ret = AVERROR(EINVAL);
1054  goto fail;
1055  }
1056 
1057  for (cur = inputs, i = 0; cur; cur = cur->next, i++)
1058  if ((ret = configure_input_filter(fg, fg->inputs[i], cur)) < 0) {
1061  goto fail;
1062  }
1064 
1065  for (cur = outputs, i = 0; cur; cur = cur->next, i++)
1066  configure_output_filter(fg, fg->outputs[i], cur);
1068 
1071  if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
1072  goto fail;
1073 
1074  fg->is_meta = graph_is_meta(fg->graph);
1075 
1076  /* limit the lists of allowed formats to the ones selected, to
1077  * make sure they stay the same if the filtergraph is reconfigured later */
1078  for (i = 0; i < fg->nb_outputs; i++) {
1079  OutputFilter *ofilter = fg->outputs[i];
1080  AVFilterContext *sink = ofilter->filter;
1081 
1082  ofilter->format = av_buffersink_get_format(sink);
1083 
1084  ofilter->width = av_buffersink_get_w(sink);
1085  ofilter->height = av_buffersink_get_h(sink);
1086 
1087  ofilter->sample_rate = av_buffersink_get_sample_rate(sink);
1089  ret = av_buffersink_get_ch_layout(sink, &ofilter->ch_layout);
1090  if (ret < 0)
1091  goto fail;
1092  }
1093 
1094  fg->reconfiguration = 1;
1095 
1096  for (i = 0; i < fg->nb_outputs; i++) {
1097  OutputStream *ost = fg->outputs[i]->ost;
1098  if (!ost->enc) {
1099  /* identical to the same check in ffmpeg.c, needed because
1100  complex filter graphs are initialized earlier */
1101  av_log(NULL, AV_LOG_ERROR, "Encoder (codec %s) not found for output stream #%d:%d\n",
1102  avcodec_get_name(ost->st->codecpar->codec_id), ost->file_index, ost->index);
1103  ret = AVERROR(EINVAL);
1104  goto fail;
1105  }
1106  if (ost->enc->type == AVMEDIA_TYPE_AUDIO &&
1107  !(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE))
1108  av_buffersink_set_frame_size(ost->filter->filter,
1109  ost->enc_ctx->frame_size);
1110  }
1111 
1112  for (i = 0; i < fg->nb_inputs; i++) {
1113  AVFrame *tmp;
1114  while (av_fifo_read(fg->inputs[i]->frame_queue, &tmp, 1) >= 0) {
1116  av_frame_free(&tmp);
1117  if (ret < 0)
1118  goto fail;
1119  }
1120  }
1121 
1122  /* send the EOFs for the finished inputs */
1123  for (i = 0; i < fg->nb_inputs; i++) {
1124  if (fg->inputs[i]->eof) {
1126  if (ret < 0)
1127  goto fail;
1128  }
1129  }
1130 
1131  /* process queued up subtitle packets */
1132  for (i = 0; i < fg->nb_inputs; i++) {
1133  InputStream *ist = fg->inputs[i]->ist;
1134  if (ist->sub2video.sub_queue && ist->sub2video.frame) {
1135  AVSubtitle tmp;
1136  while (av_fifo_read(ist->sub2video.sub_queue, &tmp, 1) >= 0) {
1137  sub2video_update(ist, INT64_MIN, &tmp);
1138  avsubtitle_free(&tmp);
1139  }
1140  }
1141  }
1142 
1143  return 0;
1144 
1145 fail:
1146  cleanup_filtergraph(fg);
1147  return ret;
1148 }
1149 
1151 {
1152  AVFrameSideData *sd;
1153  int ret;
1154 
1155  av_buffer_unref(&ifilter->hw_frames_ctx);
1156 
1157  ifilter->format = frame->format;
1158 
1159  ifilter->width = frame->width;
1160  ifilter->height = frame->height;
1161  ifilter->sample_aspect_ratio = frame->sample_aspect_ratio;
1162 
1163  ifilter->sample_rate = frame->sample_rate;
1164  ret = av_channel_layout_copy(&ifilter->ch_layout, &frame->ch_layout);
1165  if (ret < 0)
1166  return ret;
1167 
1168  av_freep(&ifilter->displaymatrix);
1170  if (sd)
1171  ifilter->displaymatrix = av_memdup(sd->data, sizeof(int32_t) * 9);
1172 
1173  if (frame->hw_frames_ctx) {
1174  ifilter->hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);
1175  if (!ifilter->hw_frames_ctx)
1176  return AVERROR(ENOMEM);
1177  }
1178 
1179  return 0;
1180 }
1181 
1183 {
1184  return !fg->graph_desc;
1185 }
AVSubtitle
Definition: avcodec.h:2314
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:265
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
audio_sync_method
int audio_sync_method
Definition: ffmpeg_opt.c:160
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:279
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:147
opt.h
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:57
AVFilterGraph::nb_threads
int nb_threads
Maximum number of threads used by filters in this graph.
Definition: avfilter.h:897
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:953
InputFilter::width
int width
Definition: ffmpeg.h:264
av_bprint_finalize
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:235
InputFilter::displaymatrix
int32_t * displaymatrix
Definition: ffmpeg.h:271
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:302
ALLOC_ARRAY_ELEM
#define ALLOC_ARRAY_ELEM(array, nb_elems)
Definition: cmdutils.h:434
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:2675
FilterGraph::inputs
InputFilter ** inputs
Definition: ffmpeg.h:310
AVStream::discard
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition: avformat.h:1010
InputStream::dec_ctx
AVCodecContext * dec_ctx
Definition: ffmpeg.h:326
InputStream::user_set_discard
int user_set_discard
Definition: ffmpeg.h:320
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
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:609
InputFilter::ch_layout
AVChannelLayout ch_layout
Definition: ffmpeg.h:268
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:1042
pixdesc.h
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1281
init_simple_filtergraph
int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
Definition: ffmpeg_filter.c:178
w
uint8_t w
Definition: llviddspenc.c:38
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:58
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:301
check_filter_outputs
void check_filter_outputs(void)
Definition: ffmpeg_filter.c:649
InputStream::nb_filters
int nb_filters
Definition: ffmpeg.h:382
AV_DICT_IGNORE_SUFFIX
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
Definition: dict.h:68
ffmpeg.h
FilterGraph::nb_inputs
int nb_inputs
Definition: ffmpeg.h:311
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
av_fifo_read
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
Read data from a FIFO.
Definition: fifo.c:240
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:295
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilterContext::output_pads
AVFilterPad * output_pads
array of output pads
Definition: avfilter.h:419
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:321
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:300
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:155
FF_COMPLIANCE_UNOFFICIAL
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
Definition: avcodec.h:1313
avfilter_graph_free
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
Definition: avfiltergraph.c:119
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:637
InputFilter::ist
struct InputStream * ist
Definition: ffmpeg.h:254
OutputFile::nb_streams
int nb_streams
Definition: ffmpeg.h:606
configure_filtergraph
int configure_filtergraph(FilterGraph *fg)
Definition: ffmpeg_filter.c:974
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:93
InputStream
Definition: ffmpeg.h:316
filter_nbthreads
char * filter_nbthreads
Definition: ffmpeg_opt.c:177
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::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:2065
InputStream::sub2video
struct InputStream::sub2video sub2video
fail
#define fail()
Definition: checkasm.h:131
InputFilter::type
enum AVMediaType type
Definition: ffmpeg.h:257
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:48
AV_BPRINT_SIZE_AUTOMATIC
#define AV_BPRINT_SIZE_AUTOMATIC
OutputFilter::sample_rate
int sample_rate
Definition: ffmpeg.h:290
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:957
InputStream::sub2video::last_pts
int64_t last_pts
Definition: ffmpeg.h:371
AVRational::num
int num
Numerator.
Definition: rational.h:59
InputFile
Definition: ffmpeg.h:415
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:418
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:730
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:415
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:886
OutputFile::shortest
int shortest
Definition: ffmpeg.h:611
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
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:40
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:287
input_streams
InputStream ** input_streams
Definition: ffmpeg.c:144
s
#define s(width, name)
Definition: cbs_vp9.c:256
FilterGraph::outputs
OutputFilter ** outputs
Definition: ffmpeg.h:312
InputStream::framerate
AVRational framerate
Definition: ffmpeg.h:357
configure_input_audio_filter
static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
Definition: ffmpeg_filter.c:836
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
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:106
AVDictionaryEntry::key
char * key
Definition: dict.h:80
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:127
InputFilter
Definition: ffmpeg.h:252
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:278
OutputStream::avfilter
char * avfilter
Definition: ffmpeg.h:539
ctx
AVFormatContext * ctx
Definition: movenc.c:48
audio_drift_threshold
float audio_drift_threshold
Definition: ffmpeg_opt.c:156
InputStream::filters
InputFilter ** filters
Definition: ffmpeg.h:381
nb_streams
static int nb_streams
Definition: ffprobe.c:307
InputFilter::graph
struct FilterGraph * graph
Definition: ffmpeg.h:255
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
output_streams
OutputStream ** output_streams
Definition: ffmpeg.c:149
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:54
AVFormatContext
Format I/O context.
Definition: avformat.h:1213
avfilter_get_by_name
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
Definition: allfilters.c:596
OutputFilter::height
int height
Definition: ffmpeg.h:287
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1108
OutputFilter::name
uint8_t * name
Definition: ffmpeg.h:280
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
AVFILTER_AUTO_CONVERT_NONE
@ AVFILTER_AUTO_CONVERT_NONE
all automatic conversions disabled
Definition: avfilter.h:1004
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:375
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:318
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:873
AVFilterContext::name
char * name
name of this filter instance
Definition: avfilter.h:413
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:960
InputFilter::eof
int eof
Definition: ffmpeg.h:273
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:871
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
nb_input_streams
int nb_input_streams
Definition: ffmpeg.c:145
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:373
FilterGraph::nb_outputs
int nb_outputs
Definition: ffmpeg.h:313
InputStream::sub2video::initialize
unsigned int initialize
marks if sub2video_update should force an initialization
Definition: ffmpeg.h:376
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:146
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:185
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:630
FilterGraph
Definition: ffmpeg.h:300
AVFormatContext::nb_streams
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1269
InputFilter::filter
AVFilterContext * filter
Definition: ffmpeg.h:253
AVFilterInOut::pad_idx
int pad_idx
index of the filt_ctx pad to use for linking
Definition: avfilter.h:1039
AVFilterGraph::scale_sws_opts
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
Definition: avfilter.h:876
f
f
Definition: af_crystalizer.c:122
AVMediaType
AVMediaType
Definition: avutil.h:199
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:290
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:317
AVFilterInOut::filter_ctx
AVFilterContext * filter_ctx
filter context associated to this input/output
Definition: avfilter.h:1036
output_files
OutputFile ** output_files
Definition: ffmpeg.c:151
avfilter_link
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
Definition: avfilter.c:140
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:304
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:167
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
av_guess_frame_rate
AVRational av_guess_frame_rate(AVFormatContext *format, AVStream *st, AVFrame *frame)
Guess the frame rate, based on both the container and codec information.
Definition: avformat.c:612
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:233
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:277
AV_PIX_FMT_RGB32
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:381
filter_is_buffersrc
static int filter_is_buffersrc(const AVFilterContext *f)
Definition: ffmpeg_filter.c:950
OutputFilter::type
enum AVMediaType type
Definition: ffmpeg.h:284
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
sample_rates
sample_rates
Definition: ffmpeg_filter.c:155
avfilter_init_str
int avfilter_init_str(AVFilterContext *filter, const char *args)
Initialize a filter with the supplied parameters.
Definition: avfilter.c:919
buffersink.h
avcodec_get_name
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
Definition: utils.c:447
ifilter_parameters_from_frame
int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
Definition: ffmpeg_filter.c:1150
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:323
configure_input_filter
static int configure_input_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
Definition: ffmpeg_filter.c:924
choose_channel_layouts
static void choose_channel_layouts(OutputFilter *ofilter, AVBPrint *bprint)
Definition: ffmpeg_filter.c:158
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:634
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:904
AVCodecParameters::height
int height
Definition: codec_par.h:128
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
display.h
OutputFile::ost_index
int ost_index
Definition: ffmpeg.h:607
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:324
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:418
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:230
filtergraphs
FilterGraph ** filtergraphs
Definition: ffmpeg.c:154
AVCodecContext::height
int height
Definition: avcodec.h:571
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:256
OutputFilter::ch_layout
AVChannelLayout ch_layout
Definition: ffmpeg.h:291
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
InputFile::ist_index
int ist_index
Definition: ffmpeg.h:421
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:267
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:958
OutputFilter::format
int format
Definition: ffmpeg.h:289
configure_input_video_filter
static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
Definition: ffmpeg_filter.c:711
AVCodecContext
main external API structure.
Definition: avcodec.h:398
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:956
av_bprint_clear
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
Definition: bprint.c:227
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:2966
DEF_CHOOSE_FORMAT
#define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name)
Definition: ffmpeg_filter.c:129
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:262
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:213
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
avfilter.h
FilterGraph::is_meta
int is_meta
Definition: ffmpeg.h:308
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:264
GROW_ARRAY
#define GROW_ARRAY(array, nb_elems)
Definition: cmdutils.h:431
AVERROR_FILTER_NOT_FOUND
#define AVERROR_FILTER_NOT_FOUND
Filter not found.
Definition: error.h:60
InputStream::discard
int discard
Definition: ffmpeg.h:319
AVFilterContext
An instance of a filter.
Definition: avfilter.h:408
OutputFilter
Definition: ffmpeg.h:276
cleanup_filtergraph
static void cleanup_filtergraph(FilterGraph *fg)
Definition: ffmpeg_filter.c:940
InputStream::sub2video::frame
AVFrame * frame
Definition: ffmpeg.h:374
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:168
OutputFilter::out_tmp
AVFilterInOut * out_tmp
Definition: ffmpeg.h:283
auto_conversion_filters
int auto_conversion_filters
Definition: ffmpeg_opt.c:180
InputStream::sub2video::h
int h
Definition: ffmpeg.h:375
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:512
InputFilter::hw_frames_ctx
AVBufferRef * hw_frames_ctx
Definition: ffmpeg.h:270
AVDictionaryEntry
Definition: dict.h:79
InputStream::sub2video::end_pts
int64_t end_pts
Definition: ffmpeg.h:372
choose_pix_fmts
static const char * choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint)
Definition: ffmpeg_filter.c:90
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:61
FilterGraph::reconfiguration
int reconfiguration
Definition: ffmpeg.h:305
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
filtergraph_is_simple
int filtergraph_is_simple(FilterGraph *fg)
Definition: ffmpeg_filter.c:1182
InputFilter::frame_queue
AVFifo * frame_queue
Definition: ffmpeg.h:259
nb_filtergraphs
int nb_filtergraphs
Definition: ffmpeg.c:155
AVFilterInOut::name
char * name
unique name for this input/output in the list
Definition: avfilter.h:1033
d
d
Definition: ffmpeg_filter.c:155
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
AVDictionaryEntry::value
char * value
Definition: dict.h:81
AVFilterGraph::nb_filters
unsigned nb_filters
Definition: avfilter.h:874
get_rotation
double get_rotation(int32_t *displaymatrix)
Definition: cmdutils.c:1003
avstring.h
OutputFile::recording_time
int64_t recording_time
desired length of the resulting file in microseconds == AV_TIME_BASE units
Definition: ffmpeg.h:608
AVFilterInOut
A linked-list of the inputs/outputs of the filter chain.
Definition: avfilter.h:1031
InputStream::dec
const AVCodec * dec
Definition: ffmpeg.h:327
snprintf
#define snprintf
Definition: snprintf.h:34
buffersrc.h
AUTO_INSERT_FILTER_INPUT
#define AUTO_INSERT_FILTER_INPUT(opt_name, filter_name, arg)
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
configure_output_audio_filter
static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
Definition: ffmpeg_filter.c:523
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:2595
filter_complex_nbthreads
int filter_complex_nbthreads
Definition: ffmpeg_opt.c:178
OutputFile
Definition: ffmpeg.h:596
sub2video_prepare
static int sub2video_prepare(InputStream *ist, InputFilter *ifilter)
Definition: ffmpeg_filter.c:664
InputStream::autorotate
int autorotate
Definition: ffmpeg.h:361