FFmpeg
ffmpeg_opt.c
Go to the documentation of this file.
1 /*
2  * ffmpeg option parsing
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 <stdint.h>
24 
25 #if HAVE_SYS_RESOURCE_H
26 #include <sys/time.h>
27 #include <sys/resource.h>
28 #endif
29 
30 #include "ffmpeg.h"
31 #include "ffmpeg_sched.h"
32 #include "cmdutils.h"
33 #include "opt_common.h"
34 
35 #include "libavformat/avformat.h"
36 
37 #include "libavcodec/avcodec.h"
38 #include "libavcodec/bsf.h"
39 
40 #include "libavfilter/avfilter.h"
41 
42 #include "libavutil/avassert.h"
43 #include "libavutil/avstring.h"
44 #include "libavutil/avutil.h"
45 #include "libavutil/mathematics.h"
46 #include "libavutil/mem.h"
47 #include "libavutil/opt.h"
48 #include "libavutil/parseutils.h"
49 #include "libavutil/stereo3d.h"
50 #include "graph/graphprint.h"
51 
53 
55 
57 float dts_error_threshold = 3600*30;
58 
59 #if FFMPEG_OPT_VSYNC
61 #endif
63 int do_benchmark = 0;
65 int do_hex_dump = 0;
66 int do_pkt_dump = 0;
67 int copy_ts = 0;
68 int start_at_zero = 0;
69 int copy_tb = -1;
70 int debug_ts = 0;
71 int exit_on_error = 0;
73 int print_stats = -1;
75 float max_error_rate = 2.0/3;
80 int print_graphs = 0;
85 
86 
87 static int file_overwrite = 0;
88 static int no_file_overwrite = 0;
91 int recast_media = 0;
92 
93 // this struct is passed as the optctx argument
94 // to func_arg() for global options
95 typedef struct GlobalOptionsContext {
97 
98  char **filtergraphs;
101 
103 {
104  /* all OPT_SPEC and OPT_TYPE_STRING can be freed in generic way */
105  for (const OptionDef *po = options; po->name; po++) {
106  void *dst;
107 
108  if (!(po->flags & OPT_FLAG_OFFSET))
109  continue;
110 
111  dst = (uint8_t*)o + po->u.off;
112  if (po->flags & OPT_FLAG_SPEC) {
113  SpecifierOptList *so = dst;
114  for (int i = 0; i < so->nb_opt; i++) {
115  av_freep(&so->opt[i].specifier);
116  if (po->flags & OPT_FLAG_PERSTREAM)
118  if (po->type == OPT_TYPE_STRING)
119  av_freep(&so->opt[i].u.str);
120  }
121  av_freep(&so->opt);
122  so->nb_opt = 0;
123  } else if (po->type == OPT_TYPE_STRING)
124  av_freep(dst);
125  }
126 
127  for (int i = 0; i < o->nb_stream_maps; i++)
129  av_freep(&o->stream_maps);
130 
131  for (int i = 0; i < o->nb_attachments; i++)
132  av_freep(&o->attachments[i]);
133  av_freep(&o->attachments);
134 
135  av_dict_free(&o->streamid);
136 }
137 
139 {
140  memset(o, 0, sizeof(*o));
141 
142  o->stop_time = INT64_MAX;
143  o->mux_max_delay = 0.7;
146  o->recording_time = INT64_MAX;
147  o->limit_filesize = INT64_MAX;
148  o->chapters_input_file = INT_MAX;
149  o->accurate_seek = 1;
150  o->thread_queue_size = 0;
151  o->input_sync_ref = -1;
152  o->find_stream_info = 1;
153  o->shortest_buf_duration = 10.f;
154 }
155 
156 static int show_hwaccels(void *optctx, const char *opt, const char *arg)
157 {
159 
160  printf("Hardware acceleration methods:\n");
161  while ((type = av_hwdevice_iterate_types(type)) !=
164  printf("\n");
165  return 0;
166 }
167 
169  char mediatype)
170 {
171  av_assert0(!sol->nb_opt || sol->type == OPT_TYPE_STRING);
172 
173  for (int i = 0; i < sol->nb_opt; i++) {
174  const char *spec = sol->opt[i].specifier;
175  if (spec[0] == mediatype && !spec[1])
176  return sol->opt[i].u.str;
177  }
178  return NULL;
179 }
180 
181 static unsigned opt_match_per_stream(void *logctx, enum OptionType type,
182  const SpecifierOptList *sol,
184 {
185  int matches = 0, match_idx = -1;
186 
187  av_assert0((type == sol->type) || !sol->nb_opt);
188 
189  for (int i = 0; i < sol->nb_opt; i++) {
190  const StreamSpecifier *ss = &sol->opt[i].stream_spec;
191 
192  if (stream_specifier_match(ss, fc, st, logctx)) {
193  match_idx = i;
194  matches++;
195  }
196  }
197 
198  if (matches > 1 && sol->opt_canon) {
199  const SpecifierOpt *so = &sol->opt[match_idx];
200  const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";
201 
202  char namestr[128] = "";
203  char optval_buf[32];
204  const char *optval = optval_buf;
205 
206  snprintf(namestr, sizeof(namestr), "-%s", sol->opt_canon->name);
207  if (sol->opt_canon->flags & OPT_HAS_ALT) {
208  const char * const *names_alt = sol->opt_canon->u1.names_alt;
209  for (int i = 0; names_alt[i]; i++)
210  av_strlcatf(namestr, sizeof(namestr), "/-%s", names_alt[i]);
211  }
212 
213  switch (sol->type) {
214  case OPT_TYPE_STRING: optval = so->u.str; break;
215  case OPT_TYPE_INT: snprintf(optval_buf, sizeof(optval_buf), "%d", so->u.i); break;
216  case OPT_TYPE_INT64: snprintf(optval_buf, sizeof(optval_buf), "%"PRId64, so->u.i64); break;
217  case OPT_TYPE_FLOAT: snprintf(optval_buf, sizeof(optval_buf), "%f", so->u.f); break;
218  case OPT_TYPE_DOUBLE: snprintf(optval_buf, sizeof(optval_buf), "%f", so->u.dbl); break;
219  default: av_assert0(0);
220  }
221 
222  av_log(logctx, AV_LOG_WARNING, "Multiple %s options specified for "
223  "stream %d, only the last option '-%s%s%s %s' will be used.\n",
224  namestr, st->index, sol->opt_canon->name, spec[0] ? ":" : "",
225  spec, optval);
226  }
227 
228  return match_idx + 1;
229 }
230 
231 #define OPT_MATCH_PER_STREAM(name, type, opt_type, m) \
232 void opt_match_per_stream_ ## name(void *logctx, const SpecifierOptList *sol, \
233  AVFormatContext *fc, AVStream *st, type *out) \
234 { \
235  unsigned ret = opt_match_per_stream(logctx, opt_type, sol, fc, st); \
236  if (ret > 0) \
237  *out = sol->opt[ret - 1].u.m; \
238 }
239 
240 OPT_MATCH_PER_STREAM(str, const char *, OPT_TYPE_STRING, str);
243 OPT_MATCH_PER_STREAM(dbl, double, OPT_TYPE_DOUBLE, dbl);
244 
245 static unsigned opt_match_per_stream_group(void *logctx, enum OptionType type,
246  const SpecifierOptList *sol,
248 {
249  int matches = 0, match_idx = -1;
250 
251  av_assert0((type == sol->type) || !sol->nb_opt);
252 
253  for (int i = 0; i < sol->nb_opt; i++) {
254  const StreamSpecifier *ss = &sol->opt[i].stream_spec;
255 
256  if (stream_group_specifier_match(ss, fc, stg, logctx)) {
257  match_idx = i;
258  matches++;
259  }
260  }
261 
262  if (matches > 1 && sol->opt_canon) {
263  const SpecifierOpt *so = &sol->opt[match_idx];
264  const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";
265 
266  char namestr[128] = "";
267  char optval_buf[32];
268  const char *optval = optval_buf;
269 
270  snprintf(namestr, sizeof(namestr), "-%s", sol->opt_canon->name);
271  if (sol->opt_canon->flags & OPT_HAS_ALT) {
272  const char * const *names_alt = sol->opt_canon->u1.names_alt;
273  for (int i = 0; names_alt[i]; i++)
274  av_strlcatf(namestr, sizeof(namestr), "/-%s", names_alt[i]);
275  }
276 
277  switch (sol->type) {
278  case OPT_TYPE_STRING: optval = so->u.str; break;
279  case OPT_TYPE_INT: snprintf(optval_buf, sizeof(optval_buf), "%d", so->u.i); break;
280  case OPT_TYPE_INT64: snprintf(optval_buf, sizeof(optval_buf), "%"PRId64, so->u.i64); break;
281  case OPT_TYPE_FLOAT: snprintf(optval_buf, sizeof(optval_buf), "%f", so->u.f); break;
282  case OPT_TYPE_DOUBLE: snprintf(optval_buf, sizeof(optval_buf), "%f", so->u.dbl); break;
283  default: av_assert0(0);
284  }
285 
286  av_log(logctx, AV_LOG_WARNING, "Multiple %s options specified for "
287  "stream group %d, only the last option '-%s%s%s %s' will be used.\n",
288  namestr, stg->index, sol->opt_canon->name, spec[0] ? ":" : "",
289  spec, optval);
290  }
291 
292  return match_idx + 1;
293 }
294 
295 #define OPT_MATCH_PER_STREAM_GROUP(name, type, opt_type, m) \
296 void opt_match_per_stream_group_ ## name(void *logctx, const SpecifierOptList *sol, \
297  AVFormatContext *fc, AVStreamGroup *stg, type *out) \
298 { \
299  unsigned ret = opt_match_per_stream_group(logctx, opt_type, sol, fc, stg); \
300  if (ret > 0) \
301  *out = sol->opt[ret - 1].u.m; \
302 }
303 
304 OPT_MATCH_PER_STREAM_GROUP(str, const char *, OPT_TYPE_STRING, str);
308 
309 int view_specifier_parse(const char **pspec, ViewSpecifier *vs)
310 {
311  const char *spec = *pspec;
312  char *endptr;
313 
315 
316  if (!strncmp(spec, "view:", 5)) {
317  spec += 5;
318 
319  if (!strncmp(spec, "all", 3)) {
320  spec += 3;
322  } else {
324  vs->val = strtoul(spec, &endptr, 0);
325  if (endptr == spec) {
326  av_log(NULL, AV_LOG_ERROR, "Invalid view ID: %s\n", spec);
327  return AVERROR(EINVAL);
328  }
329  spec = endptr;
330  }
331  } else if (!strncmp(spec, "vidx:", 5)) {
332  spec += 5;
334  vs->val = strtoul(spec, &endptr, 0);
335  if (endptr == spec) {
336  av_log(NULL, AV_LOG_ERROR, "Invalid view index: %s\n", spec);
337  return AVERROR(EINVAL);
338  }
339  spec = endptr;
340  } else if (!strncmp(spec, "vpos:", 5)) {
341  spec += 5;
343 
344  if (!strncmp(spec, "left", 4) && !cmdutils_isalnum(spec[4])) {
345  spec += 4;
347  } else if (!strncmp(spec, "right", 5) && !cmdutils_isalnum(spec[5])) {
348  spec += 5;
350  } else {
351  av_log(NULL, AV_LOG_ERROR, "Invalid view position: %s\n", spec);
352  return AVERROR(EINVAL);
353  }
354  } else
355  return 0;
356 
357  *pspec = spec;
358 
359  return 0;
360 }
361 
362 int parse_and_set_vsync(const char *arg, enum VideoSyncMethod *vsync_var, int file_idx, int st_idx, int is_global)
363 {
364  if (!av_strcasecmp(arg, "cfr")) *vsync_var = VSYNC_CFR;
365  else if (!av_strcasecmp(arg, "vfr")) *vsync_var = VSYNC_VFR;
366  else if (!av_strcasecmp(arg, "passthrough")) *vsync_var = VSYNC_PASSTHROUGH;
367 #if FFMPEG_OPT_VSYNC_DROP
368  else if (!av_strcasecmp(arg, "drop")) {
369  av_log(NULL, AV_LOG_WARNING, "-vsync/fps_mode drop is deprecated\n");
370  *vsync_var = VSYNC_DROP;
371  }
372 #endif
373  else if (!is_global && !av_strcasecmp(arg, "auto")) *vsync_var = VSYNC_AUTO;
374  else if (!is_global) {
375  av_log(NULL, AV_LOG_FATAL, "Invalid value %s specified for fps_mode of #%d:%d.\n", arg, file_idx, st_idx);
376  return AVERROR(EINVAL);
377  }
378 
379 #if FFMPEG_OPT_VSYNC
380  if (is_global && *vsync_var == VSYNC_AUTO) {
381  int ret;
382  double num;
383 
384  ret = parse_number("vsync", arg, OPT_TYPE_INT, VSYNC_AUTO, VSYNC_VFR, &num);
385  if (ret < 0)
386  return ret;
387 
388  video_sync_method = num;
389  av_log(NULL, AV_LOG_WARNING, "Passing a number to -vsync is deprecated,"
390  " use a string argument as described in the manual.\n");
391  }
392 #endif
393 
394  return 0;
395 }
396 
397 /* Correct input file start times based on enabled streams */
398 static void correct_input_start_times(void)
399 {
400  for (int i = 0; i < nb_input_files; i++) {
401  InputFile *ifile = input_files[i];
402  AVFormatContext *is = ifile->ctx;
403  int64_t new_start_time = INT64_MAX, diff, abs_start_seek;
404 
405  ifile->start_time_effective = is->start_time;
406 
407  if (is->start_time == AV_NOPTS_VALUE ||
408  !(is->iformat->flags & AVFMT_TS_DISCONT))
409  continue;
410 
411  for (int j = 0; j < is->nb_streams; j++) {
412  AVStream *st = is->streams[j];
413  if(st->discard == AVDISCARD_ALL || st->start_time == AV_NOPTS_VALUE)
414  continue;
415  new_start_time = FFMIN(new_start_time, av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q));
416  }
417 
418  diff = new_start_time - is->start_time;
419  if (diff) {
420  av_log(NULL, AV_LOG_VERBOSE, "Correcting start time of Input #%d by %"PRId64" us.\n", i, diff);
421  ifile->start_time_effective = new_start_time;
422  if (copy_ts && start_at_zero)
423  ifile->ts_offset = -new_start_time;
424  else if (!copy_ts) {
425  abs_start_seek = is->start_time + ((ifile->start_time != AV_NOPTS_VALUE) ? ifile->start_time : 0);
426  ifile->ts_offset = abs_start_seek > new_start_time ? -abs_start_seek : -new_start_time;
427  } else if (copy_ts)
428  ifile->ts_offset = 0;
429 
430  ifile->ts_offset += ifile->input_ts_offset;
431  }
432  }
433 }
434 
435 static int apply_sync_offsets(void)
436 {
437  for (int i = 0; i < nb_input_files; i++) {
438  InputFile *ref, *self = input_files[i];
439  int64_t adjustment;
440  int64_t self_start_time, ref_start_time, self_seek_start, ref_seek_start;
441  int start_times_set = 1;
442 
443  if (self->input_sync_ref == -1 || self->input_sync_ref == i) continue;
444  if (self->input_sync_ref >= nb_input_files || self->input_sync_ref < -1) {
445  av_log(NULL, AV_LOG_FATAL, "-isync for input %d references non-existent input %d.\n", i, self->input_sync_ref);
446  return AVERROR(EINVAL);
447  }
448 
449  if (copy_ts && !start_at_zero) {
450  av_log(NULL, AV_LOG_FATAL, "Use of -isync requires that start_at_zero be set if copyts is set.\n");
451  return AVERROR(EINVAL);
452  }
453 
454  ref = input_files[self->input_sync_ref];
455  if (ref->input_sync_ref != -1 && ref->input_sync_ref != self->input_sync_ref) {
456  av_log(NULL, AV_LOG_ERROR, "-isync for input %d references a resynced input %d. Sync not set.\n", i, self->input_sync_ref);
457  continue;
458  }
459 
460  if (self->ctx->start_time_realtime != AV_NOPTS_VALUE && ref->ctx->start_time_realtime != AV_NOPTS_VALUE) {
461  self_start_time = self->ctx->start_time_realtime;
462  ref_start_time = ref->ctx->start_time_realtime;
463  } else if (self->start_time_effective != AV_NOPTS_VALUE && ref->start_time_effective != AV_NOPTS_VALUE) {
464  self_start_time = self->start_time_effective;
465  ref_start_time = ref->start_time_effective;
466  } else {
467  start_times_set = 0;
468  }
469 
470  if (start_times_set) {
471  self_seek_start = self->start_time == AV_NOPTS_VALUE ? 0 : self->start_time;
472  ref_seek_start = ref->start_time == AV_NOPTS_VALUE ? 0 : ref->start_time;
473 
474  adjustment = (self_start_time - ref_start_time) + !copy_ts*(self_seek_start - ref_seek_start) + ref->input_ts_offset;
475 
476  self->ts_offset += adjustment;
477 
478  av_log(NULL, AV_LOG_INFO, "Adjusted ts offset for Input #%d by %"PRId64" us to sync with Input #%d.\n", i, adjustment, self->input_sync_ref);
479  } else {
480  av_log(NULL, AV_LOG_INFO, "Unable to identify start times for Inputs #%d and %d both. No sync adjustment made.\n", i, self->input_sync_ref);
481  }
482  }
483 
484  return 0;
485 }
486 
487 static int opt_filter_threads(void *optctx, const char *opt, const char *arg)
488 {
491  return 0;
492 }
493 
494 static int opt_abort_on(void *optctx, const char *opt, const char *arg)
495 {
496  static const AVOption opts[] = {
497  { "abort_on" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, (double)INT64_MAX, .unit = "flags" },
498  { "empty_output" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = ABORT_ON_FLAG_EMPTY_OUTPUT }, .unit = "flags" },
499  { "empty_output_stream", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM }, .unit = "flags" },
500  { NULL },
501  };
502  static const AVClass class = {
503  .class_name = "",
504  .item_name = av_default_item_name,
505  .option = opts,
506  .version = LIBAVUTIL_VERSION_INT,
507  };
508  const AVClass *pclass = &class;
509 
510  return av_opt_eval_flags(&pclass, &opts[0], arg, &abort_on_flags);
511 }
512 
513 static int opt_stats_period(void *optctx, const char *opt, const char *arg)
514 {
515  int64_t user_stats_period;
516  int ret = av_parse_time(&user_stats_period, arg, 1);
517  if (ret < 0)
518  return ret;
519 
520  if (user_stats_period <= 0) {
521  av_log(NULL, AV_LOG_ERROR, "stats_period %s must be positive.\n", arg);
522  return AVERROR(EINVAL);
523  }
524 
525  stats_period = user_stats_period;
526  av_log(NULL, AV_LOG_INFO, "ffmpeg stats and -progress period set to %s.\n", arg);
527 
528  return 0;
529 }
530 
531 static int opt_audio_codec(void *optctx, const char *opt, const char *arg)
532 {
533  OptionsContext *o = optctx;
534  return parse_option(o, "codec:a", arg, options);
535 }
536 
537 static int opt_video_codec(void *optctx, const char *opt, const char *arg)
538 {
539  OptionsContext *o = optctx;
540  return parse_option(o, "codec:v", arg, options);
541 }
542 
543 static int opt_subtitle_codec(void *optctx, const char *opt, const char *arg)
544 {
545  OptionsContext *o = optctx;
546  return parse_option(o, "codec:s", arg, options);
547 }
548 
549 static int opt_data_codec(void *optctx, const char *opt, const char *arg)
550 {
551  OptionsContext *o = optctx;
552  return parse_option(o, "codec:d", arg, options);
553 }
554 
555 static int opt_map(void *optctx, const char *opt, const char *arg)
556 {
557  OptionsContext *o = optctx;
558  StreamMap *m = NULL;
560  int i, negative = 0, file_idx, disabled = 0;
561  int ret, allow_unused = 0;
562 
563  memset(&ss, 0, sizeof(ss));
564 
565  if (*arg == '-') {
566  negative = 1;
567  arg++;
568  }
569 
570  if (arg[0] == '[') {
571  ViewSpecifier vs;
572  /* this mapping refers to lavfi output */
573  const char *c = arg + 1;
574  char *endptr;
575 
577  if (ret < 0)
578  goto fail;
579 
580  m = &o->stream_maps[o->nb_stream_maps - 1];
581  m->linklabel = av_get_token(&c, "]");
582  if (!m->linklabel) {
583  av_log(NULL, AV_LOG_ERROR, "Invalid output link label: %s.\n", arg);
584  ret = AVERROR(EINVAL);
585  goto fail;
586  }
587 
588  arg++;
589 
590  m->group_index = -1;
591  file_idx = strtol(arg, &endptr, 0);
592  if (file_idx >= nb_input_files || file_idx < 0)
593  goto end;
594 
595  arg = endptr;
596  ret = stream_specifier_parse(&ss, *arg == ':' ? arg + 1 : arg, 1, NULL);
597  if (ret < 0)
598  goto end;
599 
600  arg = ss.remainder ? ss.remainder : "";
601  ret = view_specifier_parse(&arg, &vs);
602  if (ret < 0 || (*arg && strcmp(arg, "]")))
603  goto end;
604 
605  m->file_index = file_idx;
606  m->stream_index = ss.idx;
607  m->group_index = ss.stream_list == STREAM_LIST_GROUP_IDX ? ss.list_id : -1;
608  } else {
609  ViewSpecifier vs;
610  char *endptr;
611 
612  file_idx = strtol(arg, &endptr, 0);
613  if (file_idx >= nb_input_files || file_idx < 0) {
614  av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx);
615  ret = AVERROR(EINVAL);
616  goto fail;
617  }
618  arg = endptr;
619 
620  ret = stream_specifier_parse(&ss, *arg == ':' ? arg + 1 : arg, 1, NULL);
621  if (ret < 0) {
622  av_log(NULL, AV_LOG_ERROR, "Invalid stream specifier: %s\n", arg);
623  goto fail;
624  }
625 
626  arg = ss.remainder ? ss.remainder : "";
627 
628  ret = view_specifier_parse(&arg, &vs);
629  if (ret < 0)
630  goto fail;
631 
632  if (*arg) {
633  if (!strcmp(arg, "?"))
634  allow_unused = 1;
635  else {
637  "Trailing garbage after stream specifier: %s\n", arg);
638  ret = AVERROR(EINVAL);
639  goto fail;
640  }
641  }
642 
643  if (negative)
644  /* disable some already defined maps */
645  for (i = 0; i < o->nb_stream_maps; i++) {
646  m = &o->stream_maps[i];
647  if (file_idx == m->file_index &&
648  !m->linklabel &&
649  m->stream_index >= 0 &&
654  NULL))
655  m->disabled = 1;
656  }
657  else
658  for (i = 0; i < input_files[file_idx]->nb_streams; i++) {
660  input_files[file_idx]->ctx,
661  input_files[file_idx]->ctx->streams[i],
662  NULL))
663  continue;
664  if (input_files[file_idx]->streams[i]->user_set_discard == AVDISCARD_ALL) {
665  disabled = 1;
666  continue;
667  }
669  if (ret < 0)
670  goto fail;
671 
672  m = &o->stream_maps[o->nb_stream_maps - 1];
673 
674  m->file_index = file_idx;
675  m->stream_index = i;
676  m->group_index = ss.stream_list == STREAM_LIST_GROUP_IDX ? ss.list_id : -1;
677  m->vs = vs;
678  }
679  }
680 
681  if (!m) {
682  if (allow_unused) {
683  av_log(NULL, AV_LOG_VERBOSE, "Stream map '%s' matches no streams; ignoring.\n", arg);
684  } else if (disabled) {
685  av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches disabled streams.\n"
686  "To ignore this, add a trailing '?' to the map.\n", arg);
687  ret = AVERROR(EINVAL);
688  goto fail;
689  } else {
690  av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n"
691  "To ignore this, add a trailing '?' to the map.\n", arg);
692  ret = AVERROR(EINVAL);
693  goto fail;
694  }
695  }
696 end:
697  ret = 0;
698 fail:
700  return ret;
701 }
702 
703 static int opt_attach(void *optctx, const char *opt, const char *arg)
704 {
705  OptionsContext *o = optctx;
707  if (ret < 0)
708  return ret;
709 
710  o->attachments[o->nb_attachments - 1] = av_strdup(arg);
711  if (!o->attachments[o->nb_attachments - 1])
712  return AVERROR(ENOMEM);
713 
714  return 0;
715 }
716 
717 static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
718 {
719  GlobalOptionsContext *go = optctx;
720  return sch_sdp_filename(go->sch, arg);
721 }
722 
723 #if CONFIG_VAAPI
724 static int opt_vaapi_device(void *optctx, const char *opt, const char *arg)
725 {
726  const char *prefix = "vaapi:";
727  char *tmp;
728  int err;
729  tmp = av_asprintf("%s%s", prefix, arg);
730  if (!tmp)
731  return AVERROR(ENOMEM);
733  av_free(tmp);
734  return err;
735 }
736 #endif
737 
738 #if CONFIG_QSV
739 static int opt_qsv_device(void *optctx, const char *opt, const char *arg)
740 {
741  const char *prefix = "qsv=__qsv_device:hw_any,child_device=";
742  int err;
743  char *tmp = av_asprintf("%s%s", prefix, arg);
744 
745  if (!tmp)
746  return AVERROR(ENOMEM);
747 
749  av_free(tmp);
750 
751  return err;
752 }
753 #endif
754 
755 static int opt_init_hw_device(void *optctx, const char *opt, const char *arg)
756 {
757  if (!strcmp(arg, "list")) {
759  printf("Supported hardware device types:\n");
760  while ((type = av_hwdevice_iterate_types(type)) !=
763  printf("\n");
764  return AVERROR_EXIT;
765  } else {
767  }
768 }
769 
770 static int opt_filter_hw_device(void *optctx, const char *opt, const char *arg)
771 {
772  if (filter_hw_device) {
773  av_log(NULL, AV_LOG_ERROR, "Only one filter device can be used.\n");
774  return AVERROR(EINVAL);
775  }
777  if (!filter_hw_device) {
778  av_log(NULL, AV_LOG_ERROR, "Invalid filter device %s.\n", arg);
779  return AVERROR(EINVAL);
780  }
781  return 0;
782 }
783 
784 static int opt_recording_timestamp(void *optctx, const char *opt, const char *arg)
785 {
786  OptionsContext *o = optctx;
787  char buf[128];
788  int64_t recording_timestamp;
789  int ret;
790  struct tm time;
791 
792  ret = av_parse_time(&recording_timestamp, arg, 0);
793  if (ret < 0)
794  return ret;
795 
796  recording_timestamp /= 1e6;
797  time = *gmtime((time_t*)&recording_timestamp);
798  if (!strftime(buf, sizeof(buf), "creation_time=%Y-%m-%dT%H:%M:%S%z", &time))
799  return -1;
800  parse_option(o, "metadata", buf, options);
801 
802  av_log(NULL, AV_LOG_WARNING, "%s is deprecated, set the 'creation_time' metadata "
803  "tag instead.\n", opt);
804  return 0;
805 }
806 
807 int find_codec(void *logctx, const char *name,
808  enum AVMediaType type, int encoder, const AVCodec **pcodec)
809 {
810  const AVCodecDescriptor *desc;
811  const char *codec_string = encoder ? "encoder" : "decoder";
812  const AVCodec *codec;
813 
814  codec = encoder ?
817 
818  if (!codec && (desc = avcodec_descriptor_get_by_name(name))) {
819  codec = encoder ? avcodec_find_encoder(desc->id) :
821  if (codec)
822  av_log(logctx, AV_LOG_VERBOSE, "Matched %s '%s' for codec '%s'.\n",
823  codec_string, codec->name, desc->name);
824  }
825 
826  if (!codec) {
827  av_log(logctx, AV_LOG_FATAL, "Unknown %s '%s'\n", codec_string, name);
828  return encoder ? AVERROR_ENCODER_NOT_FOUND :
830  }
831  if (codec->type != type && !recast_media) {
832  av_log(logctx, AV_LOG_FATAL, "Invalid %s type '%s'\n", codec_string, name);
833  return AVERROR(EINVAL);
834  }
835 
836  *pcodec = codec;
837  return 0;;
838 }
839 
840 int assert_file_overwrite(const char *filename)
841 {
842  const char *proto_name = avio_find_protocol_name(filename);
843 
845  fprintf(stderr, "Error, both -y and -n supplied. Exiting.\n");
846  return AVERROR(EINVAL);
847  }
848 
849  if (!file_overwrite) {
850  if (proto_name && !strcmp(proto_name, "file") && avio_check(filename, 0) == 0) {
852  fprintf(stderr,"File '%s' already exists. Overwrite? [y/N] ", filename);
853  fflush(stderr);
854  term_exit();
855  signal(SIGINT, SIG_DFL);
856  if (!read_yesno()) {
857  av_log(NULL, AV_LOG_FATAL, "Not overwriting - exiting\n");
858  return AVERROR_EXIT;
859  }
860  term_init();
861  }
862  else {
863  av_log(NULL, AV_LOG_FATAL, "File '%s' already exists. Exiting.\n", filename);
864  return AVERROR_EXIT;
865  }
866  }
867  }
868 
869  if (proto_name && !strcmp(proto_name, "file")) {
870  for (int i = 0; i < nb_input_files; i++) {
871  InputFile *file = input_files[i];
872  if (file->ctx->iformat->flags & AVFMT_NOFILE)
873  continue;
874  if (!strcmp(filename, file->ctx->url)) {
875  av_log(NULL, AV_LOG_FATAL, "Output %s same as Input #%d - exiting\n", filename, i);
876  av_log(NULL, AV_LOG_WARNING, "FFmpeg cannot edit existing files in-place.\n");
877  return AVERROR(EINVAL);
878  }
879  }
880  }
881 
882  return 0;
883 }
884 
885 /* arg format is "output-stream-index:streamid-value". */
886 static int opt_streamid(void *optctx, const char *opt, const char *arg)
887 {
888  OptionsContext *o = optctx;
889  char *p;
890  char idx_str[16];
891 
892  av_strlcpy(idx_str, arg, sizeof(idx_str));
893  p = strchr(idx_str, ':');
894  if (!p) {
896  "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
897  arg, opt);
898  return AVERROR(EINVAL);
899  }
900  *p++ = '\0';
901 
902  return av_dict_set(&o->streamid, idx_str, p, 0);
903 }
904 
905 static int opt_target(void *optctx, const char *opt, const char *arg)
906 {
907  OptionsContext *o = optctx;
908  enum { PAL, NTSC, FILM, UNKNOWN } norm = UNKNOWN;
909  static const char *const frame_rates[] = { "25", "30000/1001", "24000/1001" };
910 
911  if (!strncmp(arg, "pal-", 4)) {
912  norm = PAL;
913  arg += 4;
914  } else if (!strncmp(arg, "ntsc-", 5)) {
915  norm = NTSC;
916  arg += 5;
917  } else if (!strncmp(arg, "film-", 5)) {
918  norm = FILM;
919  arg += 5;
920  } else {
921  /* Try to determine PAL/NTSC by peeking in the input files */
922  if (nb_input_files) {
923  int i, j;
924  for (j = 0; j < nb_input_files; j++) {
925  for (i = 0; i < input_files[j]->nb_streams; i++) {
926  AVStream *st = input_files[j]->ctx->streams[i];
927  int64_t fr;
929  continue;
930  fr = st->time_base.den * 1000LL / st->time_base.num;
931  if (fr == 25000) {
932  norm = PAL;
933  break;
934  } else if ((fr == 29970) || (fr == 23976)) {
935  norm = NTSC;
936  break;
937  }
938  }
939  if (norm != UNKNOWN)
940  break;
941  }
942  }
943  if (norm != UNKNOWN)
944  av_log(NULL, AV_LOG_INFO, "Assuming %s for target.\n", norm == PAL ? "PAL" : "NTSC");
945  }
946 
947  if (norm == UNKNOWN) {
948  av_log(NULL, AV_LOG_FATAL, "Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
949  av_log(NULL, AV_LOG_FATAL, "Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
950  av_log(NULL, AV_LOG_FATAL, "or set a framerate with \"-r xxx\".\n");
951  return AVERROR(EINVAL);
952  }
953 
954  if (!strcmp(arg, "vcd")) {
955  opt_video_codec(o, "c:v", "mpeg1video");
956  opt_audio_codec(o, "c:a", "mp2");
957  parse_option(o, "f", "vcd", options);
958 
959  parse_option(o, "s", norm == PAL ? "352x288" : "352x240", options);
960  parse_option(o, "r", frame_rates[norm], options);
961  opt_default(NULL, "g", norm == PAL ? "15" : "18");
962 
963  opt_default(NULL, "b:v", "1150000");
964  opt_default(NULL, "maxrate:v", "1150000");
965  opt_default(NULL, "minrate:v", "1150000");
966  opt_default(NULL, "bufsize:v", "327680"); // 40*1024*8;
967 
968  opt_default(NULL, "b:a", "224000");
969  parse_option(o, "ar", "44100", options);
970  parse_option(o, "ac", "2", options);
971 
972  opt_default(NULL, "packetsize", "2324");
973  opt_default(NULL, "muxrate", "1411200"); // 2352 * 75 * 8;
974 
975  /* We have to offset the PTS, so that it is consistent with the SCR.
976  SCR starts at 36000, but the first two packs contain only padding
977  and the first pack from the other stream, respectively, may also have
978  been written before.
979  So the real data starts at SCR 36000+3*1200. */
980  o->mux_preload = (36000 + 3 * 1200) / 90000.0; // 0.44
981  } else if (!strcmp(arg, "svcd")) {
982 
983  opt_video_codec(o, "c:v", "mpeg2video");
984  opt_audio_codec(o, "c:a", "mp2");
985  parse_option(o, "f", "svcd", options);
986 
987  parse_option(o, "s", norm == PAL ? "480x576" : "480x480", options);
988  parse_option(o, "r", frame_rates[norm], options);
989  parse_option(o, "pix_fmt", "yuv420p", options);
990  opt_default(NULL, "g", norm == PAL ? "15" : "18");
991 
992  opt_default(NULL, "b:v", "2040000");
993  opt_default(NULL, "maxrate:v", "2516000");
994  opt_default(NULL, "minrate:v", "0"); // 1145000;
995  opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;
996  opt_default(NULL, "scan_offset", "1");
997 
998  opt_default(NULL, "b:a", "224000");
999  parse_option(o, "ar", "44100", options);
1000 
1001  opt_default(NULL, "packetsize", "2324");
1002 
1003  } else if (!strcmp(arg, "dvd")) {
1004 
1005  opt_video_codec(o, "c:v", "mpeg2video");
1006  opt_audio_codec(o, "c:a", "ac3");
1007  parse_option(o, "f", "dvd", options);
1008 
1009  parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
1010  parse_option(o, "r", frame_rates[norm], options);
1011  parse_option(o, "pix_fmt", "yuv420p", options);
1012  opt_default(NULL, "g", norm == PAL ? "15" : "18");
1013 
1014  opt_default(NULL, "b:v", "6000000");
1015  opt_default(NULL, "maxrate:v", "9000000");
1016  opt_default(NULL, "minrate:v", "0"); // 1500000;
1017  opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;
1018 
1019  opt_default(NULL, "packetsize", "2048"); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
1020  opt_default(NULL, "muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8
1021 
1022  opt_default(NULL, "b:a", "448000");
1023  parse_option(o, "ar", "48000", options);
1024 
1025  } else if (!strncmp(arg, "dv", 2)) {
1026 
1027  parse_option(o, "f", "dv", options);
1028 
1029  parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
1030  parse_option(o, "pix_fmt", !strncmp(arg, "dv50", 4) ? "yuv422p" :
1031  norm == PAL ? "yuv420p" : "yuv411p", options);
1032  parse_option(o, "r", frame_rates[norm], options);
1033 
1034  parse_option(o, "ar", "48000", options);
1035  parse_option(o, "ac", "2", options);
1036 
1037  } else {
1038  av_log(NULL, AV_LOG_ERROR, "Unknown target: %s\n", arg);
1039  return AVERROR(EINVAL);
1040  }
1041 
1044 
1045  return 0;
1046 }
1047 
1048 static int opt_vstats_file(void *optctx, const char *opt, const char *arg)
1049 {
1052  return 0;
1053 }
1054 
1055 static int opt_vstats(void *optctx, const char *opt, const char *arg)
1056 {
1057  char filename[40];
1058  time_t today2 = time(NULL);
1059  struct tm *today = localtime(&today2);
1060 
1061  if (!today) { // maybe tomorrow
1062  av_log(NULL, AV_LOG_FATAL, "Unable to get current time: %s\n", strerror(errno));
1063  return AVERROR(errno);
1064  }
1065 
1066  snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
1067  today->tm_sec);
1068  return opt_vstats_file(NULL, opt, filename);
1069 }
1070 
1071 static int opt_video_frames(void *optctx, const char *opt, const char *arg)
1072 {
1073  OptionsContext *o = optctx;
1074  return parse_option(o, "frames:v", arg, options);
1075 }
1076 
1077 static int opt_audio_frames(void *optctx, const char *opt, const char *arg)
1078 {
1079  OptionsContext *o = optctx;
1080  return parse_option(o, "frames:a", arg, options);
1081 }
1082 
1083 static int opt_data_frames(void *optctx, const char *opt, const char *arg)
1084 {
1085  OptionsContext *o = optctx;
1086  return parse_option(o, "frames:d", arg, options);
1087 }
1088 
1089 static int opt_default_new(OptionsContext *o, const char *opt, const char *arg)
1090 {
1091  int ret;
1092  AVDictionary *cbak = codec_opts;
1093  AVDictionary *fbak = format_opts;
1094  codec_opts = NULL;
1095  format_opts = NULL;
1096 
1097  ret = opt_default(NULL, opt, arg);
1098 
1099  av_dict_copy(&o->g->codec_opts , codec_opts, 0);
1103  codec_opts = cbak;
1104  format_opts = fbak;
1105 
1106  return ret;
1107 }
1108 
1109 static int opt_preset(void *optctx, const char *opt, const char *arg)
1110 {
1111  OptionsContext *o = optctx;
1112  FILE *f=NULL;
1113  char filename[1000], line[1000], tmp_line[1000];
1114  const char *codec_name = NULL;
1115  int ret = 0;
1116  int depth = o->depth;
1117 
1118  if (depth > 2) {
1119  av_log(NULL, AV_LOG_ERROR, "too deep recursion\n");
1120  return AVERROR(EINVAL);
1121  }
1122 
1123  codec_name = opt_match_per_type_str(&o->codec_names, *opt);
1124 
1125  if (!(f = get_preset_file(filename, sizeof(filename), arg, *opt == 'f', codec_name))) {
1126  if(!strncmp(arg, "libx264-lossless", strlen("libx264-lossless"))){
1127  av_log(NULL, AV_LOG_FATAL, "Please use -preset <speed> -qp 0\n");
1128  }else
1129  av_log(NULL, AV_LOG_FATAL, "File for preset '%s' not found\n", arg);
1130  return AVERROR(ENOENT);
1131  }
1132 
1133  o->depth ++;
1134  while (fgets(line, sizeof(line), f)) {
1135  char *key = tmp_line, *value, *endptr;
1136 
1137  if (strcspn(line, "#\n\r") == 0)
1138  continue;
1139  av_strlcpy(tmp_line, line, sizeof(tmp_line));
1140  if (!av_strtok(key, "=", &value) ||
1141  !av_strtok(value, "\r\n", &endptr)) {
1142  av_log(NULL, AV_LOG_FATAL, "%s: Invalid syntax: '%s'\n", filename, line);
1143  ret = AVERROR(EINVAL);
1144  goto fail;
1145  }
1146  av_log(NULL, AV_LOG_DEBUG, "ffpreset[%s]: set '%s' = '%s'\n", filename, key, value);
1147 
1148  if (!strcmp(key, "acodec")) opt_audio_codec (o, key, value);
1149  else if (!strcmp(key, "vcodec")) opt_video_codec (o, key, value);
1150  else if (!strcmp(key, "scodec")) opt_subtitle_codec(o, key, value);
1151  else if (!strcmp(key, "dcodec")) opt_data_codec (o, key, value);
1152  else if ((parse_option(o, key, value, options) < 0) &&
1153  (opt_default_new(o, key, value) < 0)) {
1154  av_log(NULL, AV_LOG_FATAL, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n",
1155  filename, line, key, value);
1156  ret = AVERROR(EINVAL);
1157  goto fail;
1158  }
1159  }
1160 
1161 fail:
1162  o->depth = depth;
1163  fclose(f);
1164 
1165  return ret;
1166 }
1167 
1168 static int opt_old2new(void *optctx, const char *opt, const char *arg)
1169 {
1170  OptionsContext *o = optctx;
1171  int ret;
1172  char *s = av_asprintf("%s:%c", opt + 1, *opt);
1173  if (!s)
1174  return AVERROR(ENOMEM);
1175  ret = parse_option(o, s, arg, options);
1176  av_free(s);
1177  return ret;
1178 }
1179 
1180 static int opt_bitrate(void *optctx, const char *opt, const char *arg)
1181 {
1182  OptionsContext *o = optctx;
1183 
1184  if(!strcmp(opt, "ab")){
1185  av_dict_set(&o->g->codec_opts, "b:a", arg, 0);
1186  return 0;
1187  } else if(!strcmp(opt, "b")){
1188  av_log(NULL, AV_LOG_WARNING, "Please use -b:a or -b:v, -b is ambiguous\n");
1189  av_dict_set(&o->g->codec_opts, "b:v", arg, 0);
1190  return 0;
1191  }
1192  av_dict_set(&o->g->codec_opts, opt, arg, 0);
1193  return 0;
1194 }
1195 
1196 static int opt_qscale(void *optctx, const char *opt, const char *arg)
1197 {
1198  OptionsContext *o = optctx;
1199  char *s;
1200  int ret;
1201  if(!strcmp(opt, "qscale")){
1202  av_log(NULL, AV_LOG_WARNING, "Please use -q:a or -q:v, -qscale is ambiguous\n");
1203  return parse_option(o, "q:v", arg, options);
1204  }
1205  s = av_asprintf("q%s", opt + 6);
1206  if (!s)
1207  return AVERROR(ENOMEM);
1208  ret = parse_option(o, s, arg, options);
1209  av_free(s);
1210  return ret;
1211 }
1212 
1213 static int opt_profile(void *optctx, const char *opt, const char *arg)
1214 {
1215  OptionsContext *o = optctx;
1216  if(!strcmp(opt, "profile")){
1217  av_log(NULL, AV_LOG_WARNING, "Please use -profile:a or -profile:v, -profile is ambiguous\n");
1218  av_dict_set(&o->g->codec_opts, "profile:v", arg, 0);
1219  return 0;
1220  }
1221  av_dict_set(&o->g->codec_opts, opt, arg, 0);
1222  return 0;
1223 }
1224 
1225 static int opt_video_filters(void *optctx, const char *opt, const char *arg)
1226 {
1227  OptionsContext *o = optctx;
1228  return parse_option(o, "filter:v", arg, options);
1229 }
1230 
1231 static int opt_audio_filters(void *optctx, const char *opt, const char *arg)
1232 {
1233  OptionsContext *o = optctx;
1234  return parse_option(o, "filter:a", arg, options);
1235 }
1236 
1237 #if FFMPEG_OPT_VSYNC
1238 static int opt_vsync(void *optctx, const char *opt, const char *arg)
1239 {
1240  av_log(NULL, AV_LOG_WARNING, "-vsync is deprecated. Use -fps_mode\n");
1241  return parse_and_set_vsync(arg, &video_sync_method, -1, -1, 1);
1242 }
1243 #endif
1244 
1245 static int opt_timecode(void *optctx, const char *opt, const char *arg)
1246 {
1247  OptionsContext *o = optctx;
1248  int ret;
1249  char *tcr = av_asprintf("timecode=%s", arg);
1250  if (!tcr)
1251  return AVERROR(ENOMEM);
1252  ret = parse_option(o, "metadata:g", tcr, options);
1253  if (ret >= 0)
1254  ret = av_dict_set(&o->g->codec_opts, "gop_timecode", arg, 0);
1255  av_free(tcr);
1256  return ret;
1257 }
1258 
1259 static int opt_audio_qscale(void *optctx, const char *opt, const char *arg)
1260 {
1261  OptionsContext *o = optctx;
1262  return parse_option(o, "q:a", arg, options);
1263 }
1264 
1265 static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
1266 {
1267  GlobalOptionsContext *go = optctx;
1268  char *graph_desc;
1269  int ret;
1270 
1271  graph_desc = av_strdup(arg);
1272  if (!graph_desc)
1273  return AVERROR(ENOMEM);
1274 
1276  if (ret < 0) {
1277  av_freep(&graph_desc);
1278  return ret;
1279  }
1280  go->filtergraphs[go->nb_filtergraphs - 1] = graph_desc;
1281 
1282  return 0;
1283 }
1284 
1285 #if FFMPEG_OPT_FILTER_SCRIPT
1286 static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
1287 {
1288  GlobalOptionsContext *go = optctx;
1289  char *graph_desc;
1290  int ret;
1291 
1292  graph_desc = read_file_to_string(arg);
1293  if (!graph_desc)
1294  return AVERROR(EINVAL);
1295 
1296  av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -/filter_complex %s instead\n",
1297  opt, arg);
1298 
1300  if (ret < 0) {
1301  av_freep(&graph_desc);
1302  return ret;
1303  }
1304  go->filtergraphs[go->nb_filtergraphs - 1] = graph_desc;
1305 
1306  return 0;
1307 }
1308 #endif
1309 
1310 void show_help_default(const char *opt, const char *arg)
1311 {
1312  int show_advanced = 0, show_avoptions = 0;
1313 
1314  if (opt && *opt) {
1315  if (!strcmp(opt, "long"))
1316  show_advanced = 1;
1317  else if (!strcmp(opt, "full"))
1318  show_advanced = show_avoptions = 1;
1319  else
1320  av_log(NULL, AV_LOG_ERROR, "Unknown help option '%s'.\n", opt);
1321  }
1322 
1323  show_usage();
1324 
1325  printf("Getting help:\n"
1326  " -h -- print basic options\n"
1327  " -h long -- print more options\n"
1328  " -h full -- print all options (including all format and codec specific options, very long)\n"
1329  " -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf/protocol\n"
1330  " See man %s for detailed description of the options.\n"
1331  "\n"
1332  "Per-stream options can be followed by :<stream_spec> to apply that option to specific streams only. "
1333  "<stream_spec> can be a stream index, or v/a/s for video/audio/subtitle (see manual for full syntax).\n"
1334  "\n", program_name);
1335 
1336  show_help_options(options, "Print help / information / capabilities:",
1337  OPT_EXIT, OPT_EXPERT);
1338  if (show_advanced)
1339  show_help_options(options, "Advanced information / capabilities:",
1340  OPT_EXIT | OPT_EXPERT, 0);
1341 
1342  show_help_options(options, "Global options (affect whole program "
1343  "instead of just one file):",
1345  if (show_advanced)
1346  show_help_options(options, "Advanced global options:", OPT_EXPERT,
1347  OPT_PERFILE | OPT_EXIT);
1348 
1349  show_help_options(options, "Per-file options (input and output):",
1353  if (show_advanced)
1354  show_help_options(options, "Advanced per-file options (input and output):",
1358 
1359  show_help_options(options, "Per-file options (input-only):",
1363  if (show_advanced)
1364  show_help_options(options, "Advanced per-file options (input-only):",
1368 
1369  show_help_options(options, "Per-file options (output-only):",
1373  if (show_advanced)
1374  show_help_options(options, "Advanced per-file options (output-only):",
1378 
1379  show_help_options(options, "Per-stream options:",
1381  OPT_EXIT | OPT_EXPERT |
1383  if (show_advanced)
1384  show_help_options(options, "Advanced per-stream options:",
1386  OPT_EXIT |
1388 
1389  show_help_options(options, "Video options:",
1391  if (show_advanced)
1392  show_help_options(options, "Advanced Video options:",
1394 
1395  show_help_options(options, "Audio options:",
1397  if (show_advanced)
1398  show_help_options(options, "Advanced Audio options:",
1400 
1401  show_help_options(options, "Subtitle options:",
1403  if (show_advanced)
1404  show_help_options(options, "Advanced Subtitle options:",
1406 
1407  if (show_advanced)
1408  show_help_options(options, "Data stream options:",
1410  printf("\n");
1411 
1412  if (show_avoptions) {
1416 #if CONFIG_SWSCALE
1418 #endif
1419 #if CONFIG_SWRESAMPLE
1421 #endif
1424  }
1425 }
1426 
1427 void show_usage(void)
1428 {
1429  av_log(NULL, AV_LOG_INFO, "Universal media converter\n");
1430  av_log(NULL, AV_LOG_INFO, "usage: %s [options] [[infile options] -i infile]... {[outfile options] outfile}...\n", program_name);
1431  av_log(NULL, AV_LOG_INFO, "\n");
1432 }
1433 
1434 enum OptGroup {
1435  GROUP_OUTFILE,
1436  GROUP_INFILE,
1437  GROUP_DECODER,
1438 };
1439 
1440 static const OptionGroupDef groups[] = {
1441  [GROUP_OUTFILE] = { "output url", NULL, OPT_OUTPUT },
1442  [GROUP_INFILE] = { "input url", "i", OPT_INPUT },
1443  [GROUP_DECODER] = { "loopback decoder", "dec", OPT_DECODER },
1444 };
1445 
1446 static int open_files(OptionGroupList *l, const char *inout, Scheduler *sch,
1447  int (*open_file)(const OptionsContext*, const char*,
1448  Scheduler*))
1449 {
1450  int i, ret;
1451 
1452  for (i = 0; i < l->nb_groups; i++) {
1453  OptionGroup *g = &l->groups[i];
1454  OptionsContext o;
1455 
1456  init_options(&o);
1457  o.g = g;
1458 
1459  ret = parse_optgroup(&o, g, options);
1460  if (ret < 0) {
1461  av_log(NULL, AV_LOG_ERROR, "Error parsing options for %s file "
1462  "%s.\n", inout, g->arg);
1463  uninit_options(&o);
1464  return ret;
1465  }
1466 
1467  av_log(NULL, AV_LOG_DEBUG, "Opening an %s file: %s.\n", inout, g->arg);
1468  ret = open_file(&o, g->arg, sch);
1469  uninit_options(&o);
1470  if (ret < 0) {
1471  av_log(NULL, AV_LOG_ERROR, "Error opening %s file %s.\n",
1472  inout, g->arg);
1473  return ret;
1474  }
1475  av_log(NULL, AV_LOG_DEBUG, "Successfully opened the file.\n");
1476  }
1477 
1478  return 0;
1479 }
1480 
1481 int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
1482 {
1483  GlobalOptionsContext go = { .sch = sch };
1484  OptionParseContext octx;
1485  const char *errmsg = NULL;
1486  int ret;
1487 
1488  memset(&octx, 0, sizeof(octx));
1489 
1490  /* split the commandline into an internal representation */
1491  ret = split_commandline(&octx, argc, argv, options, groups,
1492  FF_ARRAY_ELEMS(groups));
1493  if (ret < 0) {
1494  errmsg = "splitting the argument list";
1495  goto fail;
1496  }
1497 
1498  /* apply global options */
1499  ret = parse_optgroup(&go, &octx.global_opts, options);
1500  if (ret < 0) {
1501  errmsg = "parsing global options";
1502  goto fail;
1503  }
1504 
1505  /* configure terminal and setup signal handlers */
1506  term_init();
1507 
1508  /* create complex filtergraphs */
1509  for (int i = 0; i < go.nb_filtergraphs; i++) {
1510  ret = fg_create(NULL, &go.filtergraphs[i], sch, NULL);
1511  go.filtergraphs[i] = NULL;
1512  if (ret < 0)
1513  goto fail;
1514  }
1515 
1516  /* open input files */
1517  ret = open_files(&octx.groups[GROUP_INFILE], "input", sch, ifile_open);
1518  if (ret < 0) {
1519  errmsg = "opening input files";
1520  goto fail;
1521  }
1522 
1523  /* open output files */
1524  ret = open_files(&octx.groups[GROUP_OUTFILE], "output", sch, of_open);
1525  if (ret < 0) {
1526  errmsg = "opening output files";
1527  goto fail;
1528  }
1529 
1530  /* create loopback decoders */
1531  ret = open_files(&octx.groups[GROUP_DECODER], "decoder", sch, dec_create);
1532  if (ret < 0) {
1533  errmsg = "creating loopback decoders";
1534  goto fail;
1535  }
1536 
1537  // bind unbound filtegraph inputs/outputs and check consistency
1539  if (ret < 0) {
1540  errmsg = "binding filtergraph inputs/outputs";
1541  goto fail;
1542  }
1543 
1545 
1546  ret = apply_sync_offsets();
1547  if (ret < 0)
1548  goto fail;
1549 
1550 fail:
1551  for (int i = 0; i < go.nb_filtergraphs; i++)
1552  av_freep(&go.filtergraphs[i]);
1553  av_freep(&go.filtergraphs);
1554 
1555  uninit_parse_context(&octx);
1556  if (ret < 0 && ret != AVERROR_EXIT) {
1557  av_log(NULL, AV_LOG_FATAL, "Error %s: %s\n",
1558  errmsg ? errmsg : "", av_err2str(ret));
1559  }
1560  return ret;
1561 }
1562 
1563 static int opt_progress(void *optctx, const char *opt, const char *arg)
1564 {
1565  AVIOContext *avio = NULL;
1566  int ret;
1567 
1568  if (!strcmp(arg, "-"))
1569  arg = "pipe:";
1570  ret = avio_open2(&avio, arg, AVIO_FLAG_WRITE, &int_cb, NULL);
1571  if (ret < 0) {
1572  av_log(NULL, AV_LOG_ERROR, "Failed to open progress URL \"%s\": %s\n",
1573  arg, av_err2str(ret));
1574  return ret;
1575  }
1576  progress_avio = avio;
1577  return 0;
1578 }
1579 
1580 int opt_timelimit(void *optctx, const char *opt, const char *arg)
1581 {
1582 #if HAVE_SETRLIMIT
1583  int ret;
1584  double lim;
1585  struct rlimit rl;
1586 
1587  ret = parse_number(opt, arg, OPT_TYPE_INT64, 0, INT_MAX, &lim);
1588  if (ret < 0)
1589  return ret;
1590 
1591  rl = (struct rlimit){ lim, lim + 1 };
1592  if (setrlimit(RLIMIT_CPU, &rl))
1593  perror("setrlimit");
1594 #else
1595  av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
1596 #endif
1597  return 0;
1598 }
1599 
1600 #if FFMPEG_OPT_QPHIST
1601 static int opt_qphist(void *optctx, const char *opt, const char *arg)
1602 {
1603  av_log(NULL, AV_LOG_WARNING, "Option -%s is deprecated and has no effect\n", opt);
1604  return 0;
1605 }
1606 #endif
1607 
1608 #if FFMPEG_OPT_ADRIFT_THRESHOLD
1609 static int opt_adrift_threshold(void *optctx, const char *opt, const char *arg)
1610 {
1611  av_log(NULL, AV_LOG_WARNING, "Option -%s is deprecated and has no effect\n", opt);
1612  return 0;
1613 }
1614 #endif
1615 
1616 static const char *const alt_channel_layout[] = { "ch_layout", NULL};
1617 static const char *const alt_codec[] = { "c", "acodec", "vcodec", "scodec", "dcodec", NULL };
1618 static const char *const alt_filter[] = { "af", "vf", NULL };
1619 static const char *const alt_frames[] = { "aframes", "vframes", "dframes", NULL };
1620 static const char *const alt_pre[] = { "apre", "vpre", "spre", NULL};
1621 static const char *const alt_qscale[] = { "q", NULL};
1622 static const char *const alt_tag[] = { "atag", "vtag", "stag", NULL };
1623 
1624 #define OFFSET(x) offsetof(OptionsContext, x)
1625 const OptionDef options[] = {
1626  /* main options */
1629  { .off = OFFSET(format) },
1630  "force container format (auto-detected otherwise)", "fmt" },
1631  { "y", OPT_TYPE_BOOL, 0,
1632  { &file_overwrite },
1633  "overwrite output files" },
1634  { "n", OPT_TYPE_BOOL, 0,
1635  { &no_file_overwrite },
1636  "never overwrite output files" },
1637  { "ignore_unknown", OPT_TYPE_BOOL, OPT_EXPERT,
1639  "Ignore unknown stream types" },
1640  { "copy_unknown", OPT_TYPE_BOOL, OPT_EXPERT,
1641  { &copy_unknown_streams },
1642  "Copy unknown stream types" },
1643  { "recast_media", OPT_TYPE_BOOL, OPT_EXPERT,
1644  { &recast_media },
1645  "allow recasting stream type in order to force a decoder of different media type" },
1647  { .off = OFFSET(codec_names) },
1648  "select encoder/decoder ('copy' to copy stream without reencoding)", "codec",
1649  .u1.name_canon = "codec", },
1651  { .off = OFFSET(codec_names) },
1652  "alias for -c (select encoder/decoder)", "codec",
1653  .u1.names_alt = alt_codec, },
1655  { .off = OFFSET(presets) },
1656  "preset name", "preset",
1657  .u1.names_alt = alt_pre, },
1659  { .func_arg = opt_map },
1660  "set input stream mapping",
1661  "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
1662  { "map_metadata", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | OPT_EXPERT,
1663  { .off = OFFSET(metadata_map) },
1664  "set metadata information of outfile from infile",
1665  "outfile[,metadata]:infile[,metadata]" },
1666  { "map_chapters", OPT_TYPE_INT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
1667  { .off = OFFSET(chapters_input_file) },
1668  "set chapters mapping", "input_file_index" },
1670  { .off = OFFSET(recording_time) },
1671  "stop transcoding after specified duration",
1672  "duration" },
1674  { .off = OFFSET(stop_time) },
1675  "stop transcoding after specified time is reached",
1676  "time_stop" },
1678  { .off = OFFSET(limit_filesize) },
1679  "set the limit file size in bytes", "limit_size" },
1681  { .off = OFFSET(start_time) },
1682  "start transcoding at specified time", "time_off" },
1683  { "sseof", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_EXPERT,
1684  { .off = OFFSET(start_time_eof) },
1685  "set the start time offset relative to EOF", "time_off" },
1686  { "seek_timestamp", OPT_TYPE_INT, OPT_OFFSET | OPT_INPUT | OPT_EXPERT,
1687  { .off = OFFSET(seek_timestamp) },
1688  "enable/disable seeking by timestamp with -ss" },
1689  { "accurate_seek", OPT_TYPE_BOOL, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1690  { .off = OFFSET(accurate_seek) },
1691  "enable/disable accurate seeking with -ss" },
1692  { "isync", OPT_TYPE_INT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1693  { .off = OFFSET(input_sync_ref) },
1694  "Indicate the input index for sync reference", "sync ref" },
1695  { "itsoffset", OPT_TYPE_TIME, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1696  { .off = OFFSET(input_ts_offset) },
1697  "set the input ts offset", "time_off" },
1699  { .off = OFFSET(ts_scale) },
1700  "set the input ts scale", "scale" },
1702  { .func_arg = opt_recording_timestamp },
1703  "set the recording timestamp ('now' to set the current time)", "time" },
1704  { "metadata", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
1705  { .off = OFFSET(metadata) },
1706  "add metadata", "key=value" },
1707  { "program", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
1708  { .off = OFFSET(program) },
1709  "add program with specified streams", "title=string:st=number..." },
1710  { "stream_group", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | OPT_EXPERT,
1711  { .off = OFFSET(stream_groups) },
1712  "add stream group with specified streams and group type-specific arguments", "id=number:st=number..." },
1714  { .func_arg = opt_data_frames },
1715  "set the number of data frames to output", "number",
1716  .u1.name_canon = "frames" },
1717  { "benchmark", OPT_TYPE_BOOL, OPT_EXPERT,
1718  { &do_benchmark },
1719  "add timings for benchmarking" },
1720  { "benchmark_all", OPT_TYPE_BOOL, OPT_EXPERT,
1721  { &do_benchmark_all },
1722  "add timings for each task" },
1723  { "progress", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1724  { .func_arg = opt_progress },
1725  "write program-readable progress information", "url" },
1726  { "stdin", OPT_TYPE_BOOL, OPT_EXPERT,
1727  { &stdin_interaction },
1728  "enable or disable interaction on standard input" },
1729  { "timelimit", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1730  { .func_arg = opt_timelimit },
1731  "set max runtime in seconds in CPU user time", "limit" },
1732  { "dump", OPT_TYPE_BOOL, OPT_EXPERT,
1733  { &do_pkt_dump },
1734  "dump each input packet" },
1735  { "hex", OPT_TYPE_BOOL, OPT_EXPERT,
1736  { &do_hex_dump },
1737  "when dumping packets, also dump the payload" },
1739  { .off = OFFSET(rate_emu) },
1740  "read input at native frame rate; equivalent to -readrate 1", "" },
1741  { "readrate", OPT_TYPE_FLOAT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1742  { .off = OFFSET(readrate) },
1743  "read input at specified rate", "speed" },
1744  { "readrate_initial_burst", OPT_TYPE_DOUBLE, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1745  { .off = OFFSET(readrate_initial_burst) },
1746  "The initial amount of input to burst read before imposing any readrate", "seconds" },
1747  { "readrate_catchup", OPT_TYPE_FLOAT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1748  { .off = OFFSET(readrate_catchup) },
1749  "Temporary readrate used to catch up if an input lags behind the specified readrate", "speed" },
1751  { .func_arg = opt_target },
1752  "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\" or \"dv50\" "
1753  "with optional prefixes \"pal-\", \"ntsc-\" or \"film-\")", "type" },
1754  { "frame_drop_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
1755  { &frame_drop_threshold },
1756  "frame drop threshold", "" },
1757  { "copyts", OPT_TYPE_BOOL, OPT_EXPERT,
1758  { &copy_ts },
1759  "copy timestamps" },
1760  { "start_at_zero", OPT_TYPE_BOOL, OPT_EXPERT,
1761  { &start_at_zero },
1762  "shift input timestamps to start at 0 when using copyts" },
1763  { "copytb", OPT_TYPE_INT, OPT_EXPERT,
1764  { &copy_tb },
1765  "copy input stream time base when stream copying", "mode" },
1766  { "shortest", OPT_TYPE_BOOL, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
1767  { .off = OFFSET(shortest) },
1768  "finish encoding within shortest input" },
1769  { "shortest_buf_duration", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
1770  { .off = OFFSET(shortest_buf_duration) },
1771  "maximum buffering duration (in seconds) for the -shortest option" },
1773  { .off = OFFSET(bitexact) },
1774  "bitexact mode" },
1775  { "dts_delta_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
1776  { &dts_delta_threshold },
1777  "timestamp discontinuity delta threshold", "threshold" },
1778  { "dts_error_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
1779  { &dts_error_threshold },
1780  "timestamp error delta threshold", "threshold" },
1781  { "xerror", OPT_TYPE_BOOL, OPT_EXPERT,
1782  { &exit_on_error },
1783  "exit on error", "error" },
1784  { "abort_on", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1785  { .func_arg = opt_abort_on },
1786  "abort on the specified condition flags", "flags" },
1787  { "copyinkf", OPT_TYPE_BOOL, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1788  { .off = OFFSET(copy_initial_nonkeyframes) },
1789  "copy initial non-keyframes" },
1790  { "copypriorss", OPT_TYPE_INT, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1791  { .off = OFFSET(copy_prior_start) },
1792  "copy or discard frames before start time" },
1794  { .off = OFFSET(max_frames) },
1795  "set the number of frames to output", "number",
1796  .u1.names_alt = alt_frames, },
1798  { .off = OFFSET(codec_tags) },
1799  "force codec tag/fourcc", "fourcc/tag",
1800  .u1.names_alt = alt_tag, },
1802  { .off = OFFSET(qscale) },
1803  "use fixed quality scale (VBR)", "q",
1804  .u1.name_canon = "qscale", },
1806  { .func_arg = opt_qscale },
1807  "use fixed quality scale (VBR)", "q",
1808  .u1.names_alt = alt_qscale, },
1810  { .func_arg = opt_profile },
1811  "set profile", "profile" },
1813  { .off = OFFSET(filters) },
1814  "apply specified filters to audio/video", "filter_graph",
1815  .u1.names_alt = alt_filter, },
1816  { "filter_threads", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1817  { .func_arg = opt_filter_threads },
1818  "number of non-complex filter threads" },
1819  { "filter_buffered_frames", OPT_TYPE_INT, OPT_EXPERT,
1821  "maximum number of buffered frames in a filter graph" },
1822 #if FFMPEG_OPT_FILTER_SCRIPT
1823  { "filter_script", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1824  { .off = OFFSET(filter_scripts) },
1825  "deprecated, use -/filter", "filename" },
1826 #endif
1827  { "reinit_filter", OPT_TYPE_INT, OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1828  { .off = OFFSET(reinit_filters) },
1829  "reinit filtergraph on input parameter changes", "" },
1830  { "drop_changed", OPT_TYPE_INT, OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1831  { .off = OFFSET(drop_changed) },
1832  "drop frame instead of reiniting filtergraph on input parameter changes", "" },
1833  { "filter_complex", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1834  { .func_arg = opt_filter_complex },
1835  "create a complex filtergraph", "graph_description" },
1836  { "filter_complex_threads", OPT_TYPE_INT, OPT_EXPERT,
1838  "number of threads for -filter_complex" },
1839  { "lavfi", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1840  { .func_arg = opt_filter_complex },
1841  "create a complex filtergraph", "graph_description" },
1842 #if FFMPEG_OPT_FILTER_SCRIPT
1843  { "filter_complex_script", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1844  { .func_arg = opt_filter_complex_script },
1845  "deprecated, use -/filter_complex instead", "filename" },
1846 #endif
1847  { "print_graphs", OPT_TYPE_BOOL, 0,
1848  { &print_graphs },
1849  "print execution graph data to stderr" },
1850  { "print_graphs_file", OPT_TYPE_STRING, 0,
1851  { &print_graphs_file },
1852  "write execution graph data to the specified file", "filename" },
1853  { "print_graphs_format", OPT_TYPE_STRING, 0,
1854  { &print_graphs_format },
1855  "set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml, mermaid, mermaidhtml)", "format" },
1856  { "auto_conversion_filters", OPT_TYPE_BOOL, OPT_EXPERT,
1858  "enable automatic conversion filters globally" },
1859  { "stats", OPT_TYPE_BOOL, 0,
1860  { &print_stats },
1861  "print progress report during encoding", },
1862  { "stats_period", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1863  { .func_arg = opt_stats_period },
1864  "set the period at which ffmpeg updates stats and -progress output", "time" },
1866  { .func_arg = opt_attach },
1867  "add an attachment to the output file", "filename" },
1868  { "dump_attachment", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_INPUT,
1869  { .off = OFFSET(dump_attachment) },
1870  "extract an attachment into a file", "filename" },
1871  { "stream_loop", OPT_TYPE_INT, OPT_EXPERT | OPT_INPUT | OPT_OFFSET,
1872  { .off = OFFSET(loop) }, "set number of times input stream shall be looped", "loop count" },
1873  { "debug_ts", OPT_TYPE_BOOL, OPT_EXPERT,
1874  { &debug_ts },
1875  "print timestamp debugging info" },
1876  { "max_error_rate", OPT_TYPE_FLOAT, OPT_EXPERT,
1877  { &max_error_rate },
1878  "ratio of decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.", "maximum error rate" },
1880  { .off = OFFSET(discard) },
1881  "discard", "" },
1882  { "disposition", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_OUTPUT | OPT_EXPERT,
1883  { .off = OFFSET(disposition) },
1884  "disposition", "" },
1885  { "thread_queue_size", OPT_TYPE_INT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT,
1886  { .off = OFFSET(thread_queue_size) },
1887  "set the maximum number of queued packets from the demuxer" },
1888  { "find_stream_info", OPT_TYPE_BOOL, OPT_INPUT | OPT_EXPERT | OPT_OFFSET,
1889  { .off = OFFSET(find_stream_info) },
1890  "read and decode the streams to fill missing information with heuristics" },
1891  { "bits_per_raw_sample", OPT_TYPE_INT, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1892  { .off = OFFSET(bits_per_raw_sample) },
1893  "set the number of bits per raw sample", "number" },
1894 
1895  { "stats_enc_pre", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1896  { .off = OFFSET(enc_stats_pre) },
1897  "write encoding stats before encoding" },
1898  { "stats_enc_post", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1899  { .off = OFFSET(enc_stats_post) },
1900  "write encoding stats after encoding" },
1901  { "stats_mux_pre", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1902  { .off = OFFSET(mux_stats) },
1903  "write packets stats before muxing" },
1904  { "stats_enc_pre_fmt", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1905  { .off = OFFSET(enc_stats_pre_fmt) },
1906  "format of the stats written with -stats_enc_pre" },
1907  { "stats_enc_post_fmt", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1908  { .off = OFFSET(enc_stats_post_fmt) },
1909  "format of the stats written with -stats_enc_post" },
1910  { "stats_mux_pre_fmt", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1911  { .off = OFFSET(mux_stats_fmt) },
1912  "format of the stats written with -stats_mux_pre" },
1913 
1914  /* video options */
1916  { .func_arg = opt_video_frames },
1917  "set the number of video frames to output", "number",
1918  .u1.name_canon = "frames", },
1920  { .off = OFFSET(frame_rates) },
1921  "override input framerate/convert to given output framerate (Hz value, fraction or abbreviation)", "rate" },
1923  { .off = OFFSET(max_frame_rates) },
1924  "set max frame rate (Hz value, fraction or abbreviation)", "rate" },
1926  { .off = OFFSET(frame_sizes) },
1927  "set frame size (WxH or abbreviation)", "size" },
1929  { .off = OFFSET(frame_aspect_ratios) },
1930  "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
1932  { .off = OFFSET(frame_pix_fmts) },
1933  "set pixel format", "format" },
1934  { "display_rotation", OPT_TYPE_DOUBLE, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1935  { .off = OFFSET(display_rotations) },
1936  "set pure counter-clockwise rotation in degrees for stream(s)",
1937  "angle" },
1938  { "display_hflip", OPT_TYPE_BOOL, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1939  { .off = OFFSET(display_hflips) },
1940  "set display horizontal flip for stream(s) "
1941  "(overrides any display rotation if it is not set)"},
1942  { "display_vflip", OPT_TYPE_BOOL, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1943  { .off = OFFSET(display_vflips) },
1944  "set display vertical flip for stream(s) "
1945  "(overrides any display rotation if it is not set)"},
1946  { "mastering_display", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1947  { .off = OFFSET(mastering_displays) },
1948  "set SMPTE2084 mastering display color volume info" },
1949  { "content_light", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1950  { .off = OFFSET(content_lights) },
1951  "set SMPTE2084 Max CLL and Max FALL values" },
1953  { .off = OFFSET(video_disable) },
1954  "disable video" },
1956  { .off = OFFSET(rc_overrides) },
1957  "rate control override for specific intervals", "override" },
1959  { .func_arg = opt_video_codec },
1960  "alias for -c:v (select encoder/decoder for video streams)", "codec",
1961  .u1.name_canon = "codec", },
1963  { .func_arg = opt_timecode },
1964  "set initial TimeCode value.", "hh:mm:ss[:;.]ff" },
1966  { .off = OFFSET(pass) },
1967  "select the pass number (1 to 3)", "n" },
1969  { .off = OFFSET(passlogfiles) },
1970  "select two pass log file name prefix", "prefix" },
1971  { "vstats", OPT_TYPE_FUNC, OPT_VIDEO | OPT_EXPERT,
1972  { .func_arg = opt_vstats },
1973  "dump video coding statistics to file" },
1974  { "vstats_file", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT,
1975  { .func_arg = opt_vstats_file },
1976  "dump video coding statistics to file", "file" },
1977  { "vstats_version", OPT_TYPE_INT, OPT_VIDEO | OPT_EXPERT,
1978  { &vstats_version },
1979  "Version of the vstats format to use."},
1981  { .func_arg = opt_video_filters },
1982  "alias for -filter:v (apply filters to video streams)", "filter_graph",
1983  .u1.name_canon = "filter", },
1984  { "intra_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1985  { .off = OFFSET(intra_matrices) },
1986  "specify intra matrix coeffs", "matrix" },
1987  { "inter_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1988  { .off = OFFSET(inter_matrices) },
1989  "specify inter matrix coeffs", "matrix" },
1990  { "chroma_intra_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1991  { .off = OFFSET(chroma_intra_matrices) },
1992  "specify intra matrix coeffs", "matrix" },
1994  { .func_arg = opt_old2new },
1995  "force video tag/fourcc", "fourcc/tag",
1996  .u1.name_canon = "tag", },
1998  { .off = OFFSET(fps_mode) },
1999  "set framerate mode for matching video streams; overrides vsync" },
2001  { .off = OFFSET(force_fps) },
2002  "force the selected framerate, disable the best supported framerate selection" },
2004  { .func_arg = opt_streamid },
2005  "set the value of an outfile streamid", "streamIndex:value" },
2006  { "force_key_frames", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
2007  { .off = OFFSET(forced_key_frames) },
2008  "force key frames at specified timestamps", "timestamps" },
2010  { .func_arg = opt_bitrate },
2011  "video bitrate (please use -b:v)", "bitrate" },
2013  { .off = OFFSET(hwaccels) },
2014  "use HW accelerated decoding", "hwaccel name" },
2015  { "hwaccel_device", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT,
2016  { .off = OFFSET(hwaccel_devices) },
2017  "select a device for HW acceleration", "devicename" },
2018  { "hwaccel_output_format", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT,
2019  { .off = OFFSET(hwaccel_output_formats) },
2020  "select output format used with HW accelerated decoding", "format" },
2021  { "hwaccels", OPT_TYPE_FUNC, OPT_EXIT | OPT_EXPERT,
2022  { .func_arg = show_hwaccels },
2023  "show available HW acceleration methods" },
2024  { "autorotate", OPT_TYPE_BOOL, OPT_VIDEO | OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
2025  { .off = OFFSET(autorotate) },
2026  "automatically insert correct rotate filters" },
2028  { .off = OFFSET(autoscale) },
2029  "automatically insert a scale filter at the end of the filter graph" },
2030  { "apply_cropping", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
2031  { .off = OFFSET(apply_cropping) },
2032  "select the cropping to apply" },
2033  { "fix_sub_duration_heartbeat", OPT_TYPE_BOOL, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
2034  { .off = OFFSET(fix_sub_duration_heartbeat) },
2035  "set this video output stream to be a heartbeat stream for "
2036  "fix_sub_duration, according to which subtitles should be split at "
2037  "random access points" },
2038 
2039  /* audio options */
2041  { .func_arg = opt_audio_frames },
2042  "set the number of audio frames to output", "number",
2043  .u1.name_canon = "frames", },
2045  { .func_arg = opt_audio_qscale },
2046  "set audio quality (codec-specific)", "quality", },
2048  { .off = OFFSET(audio_sample_rate) },
2049  "set audio sampling rate (in Hz)", "rate" },
2051  { .off = OFFSET(audio_channels) },
2052  "set number of audio channels", "channels" },
2054  { .off = OFFSET(audio_disable) },
2055  "disable audio" },
2057  { .func_arg = opt_audio_codec },
2058  "alias for -c:a (select encoder/decoder for audio streams)", "codec",
2059  .u1.name_canon = "codec", },
2061  { .func_arg = opt_bitrate },
2062  "alias for -b:a (select bitrate for audio streams)", "bitrate" },
2064  { .off = OFFSET(apad) },
2065  "audio pad", "" },
2067  { .func_arg = opt_old2new },
2068  "force audio tag/fourcc", "fourcc/tag",
2069  .u1.name_canon = "tag", },
2071  { .off = OFFSET(sample_fmts) },
2072  "set sample format", "format" },
2074  { .off = OFFSET(audio_ch_layouts) },
2075  "set channel layout", "layout",
2076  .u1.names_alt = alt_channel_layout, },
2078  { .off = OFFSET(audio_ch_layouts) },
2079  "set channel layout", "layout",
2080  .u1.name_canon = "channel_layout", },
2082  { .func_arg = opt_audio_filters },
2083  "alias for -filter:a (apply filters to audio streams)", "filter_graph",
2084  .u1.name_canon = "filter", },
2085  { "guess_layout_max", OPT_TYPE_INT, OPT_AUDIO | OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
2086  { .off = OFFSET(guess_layout_max) },
2087  "set the maximum number of channels to try to guess the channel layout" },
2088 
2089  /* subtitle options */
2091  { .off = OFFSET(subtitle_disable) },
2092  "disable subtitle" },
2094  { .func_arg = opt_subtitle_codec },
2095  "alias for -c:s (select encoder/decoder for subtitle streams)", "codec",
2096  .u1.name_canon = "codec", },
2098  { .func_arg = opt_old2new }
2099  , "force subtitle tag/fourcc", "fourcc/tag",
2100  .u1.name_canon = "tag" },
2101  { "fix_sub_duration", OPT_TYPE_BOOL, OPT_EXPERT | OPT_SUBTITLE | OPT_PERSTREAM | OPT_INPUT,
2102  { .off = OFFSET(fix_sub_duration) },
2103  "fix subtitles duration" },
2105  { .off = OFFSET(canvas_sizes) },
2106  "set canvas size (WxH or abbreviation)", "size" },
2107 
2108  /* muxer options */
2109  { "muxdelay", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
2110  { .off = OFFSET(mux_max_delay) },
2111  "set the maximum demux-decode delay", "seconds" },
2112  { "muxpreload", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
2113  { .off = OFFSET(mux_preload) },
2114  "set the initial demux-decode delay", "seconds" },
2115  { "sdp_file", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_OUTPUT,
2116  { .func_arg = opt_sdp_file },
2117  "specify a file in which to print sdp information", "file" },
2118 
2119  { "time_base", OPT_TYPE_STRING, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
2120  { .off = OFFSET(time_bases) },
2121  "set the desired time base hint for output stream (1:24, 1:48000 or 0.04166, 2.0833e-5)", "ratio" },
2122  { "enc_time_base", OPT_TYPE_STRING, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
2123  { .off = OFFSET(enc_time_bases) },
2124  "set the desired time base for the encoder (1:24, 1:48000 or 0.04166, 2.0833e-5). "
2125  "two special values are defined - "
2126  "0 = use frame rate (video) or sample rate (audio),"
2127  "-1 = match source time base", "ratio" },
2128 
2130  { .off = OFFSET(bitstream_filters) },
2131  "A comma-separated list of bitstream filters", "bitstream_filters", },
2132 
2134  { .func_arg = opt_preset },
2135  "set the audio options to the indicated preset", "preset",
2136  .u1.name_canon = "pre", },
2138  { .func_arg = opt_preset },
2139  "set the video options to the indicated preset", "preset",
2140  .u1.name_canon = "pre", },
2142  { .func_arg = opt_preset },
2143  "set the subtitle options to the indicated preset", "preset",
2144  .u1.name_canon = "pre", },
2146  { .func_arg = opt_preset },
2147  "set options from indicated preset file", "filename",
2148  .u1.name_canon = "pre", },
2149 
2150  { "max_muxing_queue_size", OPT_TYPE_INT, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
2151  { .off = OFFSET(max_muxing_queue_size) },
2152  "maximum number of packets that can be buffered while waiting for all streams to initialize", "packets" },
2153  { "muxing_queue_data_threshold", OPT_TYPE_INT, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
2154  { .off = OFFSET(muxing_queue_data_threshold) },
2155  "set the threshold after which max_muxing_queue_size is taken into account", "bytes" },
2156 
2157  /* data codec support */
2159  { .func_arg = opt_data_codec },
2160  "alias for -c:d (select encoder/decoder for data streams)", "codec",
2161  .u1.name_canon = "codec", },
2163  { .off = OFFSET(data_disable) }, "disable data" },
2164 
2165 #if CONFIG_VAAPI
2166  { "vaapi_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
2167  { .func_arg = opt_vaapi_device },
2168  "set VAAPI hardware device (DirectX adapter index, DRM path or X11 display name)", "device" },
2169 #endif
2170 
2171 #if CONFIG_QSV
2172  { "qsv_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
2173  { .func_arg = opt_qsv_device },
2174  "set QSV hardware device (DirectX adapter index, DRM path or X11 display name)", "device"},
2175 #endif
2176 
2177  { "init_hw_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
2178  { .func_arg = opt_init_hw_device },
2179  "initialise hardware device", "args" },
2180  { "filter_hw_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
2181  { .func_arg = opt_filter_hw_device },
2182  "set hardware device used when filtering", "device" },
2183 
2184  // deprecated options
2185 #if FFMPEG_OPT_ADRIFT_THRESHOLD
2186  { "adrift_threshold", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
2187  { .func_arg = opt_adrift_threshold },
2188  "deprecated, does nothing", "threshold" },
2189 #endif
2190 #if FFMPEG_OPT_TOP
2192  { .off = OFFSET(top_field_first) },
2193  "deprecated, use the setfield video filter", "" },
2194 #endif
2195 #if FFMPEG_OPT_QPHIST
2196  { "qphist", OPT_TYPE_FUNC, OPT_VIDEO | OPT_EXPERT,
2197  { .func_arg = opt_qphist },
2198  "deprecated, does nothing" },
2199 #endif
2200 #if FFMPEG_OPT_VSYNC
2201  { "vsync", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
2202  { .func_arg = opt_vsync },
2203  "set video sync method globally; deprecated, use -fps_mode", "" },
2204 #endif
2205 
2206  { NULL, },
2207 };
flags
const SwsFlags flags[]
Definition: swscale.c:72
OPT_EXIT
#define OPT_EXIT
Definition: cmdutils.h:207
show_help_options
void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags)
Print help for all options matching specified flags.
Definition: cmdutils.c:107
AVCodec
AVCodec.
Definition: codec.h:172
fix_sub_duration_heartbeat
static int fix_sub_duration_heartbeat(DecoderPriv *dp, int64_t signal_pts)
Definition: ffmpeg_dec.c:617
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:216
InputFile::start_time
int64_t start_time
Definition: ffmpeg.h:543
ignore_unknown_streams
int ignore_unknown_streams
Definition: ffmpeg_opt.c:89
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
OptionsContext::stop_time
int64_t stop_time
Definition: ffmpeg.h:192
StreamMap::file_index
int file_index
Definition: ffmpeg.h:137
show_hwaccels
static int show_hwaccels(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:156
program
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C program
Definition: undefined.txt:6
AV_STEREO3D_VIEW_LEFT
@ AV_STEREO3D_VIEW_LEFT
Frame contains only the left view.
Definition: stereo3d.h:158
opt_abort_on
static int opt_abort_on(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:494
VSYNC_VFR
@ VSYNC_VFR
Definition: ffmpeg.h:70
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:109
printf
__device__ int printf(const char *,...)
opt.h
assert_file_overwrite
int assert_file_overwrite(const char *filename)
Definition: ffmpeg_opt.c:840
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:53
opt_video_filters
static int opt_video_filters(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1225
show_help_default
void show_help_default(const char *opt, const char *arg)
Per-fftool specific help handler.
Definition: ffmpeg_opt.c:1310
debug_ts
int debug_ts
Definition: ffmpeg_opt.c:70
stats_period
int64_t stats_period
Definition: ffmpeg_opt.c:84
apply_cropping
static int apply_cropping(AVCodecContext *avctx, AVFrame *frame)
Definition: decode.c:754
is
The official guide to swscale for confused that is
Definition: swscale.txt:28
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:931
opt_old2new
static int opt_old2new(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1168
AVStream::discard
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition: avformat.h:815
stream_specifier_parse
int stream_specifier_parse(StreamSpecifier *ss, const char *spec, int allow_remainder, void *logctx)
Parse a stream specifier string into a form suitable for matching.
Definition: cmdutils.c:1011
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:263
int64_t
long long int64_t
Definition: coverity.c:34
av_asprintf
char * av_asprintf(const char *fmt,...)
Definition: avstring.c:115
av_strcasecmp
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
Definition: avstring.c:208
avformat_get_class
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition: options.c:192
program_name
const char program_name[]
program name, defined by the program for show_version().
Definition: ffmpeg.c:89
no_file_overwrite
static int no_file_overwrite
Definition: ffmpeg_opt.c:88
opt_default_new
static int opt_default_new(OptionsContext *o, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1089
OptionsContext::nb_attachments
int nb_attachments
Definition: ffmpeg.h:187
avcodec_find_encoder
const AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
Definition: allcodecs.c:1044
auto_conversion_filters
int auto_conversion_filters
Definition: ffmpeg_opt.c:83
audio_channels
int audio_channels
Definition: rtp.c:40
opt_audio_codec
static int opt_audio_codec(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:531
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1331
OptionsContext::mux_max_delay
float mux_max_delay
Definition: ffmpeg.h:195
OPT_FLAG_OFFSET
#define OPT_FLAG_OFFSET
Definition: cmdutils.h:223
OPT_INPUT
#define OPT_INPUT
Definition: cmdutils.h:237
copy_unknown_streams
int copy_unknown_streams
Definition: ffmpeg_opt.c:90
parse_number
int parse_number(const char *context, const char *numstr, enum OptionType type, double min, double max, double *dst)
Parse a string and return its corresponding value as a double.
Definition: cmdutils.c:84
AV_HWDEVICE_TYPE_NONE
@ AV_HWDEVICE_TYPE_NONE
Definition: hwcontext.h:28
StreamSpecifier
Definition: cmdutils.h:113
AVOption
AVOption.
Definition: opt.h:429
OptionGroupList::groups
OptionGroup * groups
Definition: cmdutils.h:360
OptionGroupList::nb_groups
int nb_groups
Definition: cmdutils.h:361
opt_timelimit
int opt_timelimit(void *optctx, const char *opt, const char *arg)
Limit the execution time.
format_opts
AVDictionary * format_opts
Definition: cmdutils.c:58
filter_hw_device
HWDevice * filter_hw_device
Definition: ffmpeg_opt.c:52
ffmpeg.h
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:226
progress_avio
AVIOContext * progress_avio
Definition: ffmpeg.c:106
opt_filter_hw_device
static int opt_filter_hw_device(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:770
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_hwdevice_iterate_types
enum AVHWDeviceType av_hwdevice_iterate_types(enum AVHWDeviceType prev)
Iterate over supported device types.
Definition: hwcontext.c:129
autorotate
static int autorotate
Definition: ffplay.c:350
ViewSpecifier
Definition: ffmpeg.h:129
UNKNOWN
@ UNKNOWN
Definition: ftp.c:39
video_disable
static int video_disable
Definition: ffplay.c:317
mathematics.h
AVDictionary
Definition: dict.c:32
HWDevice
Definition: ffmpeg.h:110
hw_device_init_from_string
int hw_device_init_from_string(const char *arg, HWDevice **dev)
Definition: ffmpeg_hw.c:92
VIEW_SPECIFIER_TYPE_ALL
@ VIEW_SPECIFIER_TYPE_ALL
Definition: ffmpeg.h:126
do_benchmark
int do_benchmark
Definition: ffmpeg_opt.c:63
AV_STEREO3D_VIEW_RIGHT
@ AV_STEREO3D_VIEW_RIGHT
Frame contains only the right view.
Definition: stereo3d.h:163
av_strlcatf
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
Definition: avstring.c:103
GlobalOptionsContext
Definition: ffmpeg_opt.c:95
OptionDef
Definition: cmdutils.h:195
subtitle_disable
static int subtitle_disable
Definition: ffplay.c:318
OPT_DATA
#define OPT_DATA
Definition: cmdutils.h:215
stream_specifier_uninit
void stream_specifier_uninit(StreamSpecifier *ss)
Definition: cmdutils.c:1002
SpecifierOpt::i
int i
Definition: cmdutils.h:175
OptionsContext::chapters_input_file
int chapters_input_file
Definition: ffmpeg.h:189
opt_filter_threads
static int opt_filter_threads(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:487
do_hex_dump
int do_hex_dump
Definition: ffmpeg_opt.c:65
OptionGroupList
A list of option groups that all have the same group type (e.g.
Definition: cmdutils.h:357
bsf.h
do_pkt_dump
int do_pkt_dump
Definition: ffmpeg_opt.c:66
uninit_options
static void uninit_options(OptionsContext *o)
Definition: ffmpeg_opt.c:102
OptionsContext::depth
int depth
Definition: ffmpeg.h:264
presets
static const Preset presets[]
Definition: vf_pseudocolor.c:286
opt_timecode
static int opt_timecode(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1245
OptionsContext::g
OptionGroup * g
Definition: ffmpeg.h:146
fail
#define fail()
Definition: checkasm.h:224
StreamMap::disabled
int disabled
Definition: ffmpeg.h:136
GlobalOptionsContext::nb_filtergraphs
int nb_filtergraphs
Definition: ffmpeg_opt.c:99
opt_data_frames
static int opt_data_frames(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1083
VIEW_SPECIFIER_TYPE_POS
@ VIEW_SPECIFIER_TYPE_POS
Definition: ffmpeg.h:124
ifile_open
int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
Definition: ffmpeg_demux.c:2015
OptionParseContext
Definition: cmdutils.h:364
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
sws_get_class
const AVClass * sws_get_class(void)
Get the AVClass for SwsContext.
Definition: options.c:120
OptionsContext
Definition: ffmpeg.h:145
OPT_TYPE_FLOAT
@ OPT_TYPE_FLOAT
Definition: cmdutils.h:86
ss
#define ss(width, name, subs,...)
Definition: cbs_vp9.c:202
loop
static int loop
Definition: ffplay.c:337
AVRational::num
int num
Numerator.
Definition: rational.h:59
opt_audio_filters
static int opt_audio_filters(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1231
InputFile
Definition: ffmpeg.h:529
opt_filter_complex_script
static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1286
OptionGroupDef
Definition: cmdutils.h:325
AV_OPT_FLAG_AUDIO_PARAM
#define AV_OPT_FLAG_AUDIO_PARAM
Definition: opt.h:357
OptionsContext::recording_time
int64_t recording_time
Definition: ffmpeg.h:191
OPT_PERSTREAM
#define OPT_PERSTREAM
Definition: cmdutils.h:233
OptionsContext::nb_stream_maps
int nb_stream_maps
Definition: ffmpeg.h:185
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM
#define ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM
Definition: ffmpeg.h:566
fg_create
int fg_create(FilterGraph **pfg, char **graph_desc, Scheduler *sch, const OutputFilterOptions *opts)
Create a new filtergraph in the global filtergraph list.
Definition: ffmpeg_filter.c:1089
OptionGroup::codec_opts
AVDictionary * codec_opts
Definition: cmdutils.h:347
SpecifierOptList::nb_opt
int nb_opt
Definition: cmdutils.h:185
StreamMap::vs
ViewSpecifier vs
Definition: ffmpeg.h:142
opt_attach
static int opt_attach(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:703
opt_recording_timestamp
static int opt_recording_timestamp(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:784
StreamMap::linklabel
char * linklabel
Definition: ffmpeg.h:140
SpecifierOpt::specifier
char * specifier
Definition: cmdutils.h:169
AVCodecDescriptor
This struct describes the properties of a single codec described by an AVCodecID.
Definition: codec_desc.h:38
stereo3d.h
SpecifierOptList::type
enum OptionType type
Definition: cmdutils.h:192
s
#define s(width, name)
Definition: cbs_vp9.c:198
split_commandline
int split_commandline(OptionParseContext *octx, int argc, char *argv[], const OptionDef *options, const OptionGroupDef *groups, int nb_groups)
Split the commandline into an intermediate form convenient for further processing.
Definition: cmdutils.c:790
AVFormatContext::iformat
const struct AVInputFormat * iformat
The input container format.
Definition: avformat.h:1275
g
const char * g
Definition: vf_curves.c:128
OptionsContext::limit_filesize
int64_t limit_filesize
Definition: ffmpeg.h:193
VIEW_SPECIFIER_TYPE_NONE
@ VIEW_SPECIFIER_TYPE_NONE
Definition: ffmpeg.h:118
av_strtok
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
Definition: avstring.c:179
OPT_TYPE_DOUBLE
@ OPT_TYPE_DOUBLE
Definition: cmdutils.h:87
opt_audio_qscale
static int opt_audio_qscale(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1259
fc
#define fc(width, name, range_min, range_max)
Definition: cbs_av1.c:494
filters
#define filters(fmt, type, inverse, clp, inverset, clip, one, clip_fn, packed)
Definition: af_crystalizer.c:55
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:42
AVHWDeviceType
AVHWDeviceType
Definition: hwcontext.h:27
term_init
void term_init(void)
Definition: ffmpeg.c:205
AVIO_FLAG_WRITE
#define AVIO_FLAG_WRITE
write-only
Definition: avio.h:618
AVStreamGroup::index
unsigned int index
Group index in AVFormatContext.
Definition: avformat.h:1108
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:231
exit_on_error
int exit_on_error
Definition: ffmpeg_opt.c:71
ctx
static AVFormatContext * ctx
Definition: movenc.c:49
print_graphs_format
char * print_graphs_format
Definition: ffmpeg_opt.c:82
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
term_exit
void term_exit(void)
Definition: ffmpeg.c:135
opt_match_per_stream
static unsigned opt_match_per_stream(void *logctx, enum OptionType type, const SpecifierOptList *sol, AVFormatContext *fc, AVStream *st)
Definition: ffmpeg_opt.c:181
print_graphs
int print_graphs
Definition: ffmpeg_opt.c:80
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:120
do_benchmark_all
int do_benchmark_all
Definition: ffmpeg_opt.c:64
OptionsContext::accurate_seek
int accurate_seek
Definition: ffmpeg.h:170
key
const char * key
Definition: hwcontext_opencl.c:189
opt_video_frames
static int opt_video_frames(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1071
tmp
static uint8_t tmp[40]
Definition: aes_ctr.c:52
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
sch_sdp_filename
int sch_sdp_filename(Scheduler *sch, const char *sdp_filename)
Set the file path for the SDP.
Definition: ffmpeg_sched.c:649
arg
const char * arg
Definition: jacosubdec.c:65
if
if(ret)
Definition: filter_design.txt:179
OPT_SPEC
#define OPT_SPEC
Definition: cmdutils.h:229
OptionsContext::start_time
int64_t start_time
Definition: ffmpeg.h:149
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:232
AVFormatContext
Format I/O context.
Definition: avformat.h:1263
OptionGroup::format_opts
AVDictionary * format_opts
Definition: cmdutils.h:348
opts
static AVDictionary * opts
Definition: movenc.c:51
opt_target
static int opt_target(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:905
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:767
open_file
static int open_file(AVFormatContext *avf, unsigned fileno)
Definition: concatdec.c:336
opt_profile
static int opt_profile(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1213
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
dec_create
int dec_create(const OptionsContext *o, const char *arg, Scheduler *sch)
Create a standalone decoder.
Definition: ffmpeg_dec.c:1683
avcodec_get_class
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
Definition: options.c:184
metadata
Stream codec metadata
Definition: ogg-flac-chained-meta.txt:2
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:783
NULL
#define NULL
Definition: coverity.c:32
OPT_HAS_ALT
#define OPT_HAS_ALT
Definition: cmdutils.h:242
OptionParseContext::global_opts
OptionGroup global_opts
Definition: cmdutils.h:365
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:1077
format
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
Definition: swscale-v2.txt:14
av_bsf_get_class
const AVClass * av_bsf_get_class(void)
Get the AVClass for AVBSFContext.
Definition: bsf.c:99
StreamMap::group_index
int group_index
Definition: ffmpeg.h:139
OPT_EXPERT
#define OPT_EXPERT
Definition: cmdutils.h:211
swr_get_class
const AVClass * swr_get_class(void)
Get the AVClass for SwrContext.
Definition: options.c:143
InputFile::start_time_effective
int64_t start_time_effective
Effective format start time based on enabled streams.
Definition: ffmpeg.h:540
AVCodec::type
enum AVMediaType type
Definition: codec.h:185
filter_buffered_frames
int filter_buffered_frames
Definition: ffmpeg_opt.c:78
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:242
parseutils.h
GlobalOptionsContext::sch
Scheduler * sch
Definition: ffmpeg_opt.c:96
options
Definition: swscale.c:45
ViewSpecifier::val
unsigned val
Definition: ffmpeg.h:131
double
double
Definition: af_crystalizer.c:132
av_parse_time
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
Definition: parseutils.c:592
AV_DICT_DONT_OVERWRITE
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
Definition: dict.h:81
stream_specifier_match
unsigned stream_specifier_match(const StreamSpecifier *ss, const AVFormatContext *s, const AVStream *st, void *logctx)
Definition: cmdutils.c:1226
STREAM_LIST_GROUP_IDX
@ STREAM_LIST_GROUP_IDX
Definition: cmdutils.h:110
OptionsContext::input_sync_ref
int input_sync_ref
Definition: ffmpeg.h:172
OptionGroup
Definition: cmdutils.h:340
correct_input_start_times
static void correct_input_start_times(void)
Definition: ffmpeg_opt.c:398
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
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
input_files
InputFile ** input_files
Definition: ffmpeg.c:108
Scheduler
Definition: ffmpeg_sched.c:273
stream_group_specifier_match
unsigned stream_group_specifier_match(const StreamSpecifier *ss, const AVFormatContext *s, const AVStreamGroup *stg, void *logctx)
Definition: cmdutils.c:1352
avcodec_find_decoder
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: allcodecs.c:1049
opt_streamid
static int opt_streamid(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:886
opt_preset
static int opt_preset(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1109
opt_vstats_file
static int opt_vstats_file(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1048
codec_opts
AVDictionary * codec_opts
Definition: cmdutils.c:58
VideoSyncMethod
VideoSyncMethod
Definition: ffmpeg.h:66
opt_bitrate
static int opt_bitrate(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1180
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
max_error_rate
float max_error_rate
Definition: ffmpeg_opt.c:75
frame_sizes
static const uint8_t frame_sizes[]
Definition: rtpdec_qcelp.c:24
f
f
Definition: af_crystalizer.c:122
AVIOContext
Bytestream IO Context.
Definition: avio.h:160
OptionsContext::thread_queue_size
int thread_queue_size
Definition: ffmpeg.h:171
AVMediaType
AVMediaType
Definition: avutil.h:198
OPT_TYPE_INT
@ OPT_TYPE_INT
Definition: cmdutils.h:84
opt_init_hw_device
static int opt_init_hw_device(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:755
SpecifierOptList
Definition: cmdutils.h:183
OPT_AUDIO
#define OPT_AUDIO
Definition: cmdutils.h:213
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
opt_map
static int opt_map(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:555
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
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
start_time
static int64_t start_time
Definition: ffplay.c:328
AVFormatContext::url
char * url
input or output URL.
Definition: avformat.h:1379
get_preset_file
FILE * get_preset_file(char *filename, size_t filename_size, const char *preset_name, int is_path, const char *codec_name)
Get a file corresponding to a preset file.
Definition: cmdutils.c:924
StreamMap
Definition: ffmpeg.h:135
file_overwrite
static int file_overwrite
Definition: ffmpeg_opt.c:87
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:247
opt_subtitle_codec
static int opt_subtitle_codec(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:543
OptionsContext::streamid
AVDictionary * streamid
Definition: ffmpeg.h:206
avio_check
int avio_check(const char *url, int flags)
Return AVIO_FLAG_* access flags corresponding to the access permissions of the resource in url,...
Definition: avio.c:670
AVFMT_NOFILE
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:468
vstats_filename
char * vstats_filename
Definition: ffmpeg_opt.c:54
OPT_TYPE_INT64
@ OPT_TYPE_INT64
Definition: cmdutils.h:85
OptionType
OptionType
Definition: cmdutils.h:80
show_usage
void show_usage(void)
Definition: ffmpeg_opt.c:1427
opt_sdp_file
static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:717
fg_finalise_bindings
int fg_finalise_bindings(void)
Definition: ffmpeg_filter.c:1492
diff
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
Definition: vf_paletteuse.c:166
OPT_FLAG_SPEC
#define OPT_FLAG_SPEC
Definition: cmdutils.h:228
OptionsContext::find_stream_info
int find_stream_info
Definition: ffmpeg.h:173
SpecifierOptList::opt
SpecifierOpt * opt
Definition: cmdutils.h:184
line
Definition: graph2dot.c:48
opt_data_codec
static int opt_data_codec(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:549
init_options
static void init_options(OptionsContext *o)
Definition: ffmpeg_opt.c:138
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:233
parse_and_set_vsync
int parse_and_set_vsync(const char *arg, enum VideoSyncMethod *vsync_var, int file_idx, int st_idx, int is_global)
Definition: ffmpeg_opt.c:362
OPT_TYPE_FUNC
@ OPT_TYPE_FUNC
Definition: cmdutils.h:81
OPT_DECODER
#define OPT_DECODER
Definition: cmdutils.h:248
OPT_TYPE_BOOL
@ OPT_TYPE_BOOL
Definition: cmdutils.h:82
video_sync_method
enum VideoSyncMethod video_sync_method
Definition: ffmpeg_opt.c:60
OPT_HAS_CANON
#define OPT_HAS_CANON
Definition: cmdutils.h:245
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:221
start_at_zero
int start_at_zero
Definition: ffmpeg_opt.c:68
OptionDef::u1
union OptionDef::@2 u1
apply_sync_offsets
static int apply_sync_offsets(void)
Definition: ffmpeg_opt.c:435
StreamMap::stream_index
int stream_index
Definition: ffmpeg.h:138
OPT_TYPE_TIME
@ OPT_TYPE_TIME
Definition: cmdutils.h:88
OptionsContext::codec_names
SpecifierOptList codec_names
Definition: ffmpeg.h:154
OptionsContext::stream_maps
StreamMap * stream_maps
Definition: ffmpeg.h:184
OptionsContext::start_time_eof
int64_t start_time_eof
Definition: ffmpeg.h:150
VSYNC_CFR
@ VSYNC_CFR
Definition: ffmpeg.h:69
OptionsContext::shortest_buf_duration
float shortest_buf_duration
Definition: ffmpeg.h:196
opt_video_codec
static int opt_video_codec(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:537
opt_qscale
static int opt_qscale(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1196
stdin_interaction
int stdin_interaction
Definition: ffmpeg_opt.c:74
value
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 value
Definition: writing_filters.txt:86
InputFile::ctx
AVFormatContext * ctx
Definition: ffmpeg.h:534
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_OPT_FLAG_VIDEO_PARAM
#define AV_OPT_FLAG_VIDEO_PARAM
Definition: opt.h:358
OPT_FUNC_ARG
#define OPT_FUNC_ARG
Definition: cmdutils.h:205
opt_vstats
static int opt_vstats(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1055
OPT_OUTPUT
#define OPT_OUTPUT
Definition: cmdutils.h:238
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:179
dts_error_threshold
float dts_error_threshold
Definition: ffmpeg_opt.c:57
cmdutils_isalnum
int cmdutils_isalnum(char c)
Definition: cmdutils.c:995
int_cb
const AVIOInterruptCB int_cb
Definition: ffmpeg.c:312
OPT_OFFSET
#define OPT_OFFSET
Definition: cmdutils.h:224
OptionParseContext::groups
OptionGroupList * groups
Definition: cmdutils.h:367
print_graphs_file
char * print_graphs_file
Definition: ffmpeg_opt.c:81
opt_audio_frames
static int opt_audio_frames(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1077
avcodec.h
SpecifierOpt::i64
int64_t i64
Definition: cmdutils.h:176
SpecifierOptList::opt_canon
const struct OptionDef * opt_canon
Definition: cmdutils.h:188
av_opt_eval_flags
int av_opt_eval_flags(void *obj, const AVOption *o, const char *val, int *flags_out)
SpecifierOpt
Definition: cmdutils.h:167
find_codec
int find_codec(void *logctx, const char *name, enum AVMediaType type, int encoder, const AVCodec **pcodec)
Definition: ffmpeg_opt.c:807
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:744
AV_LOG_FATAL
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:204
read_yesno
int read_yesno(void)
Return a positive value if a line read from standard input starts with [yY], otherwise return 0.
Definition: cmdutils.c:913
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:81
VIEW_SPECIFIER_TYPE_IDX
@ VIEW_SPECIFIER_TYPE_IDX
Definition: ffmpeg.h:120
VSYNC_DROP
@ VSYNC_DROP
Definition: ffmpeg.h:73
uninit_parse_context
void uninit_parse_context(OptionParseContext *octx)
Free all allocated memory in an OptionParseContext.
Definition: cmdutils.c:765
OPT_PERFILE
#define OPT_PERFILE
Definition: cmdutils.h:219
opt_match_per_stream_group
static unsigned opt_match_per_stream_group(void *logctx, enum OptionType type, const SpecifierOptList *sol, AVFormatContext *fc, AVStreamGroup *stg)
Definition: ffmpeg_opt.c:245
SpecifierOpt::stream_spec
StreamSpecifier stream_spec
Definition: cmdutils.h:171
OPT_MATCH_PER_STREAM_GROUP
#define OPT_MATCH_PER_STREAM_GROUP(name, type, opt_type, m)
Definition: ffmpeg_opt.c:295
find_stream_info
static int find_stream_info
Definition: ffplay.c:351
avformat.h
CMDUTILS_COMMON_OPTIONS
#define CMDUTILS_COMMON_OPTIONS
Definition: opt_common.h:199
filter_nbthreads
char * filter_nbthreads
Definition: ffmpeg_opt.c:76
AVStreamGroup
Definition: avformat.h:1097
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:750
OPT_FLAG_PERSTREAM
#define OPT_FLAG_PERSTREAM
Definition: cmdutils.h:232
parse_option
int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options)
Parse one given option.
Definition: cmdutils.c:380
OptionsContext::mux_preload
float mux_preload
Definition: ffmpeg.h:194
OptionDef::names_alt
const char *const * names_alt
Definition: cmdutils.h:264
opt_match_per_type_str
const char * opt_match_per_type_str(const SpecifierOptList *sol, char mediatype)
Definition: ffmpeg_opt.c:168
opt_common.h
AVInputFormat::flags
int flags
Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, AVFMT_NOTIMESTAMPS,...
Definition: avformat.h:563
AVRational::den
int den
Denominator.
Definition: rational.h:60
SpecifierOpt::str
uint8_t * str
Definition: cmdutils.h:174
OPT_SUBTITLE
#define OPT_SUBTITLE
Definition: cmdutils.h:214
avfilter.h
av_get_token
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
Definition: avstring.c:143
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:117
ffmpeg_parse_options
int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
GROW_ARRAY
#define GROW_ARRAY(array, nb_elems)
Definition: cmdutils.h:536
InputFile::ts_offset
int64_t ts_offset
Definition: ffmpeg.h:541
VSYNC_AUTO
@ VSYNC_AUTO
Definition: ffmpeg.h:67
opt_vsync
static int opt_vsync(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1238
parse_optgroup
int parse_optgroup(void *optctx, OptionGroup *g, const OptionDef *defs)
Parse an options group and write results into optctx.
Definition: cmdutils.c:456
GlobalOptionsContext::filtergraphs
char ** filtergraphs
Definition: ffmpeg_opt.c:98
AVERROR_DECODER_NOT_FOUND
#define AVERROR_DECODER_NOT_FOUND
Decoder not found.
Definition: error.h:54
opt_default
int opt_default(void *optctx, const char *opt, const char *arg)
Fallback for options that are not explicitly handled, these will be parsed through AVOptions.
Definition: cmdutils.c:599
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:83
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
AVERROR_ENCODER_NOT_FOUND
#define AVERROR_ENCODER_NOT_FOUND
Encoder not found.
Definition: error.h:56
avutil.h
ViewSpecifier::type
enum ViewSpecifierType type
Definition: ffmpeg.h:130
AVFMT_TS_DISCONT
#define AVFMT_TS_DISCONT
Format allows timestamp discontinuities.
Definition: avformat.h:480
mem.h
copy_tb
int copy_tb
Definition: ffmpeg_opt.c:69
SpecifierOpt::u
union SpecifierOpt::@0 u
opt_stats_period
static int opt_stats_period(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:513
vstats_version
int vstats_version
Definition: ffmpeg_opt.c:79
avio_open2
int avio_open2(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
Definition: avio.c:497
av_strdup
#define av_strdup(s)
Definition: ops_asmgen.c:47
of_open
int of_open(const OptionsContext *o, const char *filename, Scheduler *sch)
Definition: ffmpeg_mux_init.c:3332
OptionDef::name
const char * name
Definition: cmdutils.h:196
ffmpeg_sched.h
OPT_VIDEO
#define OPT_VIDEO
Definition: cmdutils.h:212
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
OptionsContext::attachments
const char ** attachments
Definition: ffmpeg.h:186
SpecifierOpt::dbl
double dbl
Definition: cmdutils.h:179
OPT_TYPE_STRING
@ OPT_TYPE_STRING
Definition: cmdutils.h:83
audio_disable
static int audio_disable
Definition: ffplay.c:316
VIEW_SPECIFIER_TYPE_ID
@ VIEW_SPECIFIER_TYPE_ID
Definition: ffmpeg.h:122
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
av_dict_set
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:86
av_dict_copy
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
Definition: dict.c:247
copy_ts
int copy_ts
Definition: ffmpeg_opt.c:67
cmdutils.h
OFFSET
#define OFFSET(x)
InputFile::input_ts_offset
int64_t input_ts_offset
Definition: ffmpeg.h:535
avio_find_protocol_name
const char * avio_find_protocol_name(const char *url)
Return the name of the protocol that will handle the passed URL.
Definition: avio.c:663
codec_string
Definition: codecstring.c:36
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition: opt.h:255
frame_drop_threshold
float frame_drop_threshold
Definition: ffmpeg_opt.c:62
recast_media
int recast_media
Definition: ffmpeg_opt.c:91
view_specifier_parse
int view_specifier_parse(const char **pspec, ViewSpecifier *vs)
Definition: ffmpeg_opt.c:309
av_strlcpy
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition: avstring.c:85
print_stats
int print_stats
Definition: ffmpeg_opt.c:73
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
graphprint.h
read_file_to_string
char * read_file_to_string(const char *filename)
Definition: cmdutils.c:1571
AVERROR_EXIT
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:58
AVStream::start_time
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
Definition: avformat.h:793
avstring.h
avcodec_descriptor_get_by_name
const AVCodecDescriptor * avcodec_descriptor_get_by_name(const char *name)
Definition: codec_desc.c:3903
InputFile::nb_streams
int nb_streams
Definition: ffmpeg.h:549
OPT_MATCH_PER_STREAM
#define OPT_MATCH_PER_STREAM(name, type, opt_type, m)
Definition: ffmpeg_opt.c:231
hw_device_get_by_name
HWDevice * hw_device_get_by_name(const char *name)
Definition: ffmpeg_hw.c:42
avfilter_get_class
const AVClass * avfilter_get_class(void)
Definition: avfilter.c:1658
dump_attachment
static int dump_attachment(InputStream *ist, const char *filename)
Definition: ffmpeg_demux.c:1943
VSYNC_PASSTHROUGH
@ VSYNC_PASSTHROUGH
Definition: ffmpeg.h:68
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
snprintf
#define snprintf
Definition: snprintf.h:34
ABORT_ON_FLAG_EMPTY_OUTPUT
#define ABORT_ON_FLAG_EMPTY_OUTPUT
Definition: ffmpeg.h:565
SpecifierOpt::f
float f
Definition: cmdutils.h:178
opt_filter_complex
static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1265
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:1072
dts_delta_threshold
float dts_delta_threshold
Definition: ffmpeg_opt.c:56
abort_on_flags
int abort_on_flags
Definition: ffmpeg_opt.c:72
filter_complex_nbthreads
int filter_complex_nbthreads
Definition: ffmpeg_opt.c:77
OptionDef::flags
int flags
Definition: cmdutils.h:198