FFmpeg
opt_common.c
Go to the documentation of this file.
1 /*
2  * Option handlers shared between the tools.
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 "config.h"
22 
23 #include <stdio.h>
24 
25 #include "cmdutils.h"
26 #include "opt_common.h"
27 
28 #include "libavutil/avassert.h"
29 #include "libavutil/avstring.h"
30 #include "libavutil/bprint.h"
32 #include "libavutil/cpu.h"
33 #include "libavutil/dict.h"
34 #include "libavutil/error.h"
35 #include "libavutil/ffversion.h"
36 #include "libavutil/log.h"
37 #include "libavutil/mem.h"
38 #include "libavutil/parseutils.h"
39 #include "libavutil/pixdesc.h"
40 #include "libavutil/version.h"
41 
42 #include "libavcodec/avcodec.h"
43 #include "libavcodec/bsf.h"
44 #include "libavcodec/codec.h"
45 #include "libavcodec/codec_desc.h"
46 #include "libavcodec/version.h"
47 
48 #include "libavformat/avformat.h"
49 #include "libavformat/version.h"
50 
51 #include "libavdevice/avdevice.h"
52 #include "libavdevice/version.h"
53 
54 #include "libavfilter/avfilter.h"
55 #include "libavfilter/version.h"
56 
57 #include "libswscale/swscale.h"
58 #include "libswscale/version.h"
59 
61 #include "libswresample/version.h"
62 
64 #include "libpostproc/version.h"
65 
70 };
71 
72 static FILE *report_file;
74 
75 int show_license(void *optctx, const char *opt, const char *arg)
76 {
77 #if CONFIG_NONFREE
78  printf(
79  "This version of %s has nonfree parts compiled in.\n"
80  "Therefore it is not legally redistributable.\n",
81  program_name );
82 #elif CONFIG_GPLV3
83  printf(
84  "%s is free software; you can redistribute it and/or modify\n"
85  "it under the terms of the GNU General Public License as published by\n"
86  "the Free Software Foundation; either version 3 of the License, or\n"
87  "(at your option) any later version.\n"
88  "\n"
89  "%s is distributed in the hope that it will be useful,\n"
90  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
91  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
92  "GNU General Public License for more details.\n"
93  "\n"
94  "You should have received a copy of the GNU General Public License\n"
95  "along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
97 #elif CONFIG_GPL
98  printf(
99  "%s is free software; you can redistribute it and/or modify\n"
100  "it under the terms of the GNU General Public License as published by\n"
101  "the Free Software Foundation; either version 2 of the License, or\n"
102  "(at your option) any later version.\n"
103  "\n"
104  "%s is distributed in the hope that it will be useful,\n"
105  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
106  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
107  "GNU General Public License for more details.\n"
108  "\n"
109  "You should have received a copy of the GNU General Public License\n"
110  "along with %s; if not, write to the Free Software\n"
111  "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
113 #elif CONFIG_LGPLV3
114  printf(
115  "%s is free software; you can redistribute it and/or modify\n"
116  "it under the terms of the GNU Lesser General Public License as published by\n"
117  "the Free Software Foundation; either version 3 of the License, or\n"
118  "(at your option) any later version.\n"
119  "\n"
120  "%s is distributed in the hope that it will be useful,\n"
121  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
122  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
123  "GNU Lesser General Public License for more details.\n"
124  "\n"
125  "You should have received a copy of the GNU Lesser General Public License\n"
126  "along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
128 #else
129  printf(
130  "%s is free software; you can redistribute it and/or\n"
131  "modify it under the terms of the GNU Lesser General Public\n"
132  "License as published by the Free Software Foundation; either\n"
133  "version 2.1 of the License, or (at your option) any later version.\n"
134  "\n"
135  "%s is distributed in the hope that it will be useful,\n"
136  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
137  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
138  "Lesser General Public License for more details.\n"
139  "\n"
140  "You should have received a copy of the GNU Lesser General Public\n"
141  "License along with %s; if not, write to the Free Software\n"
142  "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
144 #endif
145 
146  return 0;
147 }
148 
149 static int warned_cfg = 0;
150 
151 #define INDENT 1
152 #define SHOW_VERSION 2
153 #define SHOW_CONFIG 4
154 #define SHOW_COPYRIGHT 8
155 
156 #define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \
157  if (CONFIG_##LIBNAME) { \
158  const char *indent = flags & INDENT? " " : ""; \
159  if (flags & SHOW_VERSION) { \
160  unsigned int version = libname##_version(); \
161  av_log(NULL, level, \
162  "%slib%-11s %2d.%3d.%3d / %2d.%3d.%3d\n", \
163  indent, #libname, \
164  LIB##LIBNAME##_VERSION_MAJOR, \
165  LIB##LIBNAME##_VERSION_MINOR, \
166  LIB##LIBNAME##_VERSION_MICRO, \
167  AV_VERSION_MAJOR(version), AV_VERSION_MINOR(version),\
168  AV_VERSION_MICRO(version)); \
169  } \
170  if (flags & SHOW_CONFIG) { \
171  const char *cfg = libname##_configuration(); \
172  if (strcmp(FFMPEG_CONFIGURATION, cfg)) { \
173  if (!warned_cfg) { \
174  av_log(NULL, level, \
175  "%sWARNING: library configuration mismatch\n", \
176  indent); \
177  warned_cfg = 1; \
178  } \
179  av_log(NULL, level, "%s%-11s configuration: %s\n", \
180  indent, #libname, cfg); \
181  } \
182  } \
183  } \
184 
185 static void print_all_libs_info(int flags, int level)
186 {
187  PRINT_LIB_INFO(avutil, AVUTIL, flags, level);
188  PRINT_LIB_INFO(avcodec, AVCODEC, flags, level);
189  PRINT_LIB_INFO(avformat, AVFORMAT, flags, level);
190  PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level);
191  PRINT_LIB_INFO(avfilter, AVFILTER, flags, level);
192  PRINT_LIB_INFO(swscale, SWSCALE, flags, level);
193  PRINT_LIB_INFO(swresample, SWRESAMPLE, flags, level);
194  PRINT_LIB_INFO(postproc, POSTPROC, flags, level);
195 }
196 
197 static void print_program_info(int flags, int level)
198 {
199  const char *indent = flags & INDENT? " " : "";
200 
201  av_log(NULL, level, "%s version " FFMPEG_VERSION, program_name);
202  if (flags & SHOW_COPYRIGHT)
203  av_log(NULL, level, " Copyright (c) %d-%d the FFmpeg developers",
204  program_birth_year, CONFIG_THIS_YEAR);
205  av_log(NULL, level, "\n");
206  av_log(NULL, level, "%sbuilt with %s\n", indent, CC_IDENT);
207 
208  av_log(NULL, level, "%sconfiguration: " FFMPEG_CONFIGURATION "\n", indent);
209 }
210 
211 static void print_buildconf(int flags, int level)
212 {
213  const char *indent = flags & INDENT ? " " : "";
214  char str[] = { FFMPEG_CONFIGURATION };
215  char *conflist, *remove_tilde, *splitconf;
216 
217  // Change all the ' --' strings to '~--' so that
218  // they can be identified as tokens.
219  while ((conflist = strstr(str, " --")) != NULL) {
220  conflist[0] = '~';
221  }
222 
223  // Compensate for the weirdness this would cause
224  // when passing 'pkg-config --static'.
225  while ((remove_tilde = strstr(str, "pkg-config~")) != NULL) {
226  remove_tilde[sizeof("pkg-config~") - 2] = ' ';
227  }
228 
229  splitconf = strtok(str, "~");
230  av_log(NULL, level, "\n%sconfiguration:\n", indent);
231  while (splitconf != NULL) {
232  av_log(NULL, level, "%s%s%s\n", indent, indent, splitconf);
233  splitconf = strtok(NULL, "~");
234  }
235 }
236 
237 void show_banner(int argc, char **argv, const OptionDef *options)
238 {
239  int idx = locate_option(argc, argv, options, "version");
240  if (hide_banner || idx)
241  return;
242 
246 }
247 
248 int show_version(void *optctx, const char *opt, const char *arg)
249 {
253 
254  return 0;
255 }
256 
257 int show_buildconf(void *optctx, const char *opt, const char *arg)
258 {
261 
262  return 0;
263 }
264 
265 #define PRINT_CODEC_SUPPORTED(codec, config, type, name, elem, fmt, ...) \
266  do { \
267  int num = 0; \
268  const type *elem = NULL; \
269  avcodec_get_supported_config(NULL, codec, config, 0, \
270  (const void **) &elem, &num); \
271  if (elem) { \
272  printf(" Supported " name ":"); \
273  for (int i = 0; i < num; i++) { \
274  printf(" " fmt, __VA_ARGS__); \
275  elem++; \
276  } \
277  printf("\n"); \
278  } \
279  } while (0)
280 
281 static const char *get_channel_layout_desc(const AVChannelLayout *layout, AVBPrint *bp)
282 {
283  int ret;
284  av_bprint_clear(bp);
286  if (!av_bprint_is_complete(bp) || ret < 0)
287  return "unknown/invalid";
288  return bp->str;
289 }
290 
291 static void print_codec(const AVCodec *c)
292 {
293  int encoder = av_codec_is_encoder(c);
294  AVBPrint desc;
295 
296  printf("%s %s [%s]:\n", encoder ? "Encoder" : "Decoder", c->name,
297  c->long_name ? c->long_name : "");
298 
299  printf(" General capabilities: ");
300  if (c->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)
301  printf("horizband ");
302  if (c->capabilities & AV_CODEC_CAP_DR1)
303  printf("dr1 ");
304  if (c->capabilities & AV_CODEC_CAP_DELAY)
305  printf("delay ");
306  if (c->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME)
307  printf("small ");
308  if (c->capabilities & AV_CODEC_CAP_EXPERIMENTAL)
309  printf("exp ");
310  if (c->capabilities & AV_CODEC_CAP_CHANNEL_CONF)
311  printf("chconf ");
312  if (c->capabilities & AV_CODEC_CAP_PARAM_CHANGE)
313  printf("paramchange ");
314  if (c->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)
315  printf("variable ");
316  if (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS |
319  printf("threads ");
320  if (c->capabilities & AV_CODEC_CAP_AVOID_PROBING)
321  printf("avoidprobe ");
322  if (c->capabilities & AV_CODEC_CAP_HARDWARE)
323  printf("hardware ");
324  if (c->capabilities & AV_CODEC_CAP_HYBRID)
325  printf("hybrid ");
326  if (!c->capabilities)
327  printf("none");
328  printf("\n");
329 
330  if (c->type == AVMEDIA_TYPE_VIDEO ||
331  c->type == AVMEDIA_TYPE_AUDIO) {
332  printf(" Threading capabilities: ");
333  switch (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS |
337  AV_CODEC_CAP_SLICE_THREADS: printf("frame and slice"); break;
338  case AV_CODEC_CAP_FRAME_THREADS: printf("frame"); break;
339  case AV_CODEC_CAP_SLICE_THREADS: printf("slice"); break;
340  case AV_CODEC_CAP_OTHER_THREADS: printf("other"); break;
341  default: printf("none"); break;
342  }
343  printf("\n");
344  }
345 
346  if (avcodec_get_hw_config(c, 0)) {
347  printf(" Supported hardware devices: ");
348  for (int i = 0;; i++) {
350  const char *name;
351  if (!config)
352  break;
353  name = av_hwdevice_get_type_name(config->device_type);
354  if (name)
355  printf("%s ", name);
356  }
357  printf("\n");
358  }
359 
361  fps, "%d/%d", fps->num, fps->den);
363  "pixel formats", fmt, "%s", av_get_pix_fmt_name(*fmt));
365  rate, "%d", *rate);
367  "sample formats", fmt, "%s", av_get_sample_fmt_name(*fmt));
368 
371  "channel layouts", layout, "%s",
374 
375  if (c->priv_class) {
376  show_help_children(c->priv_class,
379  }
380 }
381 
382 static const AVCodec *next_codec_for_id(enum AVCodecID id, void **iter,
383  int encoder)
384 {
385  const AVCodec *c;
386  while ((c = av_codec_iterate(iter))) {
387  if (c->id == id &&
388  (encoder ? av_codec_is_encoder(c) : av_codec_is_decoder(c)))
389  return c;
390  }
391  return NULL;
392 }
393 
394 static void show_help_codec(const char *name, int encoder)
395 {
396  const AVCodecDescriptor *desc;
397  const AVCodec *codec;
398 
399  if (!name) {
400  av_log(NULL, AV_LOG_ERROR, "No codec name specified.\n");
401  return;
402  }
403 
404  codec = encoder ? avcodec_find_encoder_by_name(name) :
406 
407  if (codec)
408  print_codec(codec);
409  else if ((desc = avcodec_descriptor_get_by_name(name))) {
410  void *iter = NULL;
411  int printed = 0;
412 
413  while ((codec = next_codec_for_id(desc->id, &iter, encoder))) {
414  printed = 1;
415  print_codec(codec);
416  }
417 
418  if (!printed) {
419  av_log(NULL, AV_LOG_ERROR, "Codec '%s' is known to FFmpeg, "
420  "but no %s for it are available. FFmpeg might need to be "
421  "recompiled with additional external libraries.\n",
422  name, encoder ? "encoders" : "decoders");
423  }
424  } else {
425  av_log(NULL, AV_LOG_ERROR, "Codec '%s' is not recognized by FFmpeg.\n",
426  name);
427  }
428 }
429 
430 static void show_help_demuxer(const char *name)
431 {
433 
434  if (!fmt) {
435  av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name);
436  return;
437  }
438 
439  printf("Demuxer %s [%s]:\n", fmt->name, fmt->long_name);
440 
441  if (fmt->extensions)
442  printf(" Common extensions: %s.\n", fmt->extensions);
443 
444  if (fmt->priv_class)
446 }
447 
448 static void show_help_protocol(const char *name)
449 {
450  const AVClass *proto_class;
451 
452  if (!name) {
453  av_log(NULL, AV_LOG_ERROR, "No protocol name specified.\n");
454  return;
455  }
456 
457  proto_class = avio_protocol_get_class(name);
458  if (!proto_class) {
459  av_log(NULL, AV_LOG_ERROR, "Unknown protocol '%s'.\n", name);
460  return;
461  }
462 
464 }
465 
466 static void show_help_muxer(const char *name)
467 {
468  const AVCodecDescriptor *desc;
469  const AVOutputFormat *fmt = av_guess_format(name, NULL, NULL);
470 
471  if (!fmt) {
472  av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name);
473  return;
474  }
475 
476  printf("Muxer %s [%s]:\n", fmt->name, fmt->long_name);
477 
478  if (fmt->extensions)
479  printf(" Common extensions: %s.\n", fmt->extensions);
480  if (fmt->mime_type)
481  printf(" Mime type: %s.\n", fmt->mime_type);
482  if (fmt->video_codec != AV_CODEC_ID_NONE &&
484  printf(" Default video codec: %s.\n", desc->name);
485  }
486  if (fmt->audio_codec != AV_CODEC_ID_NONE &&
488  printf(" Default audio codec: %s.\n", desc->name);
489  }
490  if (fmt->subtitle_codec != AV_CODEC_ID_NONE &&
492  printf(" Default subtitle codec: %s.\n", desc->name);
493  }
494 
495  if (fmt->priv_class)
497 }
498 
499 #if CONFIG_AVFILTER
500 static void show_help_filter(const char *name)
501 {
502 #if CONFIG_AVFILTER
504  int i, count;
505 
506  if (!name) {
507  av_log(NULL, AV_LOG_ERROR, "No filter name specified.\n");
508  return;
509  } else if (!f) {
510  av_log(NULL, AV_LOG_ERROR, "Unknown filter '%s'.\n", name);
511  return;
512  }
513 
514  printf("Filter %s\n", f->name);
515  if (f->description)
516  printf(" %s\n", f->description);
517 
518  if (f->flags & AVFILTER_FLAG_SLICE_THREADS)
519  printf(" slice threading supported\n");
520 
521  printf(" Inputs:\n");
522  count = avfilter_filter_pad_count(f, 0);
523  for (i = 0; i < count; i++) {
524  printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i),
526  }
527  if (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)
528  printf(" dynamic (depending on the options)\n");
529  else if (!count)
530  printf(" none (source filter)\n");
531 
532  printf(" Outputs:\n");
533  count = avfilter_filter_pad_count(f, 1);
534  for (i = 0; i < count; i++) {
535  printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i),
537  }
538  if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS)
539  printf(" dynamic (depending on the options)\n");
540  else if (!count)
541  printf(" none (sink filter)\n");
542 
543  if (f->priv_class)
546  if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE)
547  printf("This filter has support for timeline through the 'enable' option.\n");
548 #else
549  av_log(NULL, AV_LOG_ERROR, "Build without libavfilter; "
550  "can not to satisfy request\n");
551 #endif
552 }
553 #endif
554 
555 static void show_help_bsf(const char *name)
556 {
558 
559  if (!name) {
560  av_log(NULL, AV_LOG_ERROR, "No bitstream filter name specified.\n");
561  return;
562  } else if (!bsf) {
563  av_log(NULL, AV_LOG_ERROR, "Unknown bit stream filter '%s'.\n", name);
564  return;
565  }
566 
567  printf("Bit stream filter %s\n", bsf->name);
568  if (bsf->codec_ids) {
569  const enum AVCodecID *id = bsf->codec_ids;
570  printf(" Supported codecs:");
571  while (*id != AV_CODEC_ID_NONE) {
572  printf(" %s", avcodec_descriptor_get(*id)->name);
573  id++;
574  }
575  printf("\n");
576  }
577  if (bsf->priv_class)
579 }
580 
581 int show_help(void *optctx, const char *opt, const char *arg)
582 {
583  char *topic, *par;
585 
586  topic = av_strdup(arg ? arg : "");
587  if (!topic)
588  return AVERROR(ENOMEM);
589  par = strchr(topic, '=');
590  if (par)
591  *par++ = 0;
592 
593  if (!*topic) {
594  show_help_default(topic, par);
595  } else if (!strcmp(topic, "decoder")) {
596  show_help_codec(par, 0);
597  } else if (!strcmp(topic, "encoder")) {
598  show_help_codec(par, 1);
599  } else if (!strcmp(topic, "demuxer")) {
600  show_help_demuxer(par);
601  } else if (!strcmp(topic, "muxer")) {
602  show_help_muxer(par);
603  } else if (!strcmp(topic, "protocol")) {
604  show_help_protocol(par);
605 #if CONFIG_AVFILTER
606  } else if (!strcmp(topic, "filter")) {
607  show_help_filter(par);
608 #endif
609  } else if (!strcmp(topic, "bsf")) {
610  show_help_bsf(par);
611  } else {
612  show_help_default(topic, par);
613  }
614 
615  av_freep(&topic);
616  return 0;
617 }
618 
619 static void print_codecs_for_id(enum AVCodecID id, int encoder)
620 {
621  void *iter = NULL;
622  const AVCodec *codec;
623 
624  printf(" (%s:", encoder ? "encoders" : "decoders");
625 
626  while ((codec = next_codec_for_id(id, &iter, encoder)))
627  printf(" %s", codec->name);
628 
629  printf(")");
630 }
631 
632 static int compare_codec_desc(const void *a, const void *b)
633 {
634  const AVCodecDescriptor * const *da = a;
635  const AVCodecDescriptor * const *db = b;
636 
637  return (*da)->type != (*db)->type ? FFDIFFSIGN((*da)->type, (*db)->type) :
638  strcmp((*da)->name, (*db)->name);
639 }
640 
641 static int get_codecs_sorted(const AVCodecDescriptor ***rcodecs)
642 {
643  const AVCodecDescriptor *desc = NULL;
644  const AVCodecDescriptor **codecs;
645  unsigned nb_codecs = 0, i = 0;
646 
647  while ((desc = avcodec_descriptor_next(desc)))
648  nb_codecs++;
649  if (!(codecs = av_calloc(nb_codecs, sizeof(*codecs))))
650  return AVERROR(ENOMEM);
651  desc = NULL;
652  while ((desc = avcodec_descriptor_next(desc)))
653  codecs[i++] = desc;
654  av_assert0(i == nb_codecs);
655  qsort(codecs, nb_codecs, sizeof(*codecs), compare_codec_desc);
656  *rcodecs = codecs;
657  return nb_codecs;
658 }
659 
661 {
662  switch (type) {
663  case AVMEDIA_TYPE_VIDEO: return 'V';
664  case AVMEDIA_TYPE_AUDIO: return 'A';
665  case AVMEDIA_TYPE_DATA: return 'D';
666  case AVMEDIA_TYPE_SUBTITLE: return 'S';
667  case AVMEDIA_TYPE_ATTACHMENT:return 'T';
668  default: return '?';
669  }
670 }
671 
672 int show_codecs(void *optctx, const char *opt, const char *arg)
673 {
674  const AVCodecDescriptor **codecs;
675  unsigned i;
676  int nb_codecs = get_codecs_sorted(&codecs);
677 
678  if (nb_codecs < 0)
679  return nb_codecs;
680 
681  printf("Codecs:\n"
682  " D..... = Decoding supported\n"
683  " .E.... = Encoding supported\n"
684  " ..V... = Video codec\n"
685  " ..A... = Audio codec\n"
686  " ..S... = Subtitle codec\n"
687  " ..D... = Data codec\n"
688  " ..T... = Attachment codec\n"
689  " ...I.. = Intra frame-only codec\n"
690  " ....L. = Lossy compression\n"
691  " .....S = Lossless compression\n"
692  " -------\n");
693  for (i = 0; i < nb_codecs; i++) {
694  const AVCodecDescriptor *desc = codecs[i];
695  const AVCodec *codec;
696  void *iter = NULL;
697 
698  if (strstr(desc->name, "_deprecated"))
699  continue;
700 
701  printf(" %c%c%c%c%c%c",
702  avcodec_find_decoder(desc->id) ? 'D' : '.',
703  avcodec_find_encoder(desc->id) ? 'E' : '.',
704  get_media_type_char(desc->type),
705  (desc->props & AV_CODEC_PROP_INTRA_ONLY) ? 'I' : '.',
706  (desc->props & AV_CODEC_PROP_LOSSY) ? 'L' : '.',
707  (desc->props & AV_CODEC_PROP_LOSSLESS) ? 'S' : '.');
708 
709  printf(" %-20s %s", desc->name, desc->long_name ? desc->long_name : "");
710 
711  /* print decoders/encoders when there's more than one or their
712  * names are different from codec name */
713  while ((codec = next_codec_for_id(desc->id, &iter, 0))) {
714  if (strcmp(codec->name, desc->name)) {
715  print_codecs_for_id(desc->id, 0);
716  break;
717  }
718  }
719  iter = NULL;
720  while ((codec = next_codec_for_id(desc->id, &iter, 1))) {
721  if (strcmp(codec->name, desc->name)) {
722  print_codecs_for_id(desc->id, 1);
723  break;
724  }
725  }
726 
727  printf("\n");
728  }
729  av_free(codecs);
730  return 0;
731 }
732 
733 static int print_codecs(int encoder)
734 {
735  const AVCodecDescriptor **codecs;
736  int i, nb_codecs = get_codecs_sorted(&codecs);
737 
738  if (nb_codecs < 0)
739  return nb_codecs;
740 
741  printf("%s:\n"
742  " V..... = Video\n"
743  " A..... = Audio\n"
744  " S..... = Subtitle\n"
745  " .F.... = Frame-level multithreading\n"
746  " ..S... = Slice-level multithreading\n"
747  " ...X.. = Codec is experimental\n"
748  " ....B. = Supports draw_horiz_band\n"
749  " .....D = Supports direct rendering method 1\n"
750  " ------\n",
751  encoder ? "Encoders" : "Decoders");
752  for (i = 0; i < nb_codecs; i++) {
753  const AVCodecDescriptor *desc = codecs[i];
754  const AVCodec *codec;
755  void *iter = NULL;
756 
757  while ((codec = next_codec_for_id(desc->id, &iter, encoder))) {
758  printf(" %c%c%c%c%c%c",
759  get_media_type_char(desc->type),
760  (codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) ? 'F' : '.',
761  (codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) ? 'S' : '.',
762  (codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) ? 'X' : '.',
763  (codec->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND) ? 'B' : '.',
764  (codec->capabilities & AV_CODEC_CAP_DR1) ? 'D' : '.');
765 
766  printf(" %-20s %s", codec->name, codec->long_name ? codec->long_name : "");
767  if (strcmp(codec->name, desc->name))
768  printf(" (codec %s)", desc->name);
769 
770  printf("\n");
771  }
772  }
773  av_free(codecs);
774  return 0;
775 }
776 
777 int show_decoders(void *optctx, const char *opt, const char *arg)
778 {
779  return print_codecs(0);
780 }
781 
782 int show_encoders(void *optctx, const char *opt, const char *arg)
783 {
784  return print_codecs(1);
785 }
786 
787 int show_bsfs(void *optctx, const char *opt, const char *arg)
788 {
789  const AVBitStreamFilter *bsf = NULL;
790  void *opaque = NULL;
791 
792  printf("Bitstream filters:\n");
793  while ((bsf = av_bsf_iterate(&opaque)))
794  printf("%s\n", bsf->name);
795  printf("\n");
796  return 0;
797 }
798 
799 int show_filters(void *optctx, const char *opt, const char *arg)
800 {
801 #if CONFIG_AVFILTER
802  const AVFilter *filter = NULL;
803  char descr[64], *descr_cur;
804  void *opaque = NULL;
805  int i, j;
806  const AVFilterPad *pad;
807 
808  printf("Filters:\n"
809  " T.. = Timeline support\n"
810  " .S. = Slice threading\n"
811  " ..C = Command support\n"
812  " A = Audio input/output\n"
813  " V = Video input/output\n"
814  " N = Dynamic number and/or type of input/output\n"
815  " | = Source or sink filter\n");
816  while ((filter = av_filter_iterate(&opaque))) {
817  descr_cur = descr;
818  for (i = 0; i < 2; i++) {
819  unsigned nb_pads;
820  if (i) {
821  *(descr_cur++) = '-';
822  *(descr_cur++) = '>';
823  }
824  pad = i ? filter->outputs : filter->inputs;
825  nb_pads = avfilter_filter_pad_count(filter, i);
826  for (j = 0; j < nb_pads; j++) {
827  if (descr_cur >= descr + sizeof(descr) - 4)
828  break;
829  *(descr_cur++) = get_media_type_char(avfilter_pad_get_type(pad, j));
830  }
831  if (!j)
832  *(descr_cur++) = ((!i && (filter->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)) ||
833  ( i && (filter->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS))) ? 'N' : '|';
834  }
835  *descr_cur = 0;
836  printf(" %c%c%c %-17s %-10s %s\n",
837  filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE ? 'T' : '.',
838  filter->flags & AVFILTER_FLAG_SLICE_THREADS ? 'S' : '.',
839  filter->process_command ? 'C' : '.',
840  filter->name, descr, filter->description);
841  }
842 #else
843  printf("No filters available: libavfilter disabled\n");
844 #endif
845  return 0;
846 }
847 
848 static int is_device(const AVClass *avclass)
849 {
850  if (!avclass)
851  return 0;
852  return AV_IS_INPUT_DEVICE(avclass->category) || AV_IS_OUTPUT_DEVICE(avclass->category);
853 }
854 
855 static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers)
856 {
857  void *ifmt_opaque = NULL;
858  const AVInputFormat *ifmt = NULL;
859  void *ofmt_opaque = NULL;
860  const AVOutputFormat *ofmt = NULL;
861  const char *last_name;
862  int is_dev;
863  const char *is_device_placeholder = device_only ? "" : ".";
864 
865  printf("%s:\n"
866  " D.%s = Demuxing supported\n"
867  " .E%s = Muxing supported\n"
868  "%s"
869  " ---\n",
870  device_only ? "Devices" : "Formats",
871  is_device_placeholder, is_device_placeholder,
872  device_only ? "": " ..d = Is a device\n");
873 
874  last_name = "000";
875  for (;;) {
876  int decode = 0;
877  int encode = 0;
878  int device = 0;
879  const char *name = NULL;
880  const char *long_name = NULL;
881 
882  if (muxdemuxers !=SHOW_DEMUXERS) {
883  ofmt_opaque = NULL;
884  while ((ofmt = av_muxer_iterate(&ofmt_opaque))) {
885  is_dev = is_device(ofmt->priv_class);
886  if (!is_dev && device_only)
887  continue;
888  if ((!name || strcmp(ofmt->name, name) < 0) &&
889  strcmp(ofmt->name, last_name) > 0) {
890  name = ofmt->name;
891  long_name = ofmt->long_name;
892  encode = 1;
893  device = is_dev;
894  }
895  }
896  }
897  if (muxdemuxers != SHOW_MUXERS) {
898  ifmt_opaque = NULL;
899  while ((ifmt = av_demuxer_iterate(&ifmt_opaque))) {
900  is_dev = is_device(ifmt->priv_class);
901  if (!is_dev && device_only)
902  continue;
903  if ((!name || strcmp(ifmt->name, name) < 0) &&
904  strcmp(ifmt->name, last_name) > 0) {
905  name = ifmt->name;
906  long_name = ifmt->long_name;
907  encode = 0;
908  device = is_dev;
909  }
910  if (name && strcmp(ifmt->name, name) == 0) {
911  decode = 1;
912  device = is_dev;
913  }
914  }
915  }
916  if (!name)
917  break;
918  last_name = name;
919 
920  printf(" %c%c%s %-15s %s\n",
921  decode ? 'D' : ' ',
922  encode ? 'E' : ' ',
923  device_only ? "" : (device ? "d" : " "),
924  name,
925  long_name ? long_name : " ");
926  }
927  return 0;
928 }
929 
930 int show_formats(void *optctx, const char *opt, const char *arg)
931 {
932  return show_formats_devices(optctx, opt, arg, 0, SHOW_DEFAULT);
933 }
934 
935 int show_muxers(void *optctx, const char *opt, const char *arg)
936 {
937  return show_formats_devices(optctx, opt, arg, 0, SHOW_MUXERS);
938 }
939 
940 int show_demuxers(void *optctx, const char *opt, const char *arg)
941 {
942  return show_formats_devices(optctx, opt, arg, 0, SHOW_DEMUXERS);
943 }
944 
945 int show_devices(void *optctx, const char *opt, const char *arg)
946 {
947  return show_formats_devices(optctx, opt, arg, 1, SHOW_DEFAULT);
948 }
949 
950 int show_protocols(void *optctx, const char *opt, const char *arg)
951 {
952  void *opaque = NULL;
953  const char *name;
954 
955  printf("Supported file protocols:\n"
956  "Input:\n");
957  while ((name = avio_enum_protocols(&opaque, 0)))
958  printf(" %s\n", name);
959  printf("Output:\n");
960  while ((name = avio_enum_protocols(&opaque, 1)))
961  printf(" %s\n", name);
962  return 0;
963 }
964 
965 int show_colors(void *optctx, const char *opt, const char *arg)
966 {
967  const char *name;
968  const uint8_t *rgb;
969  int i;
970 
971  printf("%-32s #RRGGBB\n", "name");
972 
973  for (i = 0; name = av_get_known_color_name(i, &rgb); i++)
974  printf("%-32s #%02x%02x%02x\n", name, rgb[0], rgb[1], rgb[2]);
975 
976  return 0;
977 }
978 
979 int show_pix_fmts(void *optctx, const char *opt, const char *arg)
980 {
981  const AVPixFmtDescriptor *pix_desc = NULL;
982 
983  printf("Pixel formats:\n"
984  "I.... = Supported Input format for conversion\n"
985  ".O... = Supported Output format for conversion\n"
986  "..H.. = Hardware accelerated format\n"
987  "...P. = Paletted format\n"
988  "....B = Bitstream format\n"
989  "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL BIT_DEPTHS\n"
990  "-----\n");
991 
992 #if !CONFIG_SWSCALE
993 # define sws_isSupportedInput(x) 0
994 # define sws_isSupportedOutput(x) 0
995 #endif
996 
997  while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
999  printf("%c%c%c%c%c %-16s %d %3d %d",
1000  sws_isSupportedInput (pix_fmt) ? 'I' : '.',
1001  sws_isSupportedOutput(pix_fmt) ? 'O' : '.',
1002  pix_desc->flags & AV_PIX_FMT_FLAG_HWACCEL ? 'H' : '.',
1003  pix_desc->flags & AV_PIX_FMT_FLAG_PAL ? 'P' : '.',
1004  pix_desc->flags & AV_PIX_FMT_FLAG_BITSTREAM ? 'B' : '.',
1005  pix_desc->name,
1006  pix_desc->nb_components,
1007  av_get_bits_per_pixel(pix_desc),
1008  pix_desc->comp[0].depth);
1009 
1010  for (unsigned i = 1; i < pix_desc->nb_components; i++)
1011  printf("-%d", pix_desc->comp[i].depth);
1012  printf("\n");
1013  }
1014  return 0;
1015 }
1016 
1017 int show_layouts(void *optctx, const char *opt, const char *arg)
1018 {
1019  const AVChannelLayout *ch_layout;
1020  void *iter = NULL;
1021  char buf[128], buf2[128];
1022  int i = 0;
1023 
1024  printf("Individual channels:\n"
1025  "NAME DESCRIPTION\n");
1026  for (i = 0; i < 63; i++) {
1027  av_channel_name(buf, sizeof(buf), i);
1028  if (strstr(buf, "USR"))
1029  continue;
1030  av_channel_description(buf2, sizeof(buf2), i);
1031  printf("%-14s %s\n", buf, buf2);
1032  }
1033  printf("\nStandard channel layouts:\n"
1034  "NAME DECOMPOSITION\n");
1035  while (ch_layout = av_channel_layout_standard(&iter)) {
1036  av_channel_layout_describe(ch_layout, buf, sizeof(buf));
1037  printf("%-14s ", buf);
1038  for (i = 0; i < 63; i++) {
1039  int idx = av_channel_layout_index_from_channel(ch_layout, i);
1040  if (idx >= 0) {
1041  av_channel_name(buf2, sizeof(buf2), i);
1042  printf("%s%s", idx ? "+" : "", buf2);
1043  }
1044  }
1045  printf("\n");
1046  }
1047  return 0;
1048 }
1049 
1050 int show_sample_fmts(void *optctx, const char *opt, const char *arg)
1051 {
1052  int i;
1053  char fmt_str[128];
1054  for (i = -1; i < AV_SAMPLE_FMT_NB; i++)
1055  printf("%s\n", av_get_sample_fmt_string(fmt_str, sizeof(fmt_str), i));
1056  return 0;
1057 }
1058 
1059 int show_dispositions(void *optctx, const char *opt, const char *arg)
1060 {
1061  for (int i = 0; i < 32; i++) {
1062  const char *str = av_disposition_to_string(1U << i);
1063  if (str)
1064  printf("%s\n", str);
1065  }
1066  return 0;
1067 }
1068 
1069 int opt_cpuflags(void *optctx, const char *opt, const char *arg)
1070 {
1071  int ret;
1072  unsigned flags = av_get_cpu_flags();
1073 
1074  if ((ret = av_parse_cpu_caps(&flags, arg)) < 0)
1075  return ret;
1076 
1078  return 0;
1079 }
1080 
1081 int opt_cpucount(void *optctx, const char *opt, const char *arg)
1082 {
1083  int ret;
1084  int count;
1085 
1086  static const AVOption opts[] = {
1087  {"count", NULL, 0, AV_OPT_TYPE_INT, { .i64 = -1}, -1, INT_MAX},
1088  {NULL},
1089  };
1090  static const AVClass class = {
1091  .class_name = "cpucount",
1092  .item_name = av_default_item_name,
1093  .option = opts,
1094  .version = LIBAVUTIL_VERSION_INT,
1095  };
1096  const AVClass *pclass = &class;
1097 
1098  ret = av_opt_eval_int(&pclass, opts, arg, &count);
1099 
1100  if (!ret) {
1101  av_cpu_force_count(count);
1102  }
1103 
1104  return ret;
1105 }
1106 
1107 static void expand_filename_template(AVBPrint *bp, const char *template,
1108  struct tm *tm)
1109 {
1110  int c;
1111 
1112  while ((c = *(template++))) {
1113  if (c == '%') {
1114  if (!(c = *(template++)))
1115  break;
1116  switch (c) {
1117  case 'p':
1118  av_bprintf(bp, "%s", program_name);
1119  break;
1120  case 't':
1121  av_bprintf(bp, "%04d%02d%02d-%02d%02d%02d",
1122  tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
1123  tm->tm_hour, tm->tm_min, tm->tm_sec);
1124  break;
1125  case '%':
1126  av_bprint_chars(bp, c, 1);
1127  break;
1128  }
1129  } else {
1130  av_bprint_chars(bp, c, 1);
1131  }
1132  }
1133 }
1134 
1135 static void log_callback_report(void *ptr, int level, const char *fmt, va_list vl)
1136 {
1137  va_list vl2;
1138  char line[1024];
1139  static int print_prefix = 1;
1140 
1141  va_copy(vl2, vl);
1142  av_log_default_callback(ptr, level, fmt, vl);
1143  av_log_format_line(ptr, level, fmt, vl2, line, sizeof(line), &print_prefix);
1144  va_end(vl2);
1145  if (report_file_level >= level) {
1146  fputs(line, report_file);
1147  fflush(report_file);
1148  }
1149 }
1150 
1151 int init_report(const char *env, FILE **file)
1152 {
1153  char *filename_template = NULL;
1154  char *key, *val;
1155  int ret, count = 0;
1156  int prog_loglevel, envlevel = 0;
1157  time_t now;
1158  struct tm *tm;
1159  AVBPrint filename;
1160 
1161  if (report_file) /* already opened */
1162  return 0;
1163  time(&now);
1164  tm = localtime(&now);
1165 
1166  while (env && *env) {
1167  if ((ret = av_opt_get_key_value(&env, "=", ":", 0, &key, &val)) < 0) {
1168  if (count)
1170  "Failed to parse FFREPORT environment variable: %s\n",
1171  av_err2str(ret));
1172  break;
1173  }
1174  if (*env)
1175  env++;
1176  count++;
1177  if (!strcmp(key, "file")) {
1178  av_free(filename_template);
1179  filename_template = val;
1180  val = NULL;
1181  } else if (!strcmp(key, "level")) {
1182  char *tail;
1183  report_file_level = strtol(val, &tail, 10);
1184  if (*tail) {
1185  av_log(NULL, AV_LOG_FATAL, "Invalid report file level\n");
1186  av_free(key);
1187  av_free(val);
1188  av_free(filename_template);
1189  return AVERROR(EINVAL);
1190  }
1191  envlevel = 1;
1192  } else {
1193  av_log(NULL, AV_LOG_ERROR, "Unknown key '%s' in FFREPORT\n", key);
1194  }
1195  av_free(val);
1196  av_free(key);
1197  }
1198 
1200  expand_filename_template(&filename,
1201  av_x_if_null(filename_template, "%p-%t.log"), tm);
1202  av_free(filename_template);
1203  if (!av_bprint_is_complete(&filename)) {
1204  av_log(NULL, AV_LOG_ERROR, "Out of memory building report file name\n");
1205  return AVERROR(ENOMEM);
1206  }
1207 
1208  prog_loglevel = av_log_get_level();
1209  if (!envlevel)
1210  report_file_level = FFMAX(report_file_level, prog_loglevel);
1211 
1212  report_file = fopen(filename.str, "w");
1213  if (!report_file) {
1214  int ret = AVERROR(errno);
1215  av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n",
1216  filename.str, strerror(errno));
1217  return ret;
1218  }
1221  "%s started on %04d-%02d-%02d at %02d:%02d:%02d\n"
1222  "Report written to \"%s\"\n"
1223  "Log level: %d\n",
1224  program_name,
1225  tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
1226  tm->tm_hour, tm->tm_min, tm->tm_sec,
1227  filename.str, report_file_level);
1228  av_bprint_finalize(&filename, NULL);
1229 
1230  if (file)
1231  *file = report_file;
1232 
1233  return 0;
1234 }
1235 
1236 int opt_report(void *optctx, const char *opt, const char *arg)
1237 {
1238  return init_report(NULL, NULL);
1239 }
1240 
1241 int opt_max_alloc(void *optctx, const char *opt, const char *arg)
1242 {
1243  char *tail;
1244  size_t max;
1245 
1246  max = strtol(arg, &tail, 10);
1247  if (*tail) {
1248  av_log(NULL, AV_LOG_FATAL, "Invalid max_alloc \"%s\".\n", arg);
1249  return AVERROR(EINVAL);
1250  }
1251  av_max_alloc(max);
1252  return 0;
1253 }
1254 
1255 int opt_loglevel(void *optctx, const char *opt, const char *arg)
1256 {
1257  const struct { const char *name; int level; } log_levels[] = {
1258  { "quiet" , AV_LOG_QUIET },
1259  { "panic" , AV_LOG_PANIC },
1260  { "fatal" , AV_LOG_FATAL },
1261  { "error" , AV_LOG_ERROR },
1262  { "warning", AV_LOG_WARNING },
1263  { "info" , AV_LOG_INFO },
1264  { "verbose", AV_LOG_VERBOSE },
1265  { "debug" , AV_LOG_DEBUG },
1266  { "trace" , AV_LOG_TRACE },
1267  };
1268  const char *token;
1269  char *tail;
1270  int flags = av_log_get_flags();
1271  int level = av_log_get_level();
1272  int cmd, i = 0;
1273 
1274  av_assert0(arg);
1275  while (*arg) {
1276  token = arg;
1277  if (*token == '+' || *token == '-') {
1278  cmd = *token++;
1279  } else {
1280  cmd = 0;
1281  }
1282  if (!i && !cmd) {
1283  flags = 0; /* missing relative prefix, build absolute value */
1284  }
1285  if (av_strstart(token, "repeat", &arg)) {
1286  if (cmd == '-') {
1288  } else {
1290  }
1291  } else if (av_strstart(token, "level", &arg)) {
1292  if (cmd == '-') {
1294  } else {
1296  }
1297  } else {
1298  break;
1299  }
1300  i++;
1301  }
1302  if (!*arg) {
1303  goto end;
1304  } else if (*arg == '+') {
1305  arg++;
1306  } else if (!i) {
1307  flags = av_log_get_flags(); /* level value without prefix, reset flags */
1308  }
1309 
1310  for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) {
1311  if (!strcmp(log_levels[i].name, arg)) {
1312  level = log_levels[i].level;
1313  goto end;
1314  }
1315  }
1316 
1317  level = strtol(arg, &tail, 10);
1318  if (*tail) {
1319  av_log(NULL, AV_LOG_FATAL, "Invalid loglevel \"%s\". "
1320  "Possible levels are numbers or:\n", arg);
1321  for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++)
1322  av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name);
1323  return AVERROR(EINVAL);
1324  }
1325 
1326 end:
1329  return 0;
1330 }
1331 
1332 #if CONFIG_AVDEVICE
1333 static void print_device_list(const AVDeviceInfoList *device_list)
1334 {
1335  // print devices
1336  for (int i = 0; i < device_list->nb_devices; i++) {
1337  const AVDeviceInfo *device = device_list->devices[i];
1338  printf("%c %s [%s] (", device_list->default_device == i ? '*' : ' ',
1339  device->device_name, device->device_description);
1340  if (device->nb_media_types > 0) {
1341  for (int j = 0; j < device->nb_media_types; ++j) {
1342  const char* media_type = av_get_media_type_string(device->media_types[j]);
1343  if (j > 0)
1344  printf(", ");
1345  printf("%s", media_type ? media_type : "unknown");
1346  }
1347  } else {
1348  printf("none");
1349  }
1350  printf(")\n");
1351  }
1352 }
1353 
1354 static int print_device_sources(const AVInputFormat *fmt, AVDictionary *opts)
1355 {
1356  int ret;
1357  AVDeviceInfoList *device_list = NULL;
1358 
1359  if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category))
1360  return AVERROR(EINVAL);
1361 
1362  printf("Auto-detected sources for %s:\n", fmt->name);
1363  if ((ret = avdevice_list_input_sources(fmt, NULL, opts, &device_list)) < 0) {
1364  printf("Cannot list sources: %s\n", av_err2str(ret));
1365  goto fail;
1366  }
1367 
1368  print_device_list(device_list);
1369 
1370  fail:
1371  avdevice_free_list_devices(&device_list);
1372  return ret;
1373 }
1374 
1375 static int print_device_sinks(const AVOutputFormat *fmt, AVDictionary *opts)
1376 {
1377  int ret;
1378  AVDeviceInfoList *device_list = NULL;
1379 
1380  if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category))
1381  return AVERROR(EINVAL);
1382 
1383  printf("Auto-detected sinks for %s:\n", fmt->name);
1384  if ((ret = avdevice_list_output_sinks(fmt, NULL, opts, &device_list)) < 0) {
1385  printf("Cannot list sinks: %s\n", av_err2str(ret));
1386  goto fail;
1387  }
1388 
1389  print_device_list(device_list);
1390 
1391  fail:
1392  avdevice_free_list_devices(&device_list);
1393  return ret;
1394 }
1395 
1396 static int show_sinks_sources_parse_arg(const char *arg, char **dev, AVDictionary **opts)
1397 {
1398  int ret;
1399  if (arg) {
1400  char *opts_str = NULL;
1401  av_assert0(dev && opts);
1402  *dev = av_strdup(arg);
1403  if (!*dev)
1404  return AVERROR(ENOMEM);
1405  if ((opts_str = strchr(*dev, ','))) {
1406  *(opts_str++) = '\0';
1407  if (opts_str[0] && ((ret = av_dict_parse_string(opts, opts_str, "=", ":", 0)) < 0)) {
1408  av_freep(dev);
1409  return ret;
1410  }
1411  }
1412  } else
1413  printf("\nDevice name is not provided.\n"
1414  "You can pass devicename[,opt1=val1[,opt2=val2...]] as an argument.\n\n");
1415  return 0;
1416 }
1417 
1418 int show_sources(void *optctx, const char *opt, const char *arg)
1419 {
1420  const AVInputFormat *fmt = NULL;
1421  char *dev = NULL;
1422  AVDictionary *opts = NULL;
1423  int ret = 0;
1424  int error_level = av_log_get_level();
1425 
1427 
1428  if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
1429  goto fail;
1430 
1431  do {
1432  fmt = av_input_audio_device_next(fmt);
1433  if (fmt) {
1434  if (!strcmp(fmt->name, "lavfi"))
1435  continue; //it's pointless to probe lavfi
1436  if (dev && !av_match_name(dev, fmt->name))
1437  continue;
1438  print_device_sources(fmt, opts);
1439  }
1440  } while (fmt);
1441  do {
1442  fmt = av_input_video_device_next(fmt);
1443  if (fmt) {
1444  if (dev && !av_match_name(dev, fmt->name))
1445  continue;
1446  print_device_sources(fmt, opts);
1447  }
1448  } while (fmt);
1449  fail:
1450  av_dict_free(&opts);
1451  av_free(dev);
1452  av_log_set_level(error_level);
1453  return ret;
1454 }
1455 
1456 int show_sinks(void *optctx, const char *opt, const char *arg)
1457 {
1458  const AVOutputFormat *fmt = NULL;
1459  char *dev = NULL;
1460  AVDictionary *opts = NULL;
1461  int ret = 0;
1462  int error_level = av_log_get_level();
1463 
1465 
1466  if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
1467  goto fail;
1468 
1469  do {
1470  fmt = av_output_audio_device_next(fmt);
1471  if (fmt) {
1472  if (dev && !av_match_name(dev, fmt->name))
1473  continue;
1474  print_device_sinks(fmt, opts);
1475  }
1476  } while (fmt);
1477  do {
1478  fmt = av_output_video_device_next(fmt);
1479  if (fmt) {
1480  if (dev && !av_match_name(dev, fmt->name))
1481  continue;
1482  print_device_sinks(fmt, opts);
1483  }
1484  } while (fmt);
1485  fail:
1486  av_dict_free(&opts);
1487  av_free(dev);
1488  av_log_set_level(error_level);
1489  return ret;
1490 }
1491 #endif /* CONFIG_AVDEVICE */
show_demuxers
int show_demuxers(void *optctx, const char *opt, const char *arg)
Print a listing containing all the demuxer supported by the program (including devices).
Definition: opt_common.c:940
av_force_cpu_flags
void av_force_cpu_flags(int arg)
Disables cpu detection and forces the specified flags.
Definition: cpu.c:79
AVCodec
AVCodec.
Definition: codec.h:187
show_help_default
void show_help_default(const char *opt, const char *arg)
Per-fftool specific help handler.
Definition: ffmpeg_opt.c:1176
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:215
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
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
level
uint8_t level
Definition: svq3.c:205
avfilter_filter_pad_count
unsigned avfilter_filter_pad_count(const AVFilter *filter, int is_output)
Get the number of elements in an AVFilter's inputs or outputs array.
Definition: avfilter.c:626
AVOutputFormat::extensions
const char * extensions
comma-separated filename extensions
Definition: avformat.h:518
AVOutputFormat::name
const char * name
Definition: avformat.h:510
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:218
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
avio_protocol_get_class
const AVClass * avio_protocol_get_class(const char *name)
Get AVClass by names of available protocols.
Definition: protocols.c:114
AV_IS_INPUT_DEVICE
#define AV_IS_INPUT_DEVICE(category)
Definition: log.h:58
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:978
AVCodec::long_name
const char * long_name
Descriptive name for the codec, meant to be more human readable than name.
Definition: codec.h:199
show_filters
int show_filters(void *optctx, const char *opt, const char *arg)
Print a listing containing all the filters supported by the program.
Definition: opt_common.c:799
sws_isSupportedOutput
#define sws_isSupportedOutput(x)
AV_CODEC_PROP_LOSSY
#define AV_CODEC_PROP_LOSSY
Codec supports lossy compression.
Definition: codec_desc.h:78
av_get_sample_fmt_string
char * av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt)
Generate a string corresponding to the sample format with sample_fmt, or a header if sample_fmt is ne...
Definition: samplefmt.c:95
av_bprint_init
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition: bprint.c:69
av_cpu_force_count
void av_cpu_force_count(int count)
Overrides cpu count detection and forces the specified count.
Definition: cpu.c:271
AV_LOG_QUIET
#define AV_LOG_QUIET
Print no output.
Definition: log.h:191
AV_CODEC_CAP_HARDWARE
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: codec.h:145
AV_CODEC_CONFIG_SAMPLE_RATE
@ AV_CODEC_CONFIG_SAMPLE_RATE
int, terminated by 0
Definition: avcodec.h:2707
AV_LOG_PANIC
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
Definition: log.h:196
AVDeviceInfo::device_name
char * device_name
device name, format depends on device
Definition: avdevice.h:334
print_program_info
static void print_program_info(int flags, int level)
Definition: opt_common.c:197
version.h
AVCodecDescriptor::name
const char * name
Name of the codec described by this descriptor.
Definition: codec_desc.h:46
AVBitStreamFilter::name
const char * name
Definition: bsf.h:112
program_name
const char program_name[]
program name, defined by the program for show_version().
Definition: ffmpeg.c:85
av_unused
#define av_unused
Definition: attributes.h:131
is_device
static int is_device(const AVClass *avclass)
Definition: opt_common.c:848
AVDeviceInfoList::nb_devices
int nb_devices
number of autodetected devices
Definition: avdevice.h:345
avcodec_find_encoder
const AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
Definition: allcodecs.c:1002
show_devices
int show_devices(void *optctx, const char *opt, const char *arg)
Print a listing containing all the devices supported by the program.
Definition: opt_common.c:945
log_callback_report
static void log_callback_report(void *ptr, int level, const char *fmt, va_list vl)
Definition: opt_common.c:1135
show_formats_devices
static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers)
Definition: opt_common.c:855
pixdesc.h
SHOW_CONFIG
#define SHOW_CONFIG
Definition: opt_common.c:153
AVCodec::capabilities
int capabilities
Codec capabilities.
Definition: codec.h:206
init_report
int init_report(const char *env, FILE **file)
Definition: opt_common.c:1151
av_disposition_to_string
const char * av_disposition_to_string(int disposition)
Definition: options.c:554
opt_report
int opt_report(void *optctx, const char *opt, const char *arg)
Definition: opt_common.c:1236
AVComponentDescriptor::depth
int depth
Number of bits in the component.
Definition: pixdesc.h:57
AVPixFmtDescriptor::name
const char * name
Definition: pixdesc.h:70
show_muxdemuxers
show_muxdemuxers
Definition: opt_common.c:66
AVOption
AVOption.
Definition: opt.h:429
b
#define b
Definition: input.c:41
av_pix_fmt_desc_next
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
Iterate over all pixel format descriptors known to libavutil.
Definition: pixdesc.c:2972
show_pix_fmts
int show_pix_fmts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the pixel formats supported by the program.
Definition: opt_common.c:979
avio_enum_protocols
const char * avio_enum_protocols(void **opaque, int output)
Iterate through names of available protocols.
Definition: protocols.c:99
print_codecs_for_id
static void print_codecs_for_id(enum AVCodecID id, int encoder)
Definition: opt_common.c:619
version.h
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:225
filter
void(* filter)(uint8_t *src, int stride, int qscale)
Definition: h263dsp.c:29
PRINT_CODEC_SUPPORTED
#define PRINT_CODEC_SUPPORTED(codec, config, type, name, elem, fmt,...)
Definition: opt_common.c:265
show_help_children
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
Definition: cmdutils.c:140
av_get_bits_per_pixel
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
Definition: pixdesc.c:2917
get_media_type_char
static char get_media_type_char(enum AVMediaType type)
Definition: opt_common.c:660
max
#define max(a, b)
Definition: cuda_runtime.h:33
show_buildconf
int show_buildconf(void *optctx, const char *opt, const char *arg)
Print the build configuration of the program to stdout.
Definition: opt_common.c:257
AVDictionary
Definition: dict.c:34
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
show_dispositions
int show_dispositions(void *optctx, const char *opt, const char *arg)
Print a listing containing all supported stream dispositions.
Definition: opt_common.c:1059
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:107
AV_CODEC_CONFIG_PIX_FORMAT
@ AV_CODEC_CONFIG_PIX_FORMAT
AVPixelFormat, terminated by AV_PIX_FMT_NONE.
Definition: avcodec.h:2705
hide_banner
int hide_banner
Definition: cmdutils.c:60
tf_sess_config.config
config
Definition: tf_sess_config.py:33
SHOW_MUXERS
@ SHOW_MUXERS
Definition: opt_common.c:69
show_license
int show_license(void *optctx, const char *opt, const char *arg)
Print the license of the program to stdout.
Definition: opt_common.c:75
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:594
AVOutputFormat::subtitle_codec
enum AVCodecID subtitle_codec
default subtitle codec
Definition: avformat.h:522
av_input_audio_device_next
const av_cold AVInputFormat * av_input_audio_device_next(const AVInputFormat *d)
Audio input devices iterator.
Definition: alldevices.c:127
OptionDef
Definition: cmdutils.h:191
AVInputFormat::long_name
const char * long_name
Descriptive name for the format, meant to be more human-readable than name.
Definition: avformat.h:560
avdevice_list_output_sinks
int avdevice_list_output_sinks(const AVOutputFormat *device, const char *device_name, AVDictionary *device_options, AVDeviceInfoList **device_list)
Definition: avdevice.c:96
SHOW_DEMUXERS
@ SHOW_DEMUXERS
Definition: opt_common.c:68
av_max_alloc
void av_max_alloc(size_t max)
Set the maximum size that may be allocated in one block.
Definition: mem.c:76
rgb
Definition: rpzaenc.c:60
bsf.h
show_encoders
int show_encoders(void *optctx, const char *opt, const char *arg)
Print a listing containing all the encoders supported by the program.
Definition: opt_common.c:782
fail
#define fail()
Definition: checkasm.h:188
av_opt_get_key_value
int av_opt_get_key_value(const char **ropts, const char *key_val_sep, const char *pairs_sep, unsigned flags, char **rkey, char **rval)
Extract a key-value pair from the beginning of a string.
Definition: opt.c:1867
AV_PIX_FMT_FLAG_HWACCEL
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:128
av_filter_iterate
const AVFilter * av_filter_iterate(void **opaque)
Iterate over all registered filters.
Definition: allfilters.c:623
av_parse_cpu_caps
int av_parse_cpu_caps(unsigned *flags, const char *s)
Parse CPU caps from a string and update the given AV_CPU_* flags based on that.
Definition: cpu.c:117
AV_BPRINT_SIZE_AUTOMATIC
#define AV_BPRINT_SIZE_AUTOMATIC
val
static double val(void *priv, double ch)
Definition: aeval.c:77
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
report_file_level
static int report_file_level
Definition: opt_common.c:73
AVFILTER_FLAG_DYNAMIC_INPUTS
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition: avfilter.h:141
show_version
int show_version(void *optctx, const char *opt, const char *arg)
Print the version of the program to stdout.
Definition: opt_common.c:248
codec.h
AVRational::num
int num
Numerator.
Definition: rational.h:59
show_codecs
int show_codecs(void *optctx, const char *opt, const char *arg)
Print a listing containing all the codecs supported by the program.
Definition: opt_common.c:672
show_help_muxer
static void show_help_muxer(const char *name)
Definition: opt_common.c:466
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
FFDIFFSIGN
#define FFDIFFSIGN(x, y)
Comparator.
Definition: macros.h:45
AV_OPT_FLAG_AUDIO_PARAM
#define AV_OPT_FLAG_AUDIO_PARAM
Definition: opt.h:357
AVDeviceInfoList::devices
AVDeviceInfo ** devices
list of autodetected devices
Definition: avdevice.h:344
next_codec_for_id
static const AVCodec * next_codec_for_id(enum AVCodecID id, void **iter, int encoder)
Definition: opt_common.c:382
avassert.h
AV_LOG_TRACE
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:235
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
AV_CODEC_CAP_EXPERIMENTAL
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: codec.h:102
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
AVInputFormat
Definition: avformat.h:548
AVInputFormat::extensions
const char * extensions
If extensions are defined, then no probe is done.
Definition: avformat.h:574
avdevice_list_input_sources
int avdevice_list_input_sources(const AVInputFormat *device, const char *device_name, AVDictionary *device_options, AVDeviceInfoList **device_list)
List devices.
Definition: avdevice.c:85
postprocess.h
av_channel_layout_describe
int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
Get a human-readable string describing the channel layout properties.
Definition: channel_layout.c:648
av_log_format_line
void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, char *line, int line_size, int *print_prefix)
Format a line of log the same way as the default callback.
Definition: log.c:335
decode
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:72
report_file
static FILE * report_file
Definition: opt_common.c:72
compare_codec_desc
static int compare_codec_desc(const void *a, const void *b)
Definition: opt_common.c:632
AVCodecDescriptor
This struct describes the properties of a single codec described by an AVCodecID.
Definition: codec_desc.h:38
AV_CODEC_CONFIG_SAMPLE_FORMAT
@ AV_CODEC_CONFIG_SAMPLE_FORMAT
AVSampleFormat, terminated by AV_SAMPLE_FMT_NONE.
Definition: avcodec.h:2708
PRINT_LIB_INFO
#define PRINT_LIB_INFO(libname, LIBNAME, flags, level)
Definition: opt_common.c:156
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:553
pix_fmt
static enum AVPixelFormat pix_fmt
Definition: demux_decode.c:41
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AV_CODEC_CAP_OTHER_THREADS
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
Definition: codec.h:124
AVOutputFormat::audio_codec
enum AVCodecID audio_codec
default audio codec
Definition: avformat.h:520
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
av_channel_layout_standard
const AVChannelLayout * av_channel_layout_standard(void **opaque)
Iterate over all standard channel layouts.
Definition: channel_layout.c:847
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:230
show_bsfs
int show_bsfs(void *optctx, const char *opt, const char *arg)
Print a listing containing all the bit stream filters supported by the program.
Definition: opt_common.c:787
show_banner
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
Definition: opt_common.c:237
av_hwdevice_get_type_name
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
Definition: hwcontext.c:112
AVBitStreamFilter::codec_ids
enum AVCodecID * codec_ids
A list of codec ids supported by the filter, terminated by AV_CODEC_ID_NONE.
Definition: bsf.h:119
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
key
const char * key
Definition: hwcontext_opencl.c:189
AVMEDIA_TYPE_DATA
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition: avutil.h:203
AVDeviceInfo::media_types
enum AVMediaType * media_types
array indicating what media types(s), if any, a device can provide.
Definition: avdevice.h:336
AV_OPT_FLAG_BSF_PARAM
#define AV_OPT_FLAG_BSF_PARAM
A generic parameter which can be set by the user for bit stream filtering.
Definition: opt.h:372
arg
const char * arg
Definition: jacosubdec.c:67
AVDeviceInfo::nb_media_types
int nb_media_types
length of media_types array, 0 if device cannot provide any media types
Definition: avdevice.h:337
AV_IS_OUTPUT_DEVICE
#define AV_IS_OUTPUT_DEVICE(category)
Definition: log.h:63
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:110
av_log_get_level
int av_log_get_level(void)
Get the current log level.
Definition: log.c:442
print_codec
static void print_codec(const AVCodec *c)
Definition: opt_common.c:291
AV_CODEC_PROP_INTRA_ONLY
#define AV_CODEC_PROP_INTRA_ONLY
Codec uses only intra compression.
Definition: codec_desc.h:72
avfilter_get_by_name
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
Definition: allfilters.c:634
opts
AVDictionary * opts
Definition: movenc.c:51
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
NULL
#define NULL
Definition: coverity.c:32
avcodec_find_decoder_by_name
const AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
Definition: allcodecs.c:1035
print_all_libs_info
static void print_all_libs_info(int flags, int level)
Definition: opt_common.c:185
AVPixFmtDescriptor::nb_components
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:71
AV_CODEC_CONFIG_FRAME_RATE
@ AV_CODEC_CONFIG_FRAME_RATE
AVRational, terminated by {0, 0}.
Definition: avcodec.h:2706
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
version.h
AVOutputFormat::long_name
const char * long_name
Descriptive name for the format, meant to be more human-readable than name.
Definition: avformat.h:516
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
av_log_set_flags
void av_log_set_flags(int arg)
Definition: log.c:452
parseutils.h
opt_loglevel
int opt_loglevel(void *optctx, const char *opt, const char *arg)
Set the libav* libraries log level.
Definition: opt_common.c:1255
AVBitStreamFilter::priv_class
const AVClass * priv_class
A class for the private data, used to declare bitstream filter private AVOptions.
Definition: bsf.h:130
codecs
static const struct codec_string codecs[]
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:128
warned_cfg
static int warned_cfg
Definition: opt_common.c:149
AVOutputFormat::priv_class
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:538
AVPixFmtDescriptor::flags
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:94
AV_OPT_FLAG_ENCODING_PARAM
#define AV_OPT_FLAG_ENCODING_PARAM
A generic parameter which can be set by the user for muxing or encoding.
Definition: opt.h:352
swresample.h
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
show_sample_fmts
int show_sample_fmts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the sample formats supported by the program.
Definition: opt_common.c:1050
error.h
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:49
avcodec_find_decoder
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: allcodecs.c:1007
AVFILTER_FLAG_DYNAMIC_OUTPUTS
#define AVFILTER_FLAG_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
Definition: avfilter.h:147
AV_CODEC_CAP_CHANNEL_CONF
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:106
show_layouts
int show_layouts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the standard channel layouts supported by the program.
Definition: opt_common.c:1017
locate_option
int locate_option(int argc, char **argv, const OptionDef *options, const char *optname)
Return index of option opt in argv or 0 if not found.
Definition: cmdutils.c:486
av_codec_is_decoder
int av_codec_is_decoder(const AVCodec *codec)
Definition: utils.c:86
get_channel_layout_desc
static const char * get_channel_layout_desc(const AVChannelLayout *layout, AVBPrint *bp)
Definition: opt_common.c:281
options
const OptionDef options[]
AV_CODEC_CONFIG_CHANNEL_LAYOUT
@ AV_CODEC_CONFIG_CHANNEL_LAYOUT
AVChannelLayout, terminated by {0}.
Definition: avcodec.h:2709
AV_OPT_FLAG_FILTERING_PARAM
#define AV_OPT_FLAG_FILTERING_PARAM
A generic parameter which can be set by the user for filtering.
Definition: opt.h:381
f
f
Definition: af_crystalizer.c:122
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AV_SAMPLE_FMT_NB
@ AV_SAMPLE_FMT_NB
Number of sample formats. DO NOT USE if linking dynamically.
Definition: samplefmt.h:71
AVMediaType
AVMediaType
Definition: avutil.h:199
av_log_set_callback
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
Definition: log.c:462
av_bprint_finalize
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:240
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:311
AVClass::category
AVClassCategory category
Category used for visualization (like color).
Definition: log.h:132
cpu.h
av_err2str
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: error.h:122
av_output_video_device_next
const av_cold AVOutputFormat * av_output_video_device_next(const AVOutputFormat *d)
Video output devices iterator.
Definition: alldevices.c:142
AV_PIX_FMT_FLAG_BITSTREAM
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
Definition: pixdesc.h:124
AVDeviceInfo
Structure describes basic parameters of the device.
Definition: avdevice.h:333
av_demuxer_iterate
const AVInputFormat * av_demuxer_iterate(void **opaque)
Iterate over all registered demuxers.
Definition: allformats.c:606
printf
printf("static const uint8_t my_array[100] = {\n")
av_log_get_flags
int av_log_get_flags(void)
Definition: log.c:457
avdevice.h
avdevice_free_list_devices
void avdevice_free_list_devices(AVDeviceInfoList **device_list)
Convenient function to free result of avdevice_list_devices().
Definition: avdevice.c:107
show_protocols
int show_protocols(void *optctx, const char *opt, const char *arg)
Print a listing containing all the protocols supported by the program.
Definition: opt_common.c:950
av_channel_description
int av_channel_description(char *buf, size_t buf_size, enum AVChannel channel_id)
Get a human readable string describing a given channel.
Definition: channel_layout.c:135
encode
static void encode(AVCodecContext *ctx, AVFrame *frame, AVPacket *pkt, FILE *output)
Definition: encode_audio.c:94
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
show_decoders
int show_decoders(void *optctx, const char *opt, const char *arg)
Print a listing containing all the decoders supported by the program.
Definition: opt_common.c:777
AV_CODEC_CAP_SLICE_THREADS
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:114
line
Definition: graph2dot.c:48
av_pix_fmt_desc_get_id
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
Definition: pixdesc.c:2984
av_dict_free
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition: dict.c:223
av_strstart
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
Definition: avstring.c:36
va_copy
#define va_copy(dst, src)
Definition: va_copy.h:31
AVDeviceInfo::device_description
char * device_description
human friendly name
Definition: avdevice.h:335
show_help_bsf
static void show_help_bsf(const char *name)
Definition: opt_common.c:555
sws_isSupportedInput
#define sws_isSupportedInput(x)
AVOutputFormat::mime_type
const char * mime_type
Definition: avformat.h:517
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:220
avcodec_descriptor_next
const AVCodecDescriptor * avcodec_descriptor_next(const AVCodecDescriptor *prev)
Iterate over all codec descriptors known to libavcodec.
Definition: codec_desc.c:3747
av_codec_is_encoder
int av_codec_is_encoder(const AVCodec *codec)
Definition: utils.c:78
layout
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 layout
Definition: filter_design.txt:18
AV_CODEC_PROP_LOSSLESS
#define AV_CODEC_PROP_LOSSLESS
Codec supports lossless compression.
Definition: codec_desc.h:82
av_log_set_level
void av_log_set_level(int level)
Set the log level.
Definition: log.c:447
bprint.h
INDENT
#define INDENT
Definition: opt_common.c:151
get_codecs_sorted
static int get_codecs_sorted(const AVCodecDescriptor ***rcodecs)
Definition: opt_common.c:641
show_colors
int show_colors(void *optctx, const char *opt, const char *arg)
Print a listing containing all the color names and values recognized by the program.
Definition: opt_common.c:965
SHOW_VERSION
#define SHOW_VERSION
Definition: opt_common.c:152
log.h
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
AVOutputFormat
Definition: avformat.h:509
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
av_channel_name
int av_channel_name(char *buf, size_t buf_size, enum AVChannel channel_id)
Get a human readable string in an abbreviated form describing a given channel.
Definition: channel_layout.c:102
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
print_codecs
static int print_codecs(int encoder)
Definition: opt_common.c:733
AVMEDIA_TYPE_ATTACHMENT
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
Definition: avutil.h:205
AV_OPT_FLAG_VIDEO_PARAM
#define AV_OPT_FLAG_VIDEO_PARAM
Definition: opt.h:358
show_help_demuxer
static void show_help_demuxer(const char *name)
Definition: opt_common.c:430
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
opt_max_alloc
int opt_max_alloc(void *optctx, const char *opt, const char *arg)
Definition: opt_common.c:1241
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:264
av_codec_iterate
const AVCodec * av_codec_iterate(void **opaque)
Iterate over all registered codecs.
Definition: allcodecs.c:958
show_help_protocol
static void show_help_protocol(const char *name)
Definition: opt_common.c:448
avcodec.h
AVFilter
Filter definition.
Definition: avfilter.h:201
version.h
version.h
version.h
ret
ret
Definition: filter_design.txt:187
AV_LOG_FATAL
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:203
av_bsf_iterate
const AVBitStreamFilter * av_bsf_iterate(void **opaque)
Iterate over all registered bitstream filters.
Definition: bitstream_filters.c:75
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:80
av_opt_eval_int
int av_opt_eval_int(void *obj, const AVOption *o, const char *val, int *int_out)
AVDeviceInfoList
List of devices.
Definition: avdevice.h:343
log_callback_help
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
Definition: cmdutils.c:70
show_muxers
int show_muxers(void *optctx, const char *opt, const char *arg)
Print a listing containing all the muxers supported by the program (including devices).
Definition: opt_common.c:935
avformat.h
av_bprintf
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:99
dict.h
opt_cpucount
int opt_cpucount(void *optctx, const char *opt, const char *arg)
Override the cpucount.
Definition: opt_common.c:1081
AV_LOG_SKIP_REPEATED
#define AV_LOG_SKIP_REPEATED
Skip repeated messages, this requires the user app to use av_log() instead of (f)printf as the 2 woul...
Definition: log.h:399
U
#define U(x)
Definition: vpx_arith.h:37
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:983
av_get_media_type_string
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
Definition: utils.c:28
av_muxer_iterate
const AVOutputFormat * av_muxer_iterate(void **opaque)
Iterate over all registered muxers.
Definition: allformats.c:585
AVDeviceInfoList::default_device
int default_device
index of default device or -1 if no default
Definition: avdevice.h:346
channel_layout.h
show_formats
int show_formats(void *optctx, const char *opt, const char *arg)
Print a listing containing all the formats supported by the program (including devices).
Definition: opt_common.c:930
AVBitStreamFilter
Definition: bsf.h:111
av_channel_layout_index_from_channel
int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout, enum AVChannel channel)
Get the index of a given channel in a channel layout.
Definition: channel_layout.c:708
opt_common.h
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
av_bprint_clear
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
Definition: bprint.c:232
version.h
av_match_name
int av_match_name(const char *name, const char *names)
Match instances of a name in a comma-separated list of names.
Definition: avstring.c:345
av_dict_parse_string
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
Definition: dict.c:200
print_buildconf
static void print_buildconf(int flags, int level)
Definition: opt_common.c:211
opt_cpuflags
int opt_cpuflags(void *optctx, const char *opt, const char *arg)
Override the cpuflags.
Definition: opt_common.c:1069
swscale
static int swscale(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[], int dstSliceY, int dstSliceH)
Definition: swscale.c:236
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:105
AVOutputFormat::video_codec
enum AVCodecID video_codec
default video codec
Definition: avformat.h:521
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:76
av_find_input_format
const AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
Definition: format.c:144
avcodec_get_hw_config
const AVCodecHWConfig * avcodec_get_hw_config(const AVCodec *codec, int index)
Retrieve supported hardware configurations for a codec.
Definition: utils.c:833
SHOW_DEFAULT
@ SHOW_DEFAULT
Definition: opt_common.c:67
AV_CODEC_CAP_PARAM_CHANGE
#define AV_CODEC_CAP_PARAM_CHANGE
Codec supports changed parameters at any point.
Definition: codec.h:118
expand_filename_template
static void expand_filename_template(AVBPrint *bp, const char *template, struct tm *tm)
Definition: opt_common.c:1107
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:152
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:272
AV_OPT_FLAG_DECODING_PARAM
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
Definition: opt.h:356
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
av_log_default_callback
void av_log_default_callback(void *ptr, int level, const char *fmt, va_list vl)
Default logging callback.
Definition: log.c:353
av_guess_format
const AVOutputFormat * av_guess_format(const char *short_name, const char *filename, const char *mime_type)
Return the output format in the list of registered output formats which best matches the provided par...
Definition: format.c:79
mem.h
av_output_audio_device_next
const av_cold AVOutputFormat * av_output_audio_device_next(const AVOutputFormat *d)
Audio output devices iterator.
Definition: alldevices.c:137
AV_CODEC_CAP_HYBRID
#define AV_CODEC_CAP_HYBRID
Codec is potentially backed by a hardware implementation, but not necessarily.
Definition: codec.h:152
av_get_known_color_name
const char * av_get_known_color_name(int color_idx, const uint8_t **rgbp)
Get the name of a color from the internal table of hard-coded named colors.
Definition: parseutils.c:436
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
SHOW_COPYRIGHT
#define SHOW_COPYRIGHT
Definition: opt_common.c:154
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
AVFILTER_FLAG_SUPPORT_TIMELINE
#define AVFILTER_FLAG_SUPPORT_TIMELINE
Handy mask to test whether the filter supports or no the timeline feature (internally or generically)...
Definition: avfilter.h:195
show_help_codec
static void show_help_codec(const char *name, int encoder)
Definition: opt_common.c:394
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
cmdutils.h
show_help
int show_help(void *optctx, const char *opt, const char *arg)
Generic -h handler common to all fftools.
Definition: opt_common.c:581
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
rgb
static const SheerTable rgb[2]
Definition: sheervideodata.h:32
AV_CODEC_CAP_DRAW_HORIZ_BAND
#define AV_CODEC_CAP_DRAW_HORIZ_BAND
Decoder can use draw_horiz_band callback.
Definition: codec.h:44
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AV_CODEC_CAP_AVOID_PROBING
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
Definition: codec.h:138
AVCodecHWConfig
Definition: codec.h:345
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:145
avcodec_descriptor_get
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
Definition: codec_desc.c:3741
av_input_video_device_next
const av_cold AVInputFormat * av_input_video_device_next(const AVInputFormat *d)
Video input devices iterator.
Definition: alldevices.c:132
avstring.h
avcodec_descriptor_get_by_name
const AVCodecDescriptor * avcodec_descriptor_get_by_name(const char *name)
Definition: codec_desc.c:3756
AV_CODEC_CAP_SMALL_LAST_FRAME
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
Definition: codec.h:81
codec_desc.h
AV_PIX_FMT_FLAG_PAL
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Definition: pixdesc.h:120
AV_LOG_PRINT_LEVEL
#define AV_LOG_PRINT_LEVEL
Include the log severity in messages originating from codecs.
Definition: log.h:407
swscale.h
AVInputFormat::priv_class
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:578
av_x_if_null
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
Definition: avutil.h:312
version.h
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:2885
avcodec_find_encoder_by_name
const AVCodec * avcodec_find_encoder_by_name(const char *name)
Find a registered encoder with the specified name.
Definition: allcodecs.c:1030
program_birth_year
const int program_birth_year
program birth year, defined by the program for show_banner()
Definition: ffmpeg.c:86
av_bsf_get_by_name
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
Definition: bitstream_filters.c:87