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 #include "sync_queue.h"
35 
36 #include "libavformat/avformat.h"
37 
38 #include "libavcodec/avcodec.h"
39 #include "libavcodec/bsf.h"
40 
41 #include "libavfilter/avfilter.h"
42 
43 #include "libavutil/avassert.h"
44 #include "libavutil/avstring.h"
45 #include "libavutil/avutil.h"
46 #include "libavutil/bprint.h"
48 #include "libavutil/display.h"
49 #include "libavutil/intreadwrite.h"
50 #include "libavutil/fifo.h"
51 #include "libavutil/mathematics.h"
52 #include "libavutil/opt.h"
53 #include "libavutil/parseutils.h"
54 #include "libavutil/pixdesc.h"
55 #include "libavutil/pixfmt.h"
56 
58 
60 
63 float dts_error_threshold = 3600*30;
64 
65 #if FFMPEG_OPT_VSYNC
67 #endif
69 int do_benchmark = 0;
71 int do_hex_dump = 0;
72 int do_pkt_dump = 0;
73 int copy_ts = 0;
74 int start_at_zero = 0;
75 int copy_tb = -1;
76 int debug_ts = 0;
77 int exit_on_error = 0;
79 int print_stats = -1;
81 float max_error_rate = 2.0/3;
87 
88 
89 static int file_overwrite = 0;
90 static int no_file_overwrite = 0;
93 int recast_media = 0;
94 
96 {
97  int i;
98 
99  /* all OPT_SPEC and OPT_TYPE_STRING can be freed in generic way */
100  for (const OptionDef *po = options; po->name; po++) {
101  void *dst;
102 
103  if (!(po->flags & OPT_FLAG_OFFSET))
104  continue;
105 
106  dst = (uint8_t*)o + po->u.off;
107  if (po->flags & OPT_FLAG_SPEC) {
108  SpecifierOptList *so = dst;
109  for (int i = 0; i < so->nb_opt; i++) {
110  av_freep(&so->opt[i].specifier);
111  if (po->type == OPT_TYPE_STRING)
112  av_freep(&so->opt[i].u.str);
113  }
114  av_freep(&so->opt);
115  so->nb_opt = 0;
116  } else if (po->type == OPT_TYPE_STRING)
117  av_freep(dst);
118  }
119 
120  for (i = 0; i < o->nb_stream_maps; i++)
122  av_freep(&o->stream_maps);
123 
124  for (i = 0; i < o->nb_attachments; i++)
125  av_freep(&o->attachments[i]);
126  av_freep(&o->attachments);
127 
128  av_dict_free(&o->streamid);
129 }
130 
132 {
133  memset(o, 0, sizeof(*o));
134 
135  o->stop_time = INT64_MAX;
136  o->mux_max_delay = 0.7;
139  o->recording_time = INT64_MAX;
140  o->limit_filesize = INT64_MAX;
141  o->chapters_input_file = INT_MAX;
142  o->accurate_seek = 1;
143  o->thread_queue_size = 0;
144  o->input_sync_ref = -1;
145  o->find_stream_info = 1;
146  o->shortest_buf_duration = 10.f;
147 }
148 
149 static int show_hwaccels(void *optctx, const char *opt, const char *arg)
150 {
152 
153  printf("Hardware acceleration methods:\n");
154  while ((type = av_hwdevice_iterate_types(type)) !=
157  printf("\n");
158  return 0;
159 }
160 
161 /* return a copy of the input with the stream specifiers removed from the keys */
163 {
164  const AVDictionaryEntry *e = NULL;
165  AVDictionary *ret = NULL;
166 
167  while ((e = av_dict_iterate(dict, e))) {
168  char *p = strchr(e->key, ':');
169 
170  if (p)
171  *p = 0;
172  av_dict_set(&ret, e->key, e->value, 0);
173  if (p)
174  *p = ':';
175  }
176  return ret;
177 }
178 
180  char mediatype)
181 {
182  av_assert0(!sol->nb_opt || sol->type == OPT_TYPE_STRING);
183 
184  for (int i = 0; i < sol->nb_opt; i++) {
185  const char *spec = sol->opt[i].specifier;
186  if (spec[0] == mediatype && !spec[1])
187  return sol->opt[i].u.str;
188  }
189  return NULL;
190 }
191 
192 int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global)
193 {
194  if (!av_strcasecmp(arg, "cfr")) *vsync_var = VSYNC_CFR;
195  else if (!av_strcasecmp(arg, "vfr")) *vsync_var = VSYNC_VFR;
196  else if (!av_strcasecmp(arg, "passthrough")) *vsync_var = VSYNC_PASSTHROUGH;
197 #if FFMPEG_OPT_VSYNC_DROP
198  else if (!av_strcasecmp(arg, "drop")) {
199  av_log(NULL, AV_LOG_WARNING, "-vsync/fps_mode drop is deprecated\n");
200  *vsync_var = VSYNC_DROP;
201  }
202 #endif
203  else if (!is_global && !av_strcasecmp(arg, "auto")) *vsync_var = VSYNC_AUTO;
204  else if (!is_global) {
205  av_log(NULL, AV_LOG_FATAL, "Invalid value %s specified for fps_mode of #%d:%d.\n", arg, file_idx, st_idx);
206  return AVERROR(EINVAL);
207  }
208 
209 #if FFMPEG_OPT_VSYNC
210  if (is_global && *vsync_var == VSYNC_AUTO) {
211  int ret;
212  double num;
213 
214  ret = parse_number("vsync", arg, OPT_TYPE_INT, VSYNC_AUTO, VSYNC_VFR, &num);
215  if (ret < 0)
216  return ret;
217 
218  video_sync_method = num;
219  av_log(NULL, AV_LOG_WARNING, "Passing a number to -vsync is deprecated,"
220  " use a string argument as described in the manual.\n");
221  }
222 #endif
223 
224  return 0;
225 }
226 
227 /* Correct input file start times based on enabled streams */
228 static void correct_input_start_times(void)
229 {
230  for (int i = 0; i < nb_input_files; i++) {
231  InputFile *ifile = input_files[i];
232  AVFormatContext *is = ifile->ctx;
233  int64_t new_start_time = INT64_MAX, diff, abs_start_seek;
234 
235  ifile->start_time_effective = is->start_time;
236 
237  if (is->start_time == AV_NOPTS_VALUE ||
238  !(is->iformat->flags & AVFMT_TS_DISCONT))
239  continue;
240 
241  for (int j = 0; j < is->nb_streams; j++) {
242  AVStream *st = is->streams[j];
243  if(st->discard == AVDISCARD_ALL || st->start_time == AV_NOPTS_VALUE)
244  continue;
245  new_start_time = FFMIN(new_start_time, av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q));
246  }
247 
248  diff = new_start_time - is->start_time;
249  if (diff) {
250  av_log(NULL, AV_LOG_VERBOSE, "Correcting start time of Input #%d by %"PRId64" us.\n", i, diff);
251  ifile->start_time_effective = new_start_time;
252  if (copy_ts && start_at_zero)
253  ifile->ts_offset = -new_start_time;
254  else if (!copy_ts) {
255  abs_start_seek = is->start_time + (ifile->start_time != AV_NOPTS_VALUE) ? ifile->start_time : 0;
256  ifile->ts_offset = abs_start_seek > new_start_time ? -abs_start_seek : -new_start_time;
257  } else if (copy_ts)
258  ifile->ts_offset = 0;
259 
260  ifile->ts_offset += ifile->input_ts_offset;
261  }
262  }
263 }
264 
265 static int apply_sync_offsets(void)
266 {
267  for (int i = 0; i < nb_input_files; i++) {
268  InputFile *ref, *self = input_files[i];
269  int64_t adjustment;
270  int64_t self_start_time, ref_start_time, self_seek_start, ref_seek_start;
271  int start_times_set = 1;
272 
273  if (self->input_sync_ref == -1 || self->input_sync_ref == i) continue;
274  if (self->input_sync_ref >= nb_input_files || self->input_sync_ref < -1) {
275  av_log(NULL, AV_LOG_FATAL, "-isync for input %d references non-existent input %d.\n", i, self->input_sync_ref);
276  return AVERROR(EINVAL);
277  }
278 
279  if (copy_ts && !start_at_zero) {
280  av_log(NULL, AV_LOG_FATAL, "Use of -isync requires that start_at_zero be set if copyts is set.\n");
281  return AVERROR(EINVAL);
282  }
283 
284  ref = input_files[self->input_sync_ref];
285  if (ref->input_sync_ref != -1 && ref->input_sync_ref != self->input_sync_ref) {
286  av_log(NULL, AV_LOG_ERROR, "-isync for input %d references a resynced input %d. Sync not set.\n", i, self->input_sync_ref);
287  continue;
288  }
289 
290  if (self->ctx->start_time_realtime != AV_NOPTS_VALUE && ref->ctx->start_time_realtime != AV_NOPTS_VALUE) {
291  self_start_time = self->ctx->start_time_realtime;
292  ref_start_time = ref->ctx->start_time_realtime;
293  } else if (self->start_time_effective != AV_NOPTS_VALUE && ref->start_time_effective != AV_NOPTS_VALUE) {
294  self_start_time = self->start_time_effective;
295  ref_start_time = ref->start_time_effective;
296  } else {
297  start_times_set = 0;
298  }
299 
300  if (start_times_set) {
301  self_seek_start = self->start_time == AV_NOPTS_VALUE ? 0 : self->start_time;
302  ref_seek_start = ref->start_time == AV_NOPTS_VALUE ? 0 : ref->start_time;
303 
304  adjustment = (self_start_time - ref_start_time) + !copy_ts*(self_seek_start - ref_seek_start) + ref->input_ts_offset;
305 
306  self->ts_offset += adjustment;
307 
308  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);
309  } else {
310  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);
311  }
312  }
313 
314  return 0;
315 }
316 
317 static int opt_filter_threads(void *optctx, const char *opt, const char *arg)
318 {
321  return 0;
322 }
323 
324 static int opt_abort_on(void *optctx, const char *opt, const char *arg)
325 {
326  static const AVOption opts[] = {
327  { "abort_on" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" },
328  { "empty_output" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = ABORT_ON_FLAG_EMPTY_OUTPUT }, .unit = "flags" },
329  { "empty_output_stream", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM }, .unit = "flags" },
330  { NULL },
331  };
332  static const AVClass class = {
333  .class_name = "",
334  .item_name = av_default_item_name,
335  .option = opts,
336  .version = LIBAVUTIL_VERSION_INT,
337  };
338  const AVClass *pclass = &class;
339 
340  return av_opt_eval_flags(&pclass, &opts[0], arg, &abort_on_flags);
341 }
342 
343 static int opt_stats_period(void *optctx, const char *opt, const char *arg)
344 {
345  int64_t user_stats_period;
346  int ret = av_parse_time(&user_stats_period, arg, 1);
347  if (ret < 0)
348  return ret;
349 
350  if (user_stats_period <= 0) {
351  av_log(NULL, AV_LOG_ERROR, "stats_period %s must be positive.\n", arg);
352  return AVERROR(EINVAL);
353  }
354 
355  stats_period = user_stats_period;
356  av_log(NULL, AV_LOG_INFO, "ffmpeg stats and -progress period set to %s.\n", arg);
357 
358  return 0;
359 }
360 
361 static int opt_audio_codec(void *optctx, const char *opt, const char *arg)
362 {
363  OptionsContext *o = optctx;
364  return parse_option(o, "codec:a", arg, options);
365 }
366 
367 static int opt_video_codec(void *optctx, const char *opt, const char *arg)
368 {
369  OptionsContext *o = optctx;
370  return parse_option(o, "codec:v", arg, options);
371 }
372 
373 static int opt_subtitle_codec(void *optctx, const char *opt, const char *arg)
374 {
375  OptionsContext *o = optctx;
376  return parse_option(o, "codec:s", arg, options);
377 }
378 
379 static int opt_data_codec(void *optctx, const char *opt, const char *arg)
380 {
381  OptionsContext *o = optctx;
382  return parse_option(o, "codec:d", arg, options);
383 }
384 
385 static int opt_map(void *optctx, const char *opt, const char *arg)
386 {
387  OptionsContext *o = optctx;
388  StreamMap *m = NULL;
389  int i, negative = 0, file_idx, disabled = 0;
390  int ret;
391  char *map, *p;
392  char *allow_unused;
393 
394  if (*arg == '-') {
395  negative = 1;
396  arg++;
397  }
398  map = av_strdup(arg);
399  if (!map)
400  return AVERROR(ENOMEM);
401 
402  if (map[0] == '[') {
403  /* this mapping refers to lavfi output */
404  const char *c = map + 1;
405 
407  if (ret < 0)
408  goto fail;
409 
410  m = &o->stream_maps[o->nb_stream_maps - 1];
411  m->linklabel = av_get_token(&c, "]");
412  if (!m->linklabel) {
413  av_log(NULL, AV_LOG_ERROR, "Invalid output link label: %s.\n", map);
414  ret = AVERROR(EINVAL);
415  goto fail;
416  }
417  } else {
418  if (allow_unused = strchr(map, '?'))
419  *allow_unused = 0;
420  file_idx = strtol(map, &p, 0);
421  if (file_idx >= nb_input_files || file_idx < 0) {
422  av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx);
423  ret = AVERROR(EINVAL);
424  goto fail;
425  }
426  if (negative)
427  /* disable some already defined maps */
428  for (i = 0; i < o->nb_stream_maps; i++) {
429  m = &o->stream_maps[i];
430  if (file_idx == m->file_index &&
433  *p == ':' ? p + 1 : p) > 0)
434  m->disabled = 1;
435  }
436  else
437  for (i = 0; i < input_files[file_idx]->nb_streams; i++) {
438  if (check_stream_specifier(input_files[file_idx]->ctx, input_files[file_idx]->ctx->streams[i],
439  *p == ':' ? p + 1 : p) <= 0)
440  continue;
441  if (input_files[file_idx]->streams[i]->user_set_discard == AVDISCARD_ALL) {
442  disabled = 1;
443  continue;
444  }
446  if (ret < 0)
447  goto fail;
448 
449  m = &o->stream_maps[o->nb_stream_maps - 1];
450 
451  m->file_index = file_idx;
452  m->stream_index = i;
453  }
454  }
455 
456  if (!m) {
457  if (allow_unused) {
458  av_log(NULL, AV_LOG_VERBOSE, "Stream map '%s' matches no streams; ignoring.\n", arg);
459  } else if (disabled) {
460  av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches disabled streams.\n"
461  "To ignore this, add a trailing '?' to the map.\n", arg);
462  ret = AVERROR(EINVAL);
463  goto fail;
464  } else {
465  av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n"
466  "To ignore this, add a trailing '?' to the map.\n", arg);
467  ret = AVERROR(EINVAL);
468  goto fail;
469  }
470  }
471  ret = 0;
472 fail:
473  av_freep(&map);
474  return ret;
475 }
476 
477 static int opt_attach(void *optctx, const char *opt, const char *arg)
478 {
479  OptionsContext *o = optctx;
481  if (ret < 0)
482  return ret;
483 
484  o->attachments[o->nb_attachments - 1] = av_strdup(arg);
485  if (!o->attachments[o->nb_attachments - 1])
486  return AVERROR(ENOMEM);
487 
488  return 0;
489 }
490 
491 static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
492 {
493  Scheduler *sch = optctx;
494  return sch_sdp_filename(sch, arg);
495 }
496 
497 #if CONFIG_VAAPI
498 static int opt_vaapi_device(void *optctx, const char *opt, const char *arg)
499 {
500  const char *prefix = "vaapi:";
501  char *tmp;
502  int err;
503  tmp = av_asprintf("%s%s", prefix, arg);
504  if (!tmp)
505  return AVERROR(ENOMEM);
507  av_free(tmp);
508  return err;
509 }
510 #endif
511 
512 #if CONFIG_QSV
513 static int opt_qsv_device(void *optctx, const char *opt, const char *arg)
514 {
515  const char *prefix = "qsv=__qsv_device:hw_any,child_device=";
516  int err;
517  char *tmp = av_asprintf("%s%s", prefix, arg);
518 
519  if (!tmp)
520  return AVERROR(ENOMEM);
521 
523  av_free(tmp);
524 
525  return err;
526 }
527 #endif
528 
529 static int opt_init_hw_device(void *optctx, const char *opt, const char *arg)
530 {
531  if (!strcmp(arg, "list")) {
533  printf("Supported hardware device types:\n");
534  while ((type = av_hwdevice_iterate_types(type)) !=
537  printf("\n");
538  return AVERROR_EXIT;
539  } else {
541  }
542 }
543 
544 static int opt_filter_hw_device(void *optctx, const char *opt, const char *arg)
545 {
546  if (filter_hw_device) {
547  av_log(NULL, AV_LOG_ERROR, "Only one filter device can be used.\n");
548  return AVERROR(EINVAL);
549  }
551  if (!filter_hw_device) {
552  av_log(NULL, AV_LOG_ERROR, "Invalid filter device %s.\n", arg);
553  return AVERROR(EINVAL);
554  }
555  return 0;
556 }
557 
558 static int opt_recording_timestamp(void *optctx, const char *opt, const char *arg)
559 {
560  OptionsContext *o = optctx;
561  char buf[128];
562  int64_t recording_timestamp;
563  int ret;
564  struct tm time;
565 
566  ret = av_parse_time(&recording_timestamp, arg, 0);
567  if (ret < 0)
568  return ret;
569 
570  recording_timestamp /= 1e6;
571  time = *gmtime((time_t*)&recording_timestamp);
572  if (!strftime(buf, sizeof(buf), "creation_time=%Y-%m-%dT%H:%M:%S%z", &time))
573  return -1;
574  parse_option(o, "metadata", buf, options);
575 
576  av_log(NULL, AV_LOG_WARNING, "%s is deprecated, set the 'creation_time' metadata "
577  "tag instead.\n", opt);
578  return 0;
579 }
580 
581 int find_codec(void *logctx, const char *name,
582  enum AVMediaType type, int encoder, const AVCodec **pcodec)
583 {
584  const AVCodecDescriptor *desc;
585  const char *codec_string = encoder ? "encoder" : "decoder";
586  const AVCodec *codec;
587 
588  codec = encoder ?
591 
592  if (!codec && (desc = avcodec_descriptor_get_by_name(name))) {
593  codec = encoder ? avcodec_find_encoder(desc->id) :
595  if (codec)
596  av_log(logctx, AV_LOG_VERBOSE, "Matched %s '%s' for codec '%s'.\n",
597  codec_string, codec->name, desc->name);
598  }
599 
600  if (!codec) {
601  av_log(logctx, AV_LOG_FATAL, "Unknown %s '%s'\n", codec_string, name);
602  return encoder ? AVERROR_ENCODER_NOT_FOUND :
604  }
605  if (codec->type != type && !recast_media) {
606  av_log(logctx, AV_LOG_FATAL, "Invalid %s type '%s'\n", codec_string, name);
607  return AVERROR(EINVAL);
608  }
609 
610  *pcodec = codec;
611  return 0;;
612 }
613 
614 int assert_file_overwrite(const char *filename)
615 {
616  const char *proto_name = avio_find_protocol_name(filename);
617 
619  fprintf(stderr, "Error, both -y and -n supplied. Exiting.\n");
620  return AVERROR(EINVAL);
621  }
622 
623  if (!file_overwrite) {
624  if (proto_name && !strcmp(proto_name, "file") && avio_check(filename, 0) == 0) {
626  fprintf(stderr,"File '%s' already exists. Overwrite? [y/N] ", filename);
627  fflush(stderr);
628  term_exit();
629  signal(SIGINT, SIG_DFL);
630  if (!read_yesno()) {
631  av_log(NULL, AV_LOG_FATAL, "Not overwriting - exiting\n");
632  return AVERROR_EXIT;
633  }
634  term_init();
635  }
636  else {
637  av_log(NULL, AV_LOG_FATAL, "File '%s' already exists. Exiting.\n", filename);
638  return AVERROR_EXIT;
639  }
640  }
641  }
642 
643  if (proto_name && !strcmp(proto_name, "file")) {
644  for (int i = 0; i < nb_input_files; i++) {
645  InputFile *file = input_files[i];
646  if (file->ctx->iformat->flags & AVFMT_NOFILE)
647  continue;
648  if (!strcmp(filename, file->ctx->url)) {
649  av_log(NULL, AV_LOG_FATAL, "Output %s same as Input #%d - exiting\n", filename, i);
650  av_log(NULL, AV_LOG_WARNING, "FFmpeg cannot edit existing files in-place.\n");
651  return AVERROR(EINVAL);
652  }
653  }
654  }
655 
656  return 0;
657 }
658 
659 /* arg format is "output-stream-index:streamid-value". */
660 static int opt_streamid(void *optctx, const char *opt, const char *arg)
661 {
662  OptionsContext *o = optctx;
663  char *p;
664  char idx_str[16];
665 
666  av_strlcpy(idx_str, arg, sizeof(idx_str));
667  p = strchr(idx_str, ':');
668  if (!p) {
670  "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
671  arg, opt);
672  return AVERROR(EINVAL);
673  }
674  *p++ = '\0';
675 
676  return av_dict_set(&o->streamid, idx_str, p, 0);
677 }
678 
679 static int opt_target(void *optctx, const char *opt, const char *arg)
680 {
681  OptionsContext *o = optctx;
682  enum { PAL, NTSC, FILM, UNKNOWN } norm = UNKNOWN;
683  static const char *const frame_rates[] = { "25", "30000/1001", "24000/1001" };
684 
685  if (!strncmp(arg, "pal-", 4)) {
686  norm = PAL;
687  arg += 4;
688  } else if (!strncmp(arg, "ntsc-", 5)) {
689  norm = NTSC;
690  arg += 5;
691  } else if (!strncmp(arg, "film-", 5)) {
692  norm = FILM;
693  arg += 5;
694  } else {
695  /* Try to determine PAL/NTSC by peeking in the input files */
696  if (nb_input_files) {
697  int i, j;
698  for (j = 0; j < nb_input_files; j++) {
699  for (i = 0; i < input_files[j]->nb_streams; i++) {
700  AVStream *st = input_files[j]->ctx->streams[i];
701  int64_t fr;
703  continue;
704  fr = st->time_base.den * 1000LL / st->time_base.num;
705  if (fr == 25000) {
706  norm = PAL;
707  break;
708  } else if ((fr == 29970) || (fr == 23976)) {
709  norm = NTSC;
710  break;
711  }
712  }
713  if (norm != UNKNOWN)
714  break;
715  }
716  }
717  if (norm != UNKNOWN)
718  av_log(NULL, AV_LOG_INFO, "Assuming %s for target.\n", norm == PAL ? "PAL" : "NTSC");
719  }
720 
721  if (norm == UNKNOWN) {
722  av_log(NULL, AV_LOG_FATAL, "Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
723  av_log(NULL, AV_LOG_FATAL, "Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
724  av_log(NULL, AV_LOG_FATAL, "or set a framerate with \"-r xxx\".\n");
725  return AVERROR(EINVAL);
726  }
727 
728  if (!strcmp(arg, "vcd")) {
729  opt_video_codec(o, "c:v", "mpeg1video");
730  opt_audio_codec(o, "c:a", "mp2");
731  parse_option(o, "f", "vcd", options);
732 
733  parse_option(o, "s", norm == PAL ? "352x288" : "352x240", options);
734  parse_option(o, "r", frame_rates[norm], options);
735  opt_default(NULL, "g", norm == PAL ? "15" : "18");
736 
737  opt_default(NULL, "b:v", "1150000");
738  opt_default(NULL, "maxrate:v", "1150000");
739  opt_default(NULL, "minrate:v", "1150000");
740  opt_default(NULL, "bufsize:v", "327680"); // 40*1024*8;
741 
742  opt_default(NULL, "b:a", "224000");
743  parse_option(o, "ar", "44100", options);
744  parse_option(o, "ac", "2", options);
745 
746  opt_default(NULL, "packetsize", "2324");
747  opt_default(NULL, "muxrate", "1411200"); // 2352 * 75 * 8;
748 
749  /* We have to offset the PTS, so that it is consistent with the SCR.
750  SCR starts at 36000, but the first two packs contain only padding
751  and the first pack from the other stream, respectively, may also have
752  been written before.
753  So the real data starts at SCR 36000+3*1200. */
754  o->mux_preload = (36000 + 3 * 1200) / 90000.0; // 0.44
755  } else if (!strcmp(arg, "svcd")) {
756 
757  opt_video_codec(o, "c:v", "mpeg2video");
758  opt_audio_codec(o, "c:a", "mp2");
759  parse_option(o, "f", "svcd", options);
760 
761  parse_option(o, "s", norm == PAL ? "480x576" : "480x480", options);
762  parse_option(o, "r", frame_rates[norm], options);
763  parse_option(o, "pix_fmt", "yuv420p", options);
764  opt_default(NULL, "g", norm == PAL ? "15" : "18");
765 
766  opt_default(NULL, "b:v", "2040000");
767  opt_default(NULL, "maxrate:v", "2516000");
768  opt_default(NULL, "minrate:v", "0"); // 1145000;
769  opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;
770  opt_default(NULL, "scan_offset", "1");
771 
772  opt_default(NULL, "b:a", "224000");
773  parse_option(o, "ar", "44100", options);
774 
775  opt_default(NULL, "packetsize", "2324");
776 
777  } else if (!strcmp(arg, "dvd")) {
778 
779  opt_video_codec(o, "c:v", "mpeg2video");
780  opt_audio_codec(o, "c:a", "ac3");
781  parse_option(o, "f", "dvd", options);
782 
783  parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
784  parse_option(o, "r", frame_rates[norm], options);
785  parse_option(o, "pix_fmt", "yuv420p", options);
786  opt_default(NULL, "g", norm == PAL ? "15" : "18");
787 
788  opt_default(NULL, "b:v", "6000000");
789  opt_default(NULL, "maxrate:v", "9000000");
790  opt_default(NULL, "minrate:v", "0"); // 1500000;
791  opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;
792 
793  opt_default(NULL, "packetsize", "2048"); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
794  opt_default(NULL, "muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8
795 
796  opt_default(NULL, "b:a", "448000");
797  parse_option(o, "ar", "48000", options);
798 
799  } else if (!strncmp(arg, "dv", 2)) {
800 
801  parse_option(o, "f", "dv", options);
802 
803  parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
804  parse_option(o, "pix_fmt", !strncmp(arg, "dv50", 4) ? "yuv422p" :
805  norm == PAL ? "yuv420p" : "yuv411p", options);
806  parse_option(o, "r", frame_rates[norm], options);
807 
808  parse_option(o, "ar", "48000", options);
809  parse_option(o, "ac", "2", options);
810 
811  } else {
812  av_log(NULL, AV_LOG_ERROR, "Unknown target: %s\n", arg);
813  return AVERROR(EINVAL);
814  }
815 
818 
819  return 0;
820 }
821 
822 static int opt_vstats_file(void *optctx, const char *opt, const char *arg)
823 {
826  return 0;
827 }
828 
829 static int opt_vstats(void *optctx, const char *opt, const char *arg)
830 {
831  char filename[40];
832  time_t today2 = time(NULL);
833  struct tm *today = localtime(&today2);
834 
835  if (!today) { // maybe tomorrow
836  av_log(NULL, AV_LOG_FATAL, "Unable to get current time: %s\n", strerror(errno));
837  return AVERROR(errno);
838  }
839 
840  snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
841  today->tm_sec);
842  return opt_vstats_file(NULL, opt, filename);
843 }
844 
845 static int opt_video_frames(void *optctx, const char *opt, const char *arg)
846 {
847  OptionsContext *o = optctx;
848  return parse_option(o, "frames:v", arg, options);
849 }
850 
851 static int opt_audio_frames(void *optctx, const char *opt, const char *arg)
852 {
853  OptionsContext *o = optctx;
854  return parse_option(o, "frames:a", arg, options);
855 }
856 
857 static int opt_data_frames(void *optctx, const char *opt, const char *arg)
858 {
859  OptionsContext *o = optctx;
860  return parse_option(o, "frames:d", arg, options);
861 }
862 
863 static int opt_default_new(OptionsContext *o, const char *opt, const char *arg)
864 {
865  int ret;
866  AVDictionary *cbak = codec_opts;
867  AVDictionary *fbak = format_opts;
868  codec_opts = NULL;
869  format_opts = NULL;
870 
871  ret = opt_default(NULL, opt, arg);
872 
873  av_dict_copy(&o->g->codec_opts , codec_opts, 0);
877  codec_opts = cbak;
878  format_opts = fbak;
879 
880  return ret;
881 }
882 
883 static int opt_preset(void *optctx, const char *opt, const char *arg)
884 {
885  OptionsContext *o = optctx;
886  FILE *f=NULL;
887  char filename[1000], line[1000], tmp_line[1000];
888  const char *codec_name = NULL;
889  int ret = 0;
890 
891  codec_name = opt_match_per_type_str(&o->codec_names, *opt);
892 
893  if (!(f = get_preset_file(filename, sizeof(filename), arg, *opt == 'f', codec_name))) {
894  if(!strncmp(arg, "libx264-lossless", strlen("libx264-lossless"))){
895  av_log(NULL, AV_LOG_FATAL, "Please use -preset <speed> -qp 0\n");
896  }else
897  av_log(NULL, AV_LOG_FATAL, "File for preset '%s' not found\n", arg);
898  return AVERROR(ENOENT);
899  }
900 
901  while (fgets(line, sizeof(line), f)) {
902  char *key = tmp_line, *value, *endptr;
903 
904  if (strcspn(line, "#\n\r") == 0)
905  continue;
906  av_strlcpy(tmp_line, line, sizeof(tmp_line));
907  if (!av_strtok(key, "=", &value) ||
908  !av_strtok(value, "\r\n", &endptr)) {
909  av_log(NULL, AV_LOG_FATAL, "%s: Invalid syntax: '%s'\n", filename, line);
910  ret = AVERROR(EINVAL);
911  goto fail;
912  }
913  av_log(NULL, AV_LOG_DEBUG, "ffpreset[%s]: set '%s' = '%s'\n", filename, key, value);
914 
915  if (!strcmp(key, "acodec")) opt_audio_codec (o, key, value);
916  else if (!strcmp(key, "vcodec")) opt_video_codec (o, key, value);
917  else if (!strcmp(key, "scodec")) opt_subtitle_codec(o, key, value);
918  else if (!strcmp(key, "dcodec")) opt_data_codec (o, key, value);
919  else if (opt_default_new(o, key, value) < 0) {
920  av_log(NULL, AV_LOG_FATAL, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n",
921  filename, line, key, value);
922  ret = AVERROR(EINVAL);
923  goto fail;
924  }
925  }
926 
927 fail:
928  fclose(f);
929 
930  return ret;
931 }
932 
933 static int opt_old2new(void *optctx, const char *opt, const char *arg)
934 {
935  OptionsContext *o = optctx;
936  int ret;
937  char *s = av_asprintf("%s:%c", opt + 1, *opt);
938  if (!s)
939  return AVERROR(ENOMEM);
940  ret = parse_option(o, s, arg, options);
941  av_free(s);
942  return ret;
943 }
944 
945 static int opt_bitrate(void *optctx, const char *opt, const char *arg)
946 {
947  OptionsContext *o = optctx;
948 
949  if(!strcmp(opt, "ab")){
950  av_dict_set(&o->g->codec_opts, "b:a", arg, 0);
951  return 0;
952  } else if(!strcmp(opt, "b")){
953  av_log(NULL, AV_LOG_WARNING, "Please use -b:a or -b:v, -b is ambiguous\n");
954  av_dict_set(&o->g->codec_opts, "b:v", arg, 0);
955  return 0;
956  }
957  av_dict_set(&o->g->codec_opts, opt, arg, 0);
958  return 0;
959 }
960 
961 static int opt_qscale(void *optctx, const char *opt, const char *arg)
962 {
963  OptionsContext *o = optctx;
964  char *s;
965  int ret;
966  if(!strcmp(opt, "qscale")){
967  av_log(NULL, AV_LOG_WARNING, "Please use -q:a or -q:v, -qscale is ambiguous\n");
968  return parse_option(o, "q:v", arg, options);
969  }
970  s = av_asprintf("q%s", opt + 6);
971  if (!s)
972  return AVERROR(ENOMEM);
973  ret = parse_option(o, s, arg, options);
974  av_free(s);
975  return ret;
976 }
977 
978 static int opt_profile(void *optctx, const char *opt, const char *arg)
979 {
980  OptionsContext *o = optctx;
981  if(!strcmp(opt, "profile")){
982  av_log(NULL, AV_LOG_WARNING, "Please use -profile:a or -profile:v, -profile is ambiguous\n");
983  av_dict_set(&o->g->codec_opts, "profile:v", arg, 0);
984  return 0;
985  }
986  av_dict_set(&o->g->codec_opts, opt, arg, 0);
987  return 0;
988 }
989 
990 static int opt_video_filters(void *optctx, const char *opt, const char *arg)
991 {
992  OptionsContext *o = optctx;
993  return parse_option(o, "filter:v", arg, options);
994 }
995 
996 static int opt_audio_filters(void *optctx, const char *opt, const char *arg)
997 {
998  OptionsContext *o = optctx;
999  return parse_option(o, "filter:a", arg, options);
1000 }
1001 
1002 #if FFMPEG_OPT_VSYNC
1003 static int opt_vsync(void *optctx, const char *opt, const char *arg)
1004 {
1005  av_log(NULL, AV_LOG_WARNING, "-vsync is deprecated. Use -fps_mode\n");
1006  return parse_and_set_vsync(arg, &video_sync_method, -1, -1, 1);
1007 }
1008 #endif
1009 
1010 static int opt_timecode(void *optctx, const char *opt, const char *arg)
1011 {
1012  OptionsContext *o = optctx;
1013  int ret;
1014  char *tcr = av_asprintf("timecode=%s", arg);
1015  if (!tcr)
1016  return AVERROR(ENOMEM);
1017  ret = parse_option(o, "metadata:g", tcr, options);
1018  if (ret >= 0)
1019  ret = av_dict_set(&o->g->codec_opts, "gop_timecode", arg, 0);
1020  av_free(tcr);
1021  return ret;
1022 }
1023 
1024 static int opt_audio_qscale(void *optctx, const char *opt, const char *arg)
1025 {
1026  OptionsContext *o = optctx;
1027  return parse_option(o, "q:a", arg, options);
1028 }
1029 
1030 static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
1031 {
1032  Scheduler *sch = optctx;
1033  char *graph_desc = av_strdup(arg);
1034  if (!graph_desc)
1035  return AVERROR(ENOMEM);
1036 
1037  return fg_create(NULL, graph_desc, sch);
1038 }
1039 
1040 #if FFMPEG_OPT_FILTER_SCRIPT
1041 static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
1042 {
1043  Scheduler *sch = optctx;
1044  char *graph_desc = file_read(arg);
1045  if (!graph_desc)
1046  return AVERROR(EINVAL);
1047 
1048  av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -/filter_complex %s instead\n",
1049  opt, arg);
1050 
1051  return fg_create(NULL, graph_desc, sch);
1052 }
1053 #endif
1054 
1055 void show_help_default(const char *opt, const char *arg)
1056 {
1057  int show_advanced = 0, show_avoptions = 0;
1058 
1059  if (opt && *opt) {
1060  if (!strcmp(opt, "long"))
1061  show_advanced = 1;
1062  else if (!strcmp(opt, "full"))
1063  show_advanced = show_avoptions = 1;
1064  else
1065  av_log(NULL, AV_LOG_ERROR, "Unknown help option '%s'.\n", opt);
1066  }
1067 
1068  show_usage();
1069 
1070  printf("Getting help:\n"
1071  " -h -- print basic options\n"
1072  " -h long -- print more options\n"
1073  " -h full -- print all options (including all format and codec specific options, very long)\n"
1074  " -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf/protocol\n"
1075  " See man %s for detailed description of the options.\n"
1076  "\n"
1077  "Per-stream options can be followed by :<stream_spec> to apply that option to specific streams only. "
1078  "<stream_spec> can be a stream index, or v/a/s for video/audio/subtitle (see manual for full syntax).\n"
1079  "\n", program_name);
1080 
1081  show_help_options(options, "Print help / information / capabilities:",
1082  OPT_EXIT, OPT_EXPERT);
1083  if (show_advanced)
1084  show_help_options(options, "Advanced information / capabilities:",
1085  OPT_EXIT | OPT_EXPERT, 0);
1086 
1087  show_help_options(options, "Global options (affect whole program "
1088  "instead of just one file):",
1090  if (show_advanced)
1091  show_help_options(options, "Advanced global options:", OPT_EXPERT,
1092  OPT_PERFILE | OPT_EXIT);
1093 
1094  show_help_options(options, "Per-file options (input and output):",
1098  if (show_advanced)
1099  show_help_options(options, "Advanced per-file options (input and output):",
1103 
1104  show_help_options(options, "Per-file options (input-only):",
1108  if (show_advanced)
1109  show_help_options(options, "Advanced per-file options (input-only):",
1113 
1114  show_help_options(options, "Per-file options (output-only):",
1118  if (show_advanced)
1119  show_help_options(options, "Advanced per-file options (output-only):",
1123 
1124  show_help_options(options, "Per-stream options:",
1126  OPT_EXIT | OPT_EXPERT |
1128  if (show_advanced)
1129  show_help_options(options, "Advanced per-stream options:",
1131  OPT_EXIT |
1133 
1134  show_help_options(options, "Video options:",
1136  if (show_advanced)
1137  show_help_options(options, "Advanced Video options:",
1139 
1140  show_help_options(options, "Audio options:",
1142  if (show_advanced)
1143  show_help_options(options, "Advanced Audio options:",
1145 
1146  show_help_options(options, "Subtitle options:",
1148  if (show_advanced)
1149  show_help_options(options, "Advanced Subtitle options:",
1151 
1152  if (show_advanced)
1153  show_help_options(options, "Data stream options:",
1155  printf("\n");
1156 
1157  if (show_avoptions) {
1161 #if CONFIG_SWSCALE
1163 #endif
1164 #if CONFIG_SWRESAMPLE
1166 #endif
1169  }
1170 }
1171 
1172 void show_usage(void)
1173 {
1174  av_log(NULL, AV_LOG_INFO, "Universal media converter\n");
1175  av_log(NULL, AV_LOG_INFO, "usage: %s [options] [[infile options] -i infile]... {[outfile options] outfile}...\n", program_name);
1176  av_log(NULL, AV_LOG_INFO, "\n");
1177 }
1178 
1179 enum OptGroup {
1180  GROUP_OUTFILE,
1181  GROUP_INFILE,
1182  GROUP_DECODER,
1183 };
1184 
1185 static const OptionGroupDef groups[] = {
1186  [GROUP_OUTFILE] = { "output url", NULL, OPT_OUTPUT },
1187  [GROUP_INFILE] = { "input url", "i", OPT_INPUT },
1188  [GROUP_DECODER] = { "loopback decoder", "dec", OPT_DECODER },
1189 };
1190 
1191 static int open_files(OptionGroupList *l, const char *inout, Scheduler *sch,
1192  int (*open_file)(const OptionsContext*, const char*,
1193  Scheduler*))
1194 {
1195  int i, ret;
1196 
1197  for (i = 0; i < l->nb_groups; i++) {
1198  OptionGroup *g = &l->groups[i];
1199  OptionsContext o;
1200 
1201  init_options(&o);
1202  o.g = g;
1203 
1204  ret = parse_optgroup(&o, g, options);
1205  if (ret < 0) {
1206  av_log(NULL, AV_LOG_ERROR, "Error parsing options for %s file "
1207  "%s.\n", inout, g->arg);
1208  uninit_options(&o);
1209  return ret;
1210  }
1211 
1212  av_log(NULL, AV_LOG_DEBUG, "Opening an %s file: %s.\n", inout, g->arg);
1213  ret = open_file(&o, g->arg, sch);
1214  uninit_options(&o);
1215  if (ret < 0) {
1216  av_log(NULL, AV_LOG_ERROR, "Error opening %s file %s.\n",
1217  inout, g->arg);
1218  return ret;
1219  }
1220  av_log(NULL, AV_LOG_DEBUG, "Successfully opened the file.\n");
1221  }
1222 
1223  return 0;
1224 }
1225 
1226 int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
1227 {
1228  OptionParseContext octx;
1229  const char *errmsg = NULL;
1230  int ret;
1231 
1232  memset(&octx, 0, sizeof(octx));
1233 
1234  /* split the commandline into an internal representation */
1235  ret = split_commandline(&octx, argc, argv, options, groups,
1236  FF_ARRAY_ELEMS(groups));
1237  if (ret < 0) {
1238  errmsg = "splitting the argument list";
1239  goto fail;
1240  }
1241 
1242  /* apply global options */
1243  ret = parse_optgroup(sch, &octx.global_opts, options);
1244  if (ret < 0) {
1245  errmsg = "parsing global options";
1246  goto fail;
1247  }
1248 
1249  /* configure terminal and setup signal handlers */
1250  term_init();
1251 
1252  /* open input files */
1253  ret = open_files(&octx.groups[GROUP_INFILE], "input", sch, ifile_open);
1254  if (ret < 0) {
1255  errmsg = "opening input files";
1256  goto fail;
1257  }
1258 
1259  /* open output files */
1260  ret = open_files(&octx.groups[GROUP_OUTFILE], "output", sch, of_open);
1261  if (ret < 0) {
1262  errmsg = "opening output files";
1263  goto fail;
1264  }
1265 
1266  /* create loopback decoders */
1267  ret = open_files(&octx.groups[GROUP_DECODER], "decoder", sch, dec_create);
1268  if (ret < 0) {
1269  errmsg = "creating loopback decoders";
1270  goto fail;
1271  }
1272 
1273  // bind unbound filtegraph inputs/outputs and check consistency
1274  for (int i = 0; i < nb_filtergraphs; i++) {
1276  if (ret < 0) {
1277  errmsg = "binding filtergraph inputs/outputs";
1278  goto fail;
1279  }
1280  }
1281 
1283 
1284  ret = apply_sync_offsets();
1285  if (ret < 0)
1286  goto fail;
1287 
1288 fail:
1289  uninit_parse_context(&octx);
1290  if (ret < 0 && ret != AVERROR_EXIT) {
1291  av_log(NULL, AV_LOG_FATAL, "Error %s: %s\n",
1292  errmsg ? errmsg : "", av_err2str(ret));
1293  }
1294  return ret;
1295 }
1296 
1297 static int opt_progress(void *optctx, const char *opt, const char *arg)
1298 {
1299  AVIOContext *avio = NULL;
1300  int ret;
1301 
1302  if (!strcmp(arg, "-"))
1303  arg = "pipe:";
1304  ret = avio_open2(&avio, arg, AVIO_FLAG_WRITE, &int_cb, NULL);
1305  if (ret < 0) {
1306  av_log(NULL, AV_LOG_ERROR, "Failed to open progress URL \"%s\": %s\n",
1307  arg, av_err2str(ret));
1308  return ret;
1309  }
1310  progress_avio = avio;
1311  return 0;
1312 }
1313 
1314 int opt_timelimit(void *optctx, const char *opt, const char *arg)
1315 {
1316 #if HAVE_SETRLIMIT
1317  int ret;
1318  double lim;
1319  struct rlimit rl;
1320 
1321  ret = parse_number(opt, arg, OPT_TYPE_INT64, 0, INT_MAX, &lim);
1322  if (ret < 0)
1323  return ret;
1324 
1325  rl = (struct rlimit){ lim, lim + 1 };
1326  if (setrlimit(RLIMIT_CPU, &rl))
1327  perror("setrlimit");
1328 #else
1329  av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
1330 #endif
1331  return 0;
1332 }
1333 
1334 #if FFMPEG_OPT_QPHIST
1335 static int opt_qphist(void *optctx, const char *opt, const char *arg)
1336 {
1337  av_log(NULL, AV_LOG_WARNING, "Option -%s is deprecated and has no effect\n", opt);
1338  return 0;
1339 }
1340 #endif
1341 
1342 #if FFMPEG_OPT_ADRIFT_THRESHOLD
1343 static int opt_adrift_threshold(void *optctx, const char *opt, const char *arg)
1344 {
1345  av_log(NULL, AV_LOG_WARNING, "Option -%s is deprecated and has no effect\n", opt);
1346  return 0;
1347 }
1348 #endif
1349 
1350 static const char *const alt_bsf[] = { "absf", "vbsf", NULL };
1351 static const char *const alt_channel_layout[] = { "ch_layout", NULL};
1352 static const char *const alt_codec[] = { "c", "acodec", "vcodec", "scodec", "dcodec", NULL };
1353 static const char *const alt_filter[] = { "af", "vf", NULL };
1354 static const char *const alt_frames[] = { "aframes", "vframes", "dframes", NULL };
1355 static const char *const alt_pre[] = { "apre", "vpre", "spre", NULL};
1356 static const char *const alt_qscale[] = { "q", NULL};
1357 static const char *const alt_tag[] = { "atag", "vtag", "stag", NULL };
1358 
1359 #define OFFSET(x) offsetof(OptionsContext, x)
1360 const OptionDef options[] = {
1361  /* main options */
1364  { .off = OFFSET(format) },
1365  "force container format (auto-detected otherwise)", "fmt" },
1366  { "y", OPT_TYPE_BOOL, 0,
1367  { &file_overwrite },
1368  "overwrite output files" },
1369  { "n", OPT_TYPE_BOOL, 0,
1370  { &no_file_overwrite },
1371  "never overwrite output files" },
1372  { "ignore_unknown", OPT_TYPE_BOOL, OPT_EXPERT,
1374  "Ignore unknown stream types" },
1375  { "copy_unknown", OPT_TYPE_BOOL, OPT_EXPERT,
1376  { &copy_unknown_streams },
1377  "Copy unknown stream types" },
1378  { "recast_media", OPT_TYPE_BOOL, OPT_EXPERT,
1379  { &recast_media },
1380  "allow recasting stream type in order to force a decoder of different media type" },
1382  { .off = OFFSET(codec_names) },
1383  "select encoder/decoder ('copy' to copy stream without reencoding)", "codec",
1384  .u1.name_canon = "codec", },
1386  { .off = OFFSET(codec_names) },
1387  "alias for -c (select encoder/decoder)", "codec",
1388  .u1.names_alt = alt_codec, },
1390  { .off = OFFSET(presets) },
1391  "preset name", "preset",
1392  .u1.names_alt = alt_pre, },
1394  { .func_arg = opt_map },
1395  "set input stream mapping",
1396  "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
1397  { "map_metadata", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | OPT_EXPERT,
1398  { .off = OFFSET(metadata_map) },
1399  "set metadata information of outfile from infile",
1400  "outfile[,metadata]:infile[,metadata]" },
1401  { "map_chapters", OPT_TYPE_INT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
1402  { .off = OFFSET(chapters_input_file) },
1403  "set chapters mapping", "input_file_index" },
1405  { .off = OFFSET(recording_time) },
1406  "stop transcoding after specified duration",
1407  "duration" },
1409  { .off = OFFSET(stop_time) },
1410  "stop transcoding after specified time is reached",
1411  "time_stop" },
1413  { .off = OFFSET(limit_filesize) },
1414  "set the limit file size in bytes", "limit_size" },
1416  { .off = OFFSET(start_time) },
1417  "start transcoding at specified time", "time_off" },
1418  { "sseof", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_EXPERT,
1419  { .off = OFFSET(start_time_eof) },
1420  "set the start time offset relative to EOF", "time_off" },
1421  { "seek_timestamp", OPT_TYPE_INT, OPT_OFFSET | OPT_INPUT | OPT_EXPERT,
1422  { .off = OFFSET(seek_timestamp) },
1423  "enable/disable seeking by timestamp with -ss" },
1424  { "accurate_seek", OPT_TYPE_BOOL, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1425  { .off = OFFSET(accurate_seek) },
1426  "enable/disable accurate seeking with -ss" },
1427  { "isync", OPT_TYPE_INT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1428  { .off = OFFSET(input_sync_ref) },
1429  "Indicate the input index for sync reference", "sync ref" },
1430  { "itsoffset", OPT_TYPE_TIME, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1431  { .off = OFFSET(input_ts_offset) },
1432  "set the input ts offset", "time_off" },
1434  { .off = OFFSET(ts_scale) },
1435  "set the input ts scale", "scale" },
1437  { .func_arg = opt_recording_timestamp },
1438  "set the recording timestamp ('now' to set the current time)", "time" },
1439  { "metadata", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
1440  { .off = OFFSET(metadata) },
1441  "add metadata", "key=value" },
1442  { "program", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
1443  { .off = OFFSET(program) },
1444  "add program with specified streams", "title=string:st=number..." },
1445  { "stream_group", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | OPT_EXPERT,
1446  { .off = OFFSET(stream_groups) },
1447  "add stream group with specified streams and group type-specific arguments", "id=number:st=number..." },
1449  { .func_arg = opt_data_frames },
1450  "set the number of data frames to output", "number",
1451  .u1.name_canon = "frames" },
1452  { "benchmark", OPT_TYPE_BOOL, OPT_EXPERT,
1453  { &do_benchmark },
1454  "add timings for benchmarking" },
1455  { "benchmark_all", OPT_TYPE_BOOL, OPT_EXPERT,
1456  { &do_benchmark_all },
1457  "add timings for each task" },
1458  { "progress", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1459  { .func_arg = opt_progress },
1460  "write program-readable progress information", "url" },
1461  { "stdin", OPT_TYPE_BOOL, OPT_EXPERT,
1462  { &stdin_interaction },
1463  "enable or disable interaction on standard input" },
1464  { "timelimit", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1465  { .func_arg = opt_timelimit },
1466  "set max runtime in seconds in CPU user time", "limit" },
1467  { "dump", OPT_TYPE_BOOL, OPT_EXPERT,
1468  { &do_pkt_dump },
1469  "dump each input packet" },
1470  { "hex", OPT_TYPE_BOOL, OPT_EXPERT,
1471  { &do_hex_dump },
1472  "when dumping packets, also dump the payload" },
1474  { .off = OFFSET(rate_emu) },
1475  "read input at native frame rate; equivalent to -readrate 1", "" },
1476  { "readrate", OPT_TYPE_FLOAT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1477  { .off = OFFSET(readrate) },
1478  "read input at specified rate", "speed" },
1479  { "readrate_initial_burst", OPT_TYPE_DOUBLE, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1480  { .off = OFFSET(readrate_initial_burst) },
1481  "The initial amount of input to burst read before imposing any readrate", "seconds" },
1483  { .func_arg = opt_target },
1484  "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\" or \"dv50\" "
1485  "with optional prefixes \"pal-\", \"ntsc-\" or \"film-\")", "type" },
1486  { "frame_drop_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
1487  { &frame_drop_threshold },
1488  "frame drop threshold", "" },
1489  { "copyts", OPT_TYPE_BOOL, OPT_EXPERT,
1490  { &copy_ts },
1491  "copy timestamps" },
1492  { "start_at_zero", OPT_TYPE_BOOL, OPT_EXPERT,
1493  { &start_at_zero },
1494  "shift input timestamps to start at 0 when using copyts" },
1495  { "copytb", OPT_TYPE_INT, OPT_EXPERT,
1496  { &copy_tb },
1497  "copy input stream time base when stream copying", "mode" },
1498  { "shortest", OPT_TYPE_BOOL, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
1499  { .off = OFFSET(shortest) },
1500  "finish encoding within shortest input" },
1501  { "shortest_buf_duration", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
1502  { .off = OFFSET(shortest_buf_duration) },
1503  "maximum buffering duration (in seconds) for the -shortest option" },
1505  { .off = OFFSET(bitexact) },
1506  "bitexact mode" },
1508  { .off = OFFSET(apad) },
1509  "audio pad", "" },
1510  { "dts_delta_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
1511  { &dts_delta_threshold },
1512  "timestamp discontinuity delta threshold", "threshold" },
1513  { "dts_error_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
1514  { &dts_error_threshold },
1515  "timestamp error delta threshold", "threshold" },
1516  { "xerror", OPT_TYPE_BOOL, OPT_EXPERT,
1517  { &exit_on_error },
1518  "exit on error", "error" },
1519  { "abort_on", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1520  { .func_arg = opt_abort_on },
1521  "abort on the specified condition flags", "flags" },
1522  { "copyinkf", OPT_TYPE_BOOL, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1523  { .off = OFFSET(copy_initial_nonkeyframes) },
1524  "copy initial non-keyframes" },
1525  { "copypriorss", OPT_TYPE_INT, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1526  { .off = OFFSET(copy_prior_start) },
1527  "copy or discard frames before start time" },
1529  { .off = OFFSET(max_frames) },
1530  "set the number of frames to output", "number",
1531  .u1.names_alt = alt_frames, },
1533  { .off = OFFSET(codec_tags) },
1534  "force codec tag/fourcc", "fourcc/tag",
1535  .u1.names_alt = alt_tag, },
1537  { .off = OFFSET(qscale) },
1538  "use fixed quality scale (VBR)", "q",
1539  .u1.name_canon = "qscale", },
1541  { .func_arg = opt_qscale },
1542  "use fixed quality scale (VBR)", "q",
1543  .u1.names_alt = alt_qscale, },
1545  { .func_arg = opt_profile },
1546  "set profile", "profile" },
1548  { .off = OFFSET(filters) },
1549  "apply specified filters to audio/video", "filter_graph",
1550  .u1.names_alt = alt_filter, },
1551  { "filter_threads", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1552  { .func_arg = opt_filter_threads },
1553  "number of non-complex filter threads" },
1554 #if FFMPEG_OPT_FILTER_SCRIPT
1555  { "filter_script", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1556  { .off = OFFSET(filter_scripts) },
1557  "deprecated, use -/filter", "filename" },
1558 #endif
1559  { "reinit_filter", OPT_TYPE_INT, OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1560  { .off = OFFSET(reinit_filters) },
1561  "reinit filtergraph on input parameter changes", "" },
1562  { "filter_complex", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1563  { .func_arg = opt_filter_complex },
1564  "create a complex filtergraph", "graph_description" },
1565  { "filter_complex_threads", OPT_TYPE_INT, OPT_EXPERT,
1567  "number of threads for -filter_complex" },
1568  { "lavfi", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1569  { .func_arg = opt_filter_complex },
1570  "create a complex filtergraph", "graph_description" },
1571 #if FFMPEG_OPT_FILTER_SCRIPT
1572  { "filter_complex_script", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1573  { .func_arg = opt_filter_complex_script },
1574  "deprecated, use -/filter_complex instead", "filename" },
1575 #endif
1576  { "auto_conversion_filters", OPT_TYPE_BOOL, OPT_EXPERT,
1578  "enable automatic conversion filters globally" },
1579  { "stats", OPT_TYPE_BOOL, 0,
1580  { &print_stats },
1581  "print progress report during encoding", },
1582  { "stats_period", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1583  { .func_arg = opt_stats_period },
1584  "set the period at which ffmpeg updates stats and -progress output", "time" },
1586  { .func_arg = opt_attach },
1587  "add an attachment to the output file", "filename" },
1588  { "dump_attachment", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_INPUT,
1589  { .off = OFFSET(dump_attachment) },
1590  "extract an attachment into a file", "filename" },
1591  { "stream_loop", OPT_TYPE_INT, OPT_EXPERT | OPT_INPUT | OPT_OFFSET,
1592  { .off = OFFSET(loop) }, "set number of times input stream shall be looped", "loop count" },
1593  { "debug_ts", OPT_TYPE_BOOL, OPT_EXPERT,
1594  { &debug_ts },
1595  "print timestamp debugging info" },
1596  { "max_error_rate", OPT_TYPE_FLOAT, OPT_EXPERT,
1597  { &max_error_rate },
1598  "ratio of decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.", "maximum error rate" },
1600  { .off = OFFSET(discard) },
1601  "discard", "" },
1602  { "disposition", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_OUTPUT | OPT_EXPERT,
1603  { .off = OFFSET(disposition) },
1604  "disposition", "" },
1605  { "thread_queue_size", OPT_TYPE_INT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT,
1606  { .off = OFFSET(thread_queue_size) },
1607  "set the maximum number of queued packets from the demuxer" },
1608  { "find_stream_info", OPT_TYPE_BOOL, OPT_INPUT | OPT_EXPERT | OPT_OFFSET,
1609  { .off = OFFSET(find_stream_info) },
1610  "read and decode the streams to fill missing information with heuristics" },
1611  { "bits_per_raw_sample", OPT_TYPE_INT, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1612  { .off = OFFSET(bits_per_raw_sample) },
1613  "set the number of bits per raw sample", "number" },
1614 
1615  { "stats_enc_pre", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1616  { .off = OFFSET(enc_stats_pre) },
1617  "write encoding stats before encoding" },
1618  { "stats_enc_post", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1619  { .off = OFFSET(enc_stats_post) },
1620  "write encoding stats after encoding" },
1621  { "stats_mux_pre", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1622  { .off = OFFSET(mux_stats) },
1623  "write packets stats before muxing" },
1624  { "stats_enc_pre_fmt", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1625  { .off = OFFSET(enc_stats_pre_fmt) },
1626  "format of the stats written with -stats_enc_pre" },
1627  { "stats_enc_post_fmt", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1628  { .off = OFFSET(enc_stats_post_fmt) },
1629  "format of the stats written with -stats_enc_post" },
1630  { "stats_mux_pre_fmt", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1631  { .off = OFFSET(mux_stats_fmt) },
1632  "format of the stats written with -stats_mux_pre" },
1633 
1634  /* video options */
1636  { .func_arg = opt_video_frames },
1637  "set the number of video frames to output", "number",
1638  .u1.name_canon = "frames", },
1640  { .off = OFFSET(frame_rates) },
1641  "override input framerate/convert to given output framerate (Hz value, fraction or abbreviation)", "rate" },
1643  { .off = OFFSET(max_frame_rates) },
1644  "set max frame rate (Hz value, fraction or abbreviation)", "rate" },
1646  { .off = OFFSET(frame_sizes) },
1647  "set frame size (WxH or abbreviation)", "size" },
1649  { .off = OFFSET(frame_aspect_ratios) },
1650  "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
1652  { .off = OFFSET(frame_pix_fmts) },
1653  "set pixel format", "format" },
1654  { "display_rotation", OPT_TYPE_DOUBLE, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1655  { .off = OFFSET(display_rotations) },
1656  "set pure counter-clockwise rotation in degrees for stream(s)",
1657  "angle" },
1658  { "display_hflip", OPT_TYPE_BOOL, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1659  { .off = OFFSET(display_hflips) },
1660  "set display horizontal flip for stream(s) "
1661  "(overrides any display rotation if it is not set)"},
1662  { "display_vflip", OPT_TYPE_BOOL, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1663  { .off = OFFSET(display_vflips) },
1664  "set display vertical flip for stream(s) "
1665  "(overrides any display rotation if it is not set)"},
1667  { .off = OFFSET(video_disable) },
1668  "disable video" },
1670  { .off = OFFSET(rc_overrides) },
1671  "rate control override for specific intervals", "override" },
1673  { .func_arg = opt_video_codec },
1674  "alias for -c:v (select encoder/decoder for video streams)", "codec",
1675  .u1.name_canon = "codec", },
1677  { .func_arg = opt_timecode },
1678  "set initial TimeCode value.", "hh:mm:ss[:;.]ff" },
1680  { .off = OFFSET(pass) },
1681  "select the pass number (1 to 3)", "n" },
1683  { .off = OFFSET(passlogfiles) },
1684  "select two pass log file name prefix", "prefix" },
1685  { "vstats", OPT_TYPE_FUNC, OPT_VIDEO | OPT_EXPERT,
1686  { .func_arg = opt_vstats },
1687  "dump video coding statistics to file" },
1688  { "vstats_file", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT,
1689  { .func_arg = opt_vstats_file },
1690  "dump video coding statistics to file", "file" },
1691  { "vstats_version", OPT_TYPE_INT, OPT_VIDEO | OPT_EXPERT,
1692  { &vstats_version },
1693  "Version of the vstats format to use."},
1695  { .func_arg = opt_video_filters },
1696  "alias for -filter:v (apply filters to video streams)", "filter_graph",
1697  .u1.name_canon = "filter", },
1698  { "intra_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1699  { .off = OFFSET(intra_matrices) },
1700  "specify intra matrix coeffs", "matrix" },
1701  { "inter_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1702  { .off = OFFSET(inter_matrices) },
1703  "specify inter matrix coeffs", "matrix" },
1704  { "chroma_intra_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1705  { .off = OFFSET(chroma_intra_matrices) },
1706  "specify intra matrix coeffs", "matrix" },
1708  { .func_arg = opt_old2new },
1709  "force video tag/fourcc", "fourcc/tag",
1710  .u1.name_canon = "tag", },
1712  { .off = OFFSET(fps_mode) },
1713  "set framerate mode for matching video streams; overrides vsync" },
1715  { .off = OFFSET(force_fps) },
1716  "force the selected framerate, disable the best supported framerate selection" },
1718  { .func_arg = opt_streamid },
1719  "set the value of an outfile streamid", "streamIndex:value" },
1720  { "force_key_frames", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1721  { .off = OFFSET(forced_key_frames) },
1722  "force key frames at specified timestamps", "timestamps" },
1724  { .func_arg = opt_bitrate },
1725  "video bitrate (please use -b:v)", "bitrate" },
1727  { .off = OFFSET(hwaccels) },
1728  "use HW accelerated decoding", "hwaccel name" },
1729  { "hwaccel_device", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT,
1730  { .off = OFFSET(hwaccel_devices) },
1731  "select a device for HW acceleration", "devicename" },
1732  { "hwaccel_output_format", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT,
1733  { .off = OFFSET(hwaccel_output_formats) },
1734  "select output format used with HW accelerated decoding", "format" },
1735  { "hwaccels", OPT_TYPE_FUNC, OPT_EXIT | OPT_EXPERT,
1736  { .func_arg = show_hwaccels },
1737  "show available HW acceleration methods" },
1738  { "autorotate", OPT_TYPE_BOOL, OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
1739  { .off = OFFSET(autorotate) },
1740  "automatically insert correct rotate filters" },
1741  { "autoscale", OPT_TYPE_BOOL, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1742  { .off = OFFSET(autoscale) },
1743  "automatically insert a scale filter at the end of the filter graph" },
1744  { "fix_sub_duration_heartbeat", OPT_TYPE_BOOL, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1745  { .off = OFFSET(fix_sub_duration_heartbeat) },
1746  "set this video output stream to be a heartbeat stream for "
1747  "fix_sub_duration, according to which subtitles should be split at "
1748  "random access points" },
1749 
1750  /* audio options */
1752  { .func_arg = opt_audio_frames },
1753  "set the number of audio frames to output", "number",
1754  .u1.name_canon = "frames", },
1756  { .func_arg = opt_audio_qscale },
1757  "set audio quality (codec-specific)", "quality", },
1759  { .off = OFFSET(audio_sample_rate) },
1760  "set audio sampling rate (in Hz)", "rate" },
1762  { .off = OFFSET(audio_channels) },
1763  "set number of audio channels", "channels" },
1765  { .off = OFFSET(audio_disable) },
1766  "disable audio" },
1768  { .func_arg = opt_audio_codec },
1769  "alias for -c:a (select encoder/decoder for audio streams)", "codec",
1770  .u1.name_canon = "codec", },
1772  { .func_arg = opt_bitrate },
1773  "alias for -b:a (select bitrate for audio streams)", "bitrate" },
1775  { .func_arg = opt_old2new },
1776  "force audio tag/fourcc", "fourcc/tag",
1777  .u1.name_canon = "tag", },
1779  { .off = OFFSET(sample_fmts) },
1780  "set sample format", "format" },
1782  { .off = OFFSET(audio_ch_layouts) },
1783  "set channel layout", "layout",
1784  .u1.names_alt = alt_channel_layout, },
1786  { .off = OFFSET(audio_ch_layouts) },
1787  "set channel layout", "layout",
1788  .u1.name_canon = "channel_layout", },
1790  { .func_arg = opt_audio_filters },
1791  "alias for -filter:a (apply filters to audio streams)", "filter_graph",
1792  .u1.name_canon = "filter", },
1793  { "guess_layout_max", OPT_TYPE_INT, OPT_AUDIO | OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
1794  { .off = OFFSET(guess_layout_max) },
1795  "set the maximum number of channels to try to guess the channel layout" },
1796 
1797  /* subtitle options */
1799  { .off = OFFSET(subtitle_disable) },
1800  "disable subtitle" },
1802  { .func_arg = opt_subtitle_codec },
1803  "alias for -c:s (select encoder/decoder for subtitle streams)", "codec",
1804  .u1.name_canon = "codec", },
1806  { .func_arg = opt_old2new }
1807  , "force subtitle tag/fourcc", "fourcc/tag",
1808  .u1.name_canon = "tag" },
1809  { "fix_sub_duration", OPT_TYPE_BOOL, OPT_EXPERT | OPT_SUBTITLE | OPT_PERSTREAM | OPT_INPUT,
1810  { .off = OFFSET(fix_sub_duration) },
1811  "fix subtitles duration" },
1813  { .off = OFFSET(canvas_sizes) },
1814  "set canvas size (WxH or abbreviation)", "size" },
1815 
1816  /* muxer options */
1817  { "muxdelay", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
1818  { .off = OFFSET(mux_max_delay) },
1819  "set the maximum demux-decode delay", "seconds" },
1820  { "muxpreload", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
1821  { .off = OFFSET(mux_preload) },
1822  "set the initial demux-decode delay", "seconds" },
1823  { "sdp_file", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_OUTPUT,
1824  { .func_arg = opt_sdp_file },
1825  "specify a file in which to print sdp information", "file" },
1826 
1827  { "time_base", OPT_TYPE_STRING, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1828  { .off = OFFSET(time_bases) },
1829  "set the desired time base hint for output stream (1:24, 1:48000 or 0.04166, 2.0833e-5)", "ratio" },
1830  { "enc_time_base", OPT_TYPE_STRING, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1831  { .off = OFFSET(enc_time_bases) },
1832  "set the desired time base for the encoder (1:24, 1:48000 or 0.04166, 2.0833e-5). "
1833  "two special values are defined - "
1834  "0 = use frame rate (video) or sample rate (audio),"
1835  "-1 = match source time base", "ratio" },
1836 
1838  { .off = OFFSET(bitstream_filters) },
1839  "A comma-separated list of bitstream filters", "bitstream_filters", },
1840 
1842  { .func_arg = opt_preset },
1843  "set the audio options to the indicated preset", "preset",
1844  .u1.name_canon = "pre", },
1846  { .func_arg = opt_preset },
1847  "set the video options to the indicated preset", "preset",
1848  .u1.name_canon = "pre", },
1850  { .func_arg = opt_preset },
1851  "set the subtitle options to the indicated preset", "preset",
1852  .u1.name_canon = "pre", },
1854  { .func_arg = opt_preset },
1855  "set options from indicated preset file", "filename",
1856  .u1.name_canon = "pre", },
1857 
1858  { "max_muxing_queue_size", OPT_TYPE_INT, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1859  { .off = OFFSET(max_muxing_queue_size) },
1860  "maximum number of packets that can be buffered while waiting for all streams to initialize", "packets" },
1861  { "muxing_queue_data_threshold", OPT_TYPE_INT, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1862  { .off = OFFSET(muxing_queue_data_threshold) },
1863  "set the threshold after which max_muxing_queue_size is taken into account", "bytes" },
1864 
1865  /* data codec support */
1867  { .func_arg = opt_data_codec },
1868  "alias for -c:d (select encoder/decoder for data streams)", "codec",
1869  .u1.name_canon = "codec", },
1871  { .off = OFFSET(data_disable) }, "disable data" },
1872 
1873 #if CONFIG_VAAPI
1874  { "vaapi_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1875  { .func_arg = opt_vaapi_device },
1876  "set VAAPI hardware device (DirectX adapter index, DRM path or X11 display name)", "device" },
1877 #endif
1878 
1879 #if CONFIG_QSV
1880  { "qsv_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1881  { .func_arg = opt_qsv_device },
1882  "set QSV hardware device (DirectX adapter index, DRM path or X11 display name)", "device"},
1883 #endif
1884 
1885  { "init_hw_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1886  { .func_arg = opt_init_hw_device },
1887  "initialise hardware device", "args" },
1888  { "filter_hw_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1889  { .func_arg = opt_filter_hw_device },
1890  "set hardware device used when filtering", "device" },
1891 
1892  // deprecated options
1893 #if FFMPEG_OPT_ADRIFT_THRESHOLD
1894  { "adrift_threshold", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1895  { .func_arg = opt_adrift_threshold },
1896  "deprecated, does nothing", "threshold" },
1897 #endif
1898 #if FFMPEG_OPT_TOP
1900  { .off = OFFSET(top_field_first) },
1901  "deprecated, use the setfield video filter", "" },
1902 #endif
1903 #if FFMPEG_OPT_QPHIST
1904  { "qphist", OPT_TYPE_FUNC, OPT_VIDEO | OPT_EXPERT,
1905  { .func_arg = opt_qphist },
1906  "deprecated, does nothing" },
1907 #endif
1908 #if FFMPEG_OPT_VSYNC
1909  { "vsync", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1910  { .func_arg = opt_vsync },
1911  "set video sync method globally; deprecated, use -fps_mode", "" },
1912 #endif
1913 
1914  { NULL, },
1915 };
OPT_EXIT
#define OPT_EXIT
Definition: cmdutils.h:138
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:110
AVCodec
AVCodec.
Definition: codec.h:187
fix_sub_duration_heartbeat
static int fix_sub_duration_heartbeat(DecoderPriv *dp, int64_t signal_pts)
Definition: ffmpeg_dec.c:572
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
InputFile::start_time
int64_t start_time
Definition: ffmpeg.h:403
ignore_unknown_streams
int ignore_unknown_streams
Definition: ffmpeg_opt.c:91
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:168
StreamMap::file_index
int file_index
Definition: ffmpeg.h:118
show_hwaccels
static int show_hwaccels(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:149
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
opt_abort_on
static int opt_abort_on(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:324
VSYNC_VFR
@ VSYNC_VFR
Definition: ffmpeg.h:69
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:126
opt.h
assert_file_overwrite
int assert_file_overwrite(const char *filename)
Definition: ffmpeg_opt.c:614
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:51
opt_video_filters
static int opt_video_filters(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:990
show_help_default
void show_help_default(const char *opt, const char *arg)
Per-fftool specific help handler.
Definition: ffmpeg_opt.c:1055
debug_ts
int debug_ts
Definition: ffmpeg_opt.c:76
stats_period
int64_t stats_period
Definition: ffmpeg_opt.c:86
is
The official guide to swscale for confused that is
Definition: swscale.txt:28
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:947
opt_old2new
static int opt_old2new(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:933
AVStream::discard
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition: avformat.h:814
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:264
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:207
avformat_get_class
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition: options.c:196
program_name
const char program_name[]
program name, defined by the program for show_version().
Definition: ffmpeg.c:106
no_file_overwrite
static int no_file_overwrite
Definition: ffmpeg_opt.c:90
opt_default_new
static int opt_default_new(OptionsContext *o, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:863
OptionsContext::nb_attachments
int nb_attachments
Definition: ffmpeg.h:163
avcodec_find_encoder
const AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
Definition: allcodecs.c:966
auto_conversion_filters
int auto_conversion_filters
Definition: ffmpeg_opt.c:85
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:361
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
pixdesc.h
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1323
OptionsContext::mux_max_delay
float mux_max_delay
Definition: ffmpeg.h:171
OPT_FLAG_OFFSET
#define OPT_FLAG_OFFSET
Definition: cmdutils.h:154
OPT_INPUT
#define OPT_INPUT
Definition: cmdutils.h:168
copy_unknown_streams
int copy_unknown_streams
Definition: ffmpeg_opt.c:92
sync_queue.h
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:87
AV_HWDEVICE_TYPE_NONE
@ AV_HWDEVICE_TYPE_NONE
Definition: hwcontext.h:28
AVOption
AVOption.
Definition: opt.h:346
OptionGroupList::groups
OptionGroup * groups
Definition: cmdutils.h:291
OptionGroupList::nb_groups
int nb_groups
Definition: cmdutils.h:292
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:61
filter_hw_device
HWDevice * filter_hw_device
Definition: ffmpeg_opt.c:57
ffmpeg.h
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
progress_avio
AVIOContext * progress_avio
Definition: ffmpeg.c:123
opt_filter_hw_device
static int opt_filter_hw_device(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:544
fg_create
int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
Create a new filtergraph in the global filtergraph list.
Definition: ffmpeg_filter.c:957
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:143
av_hwdevice_iterate_types
enum AVHWDeviceType av_hwdevice_iterate_types(enum AVHWDeviceType prev)
Iterate over supported device types.
Definition: hwcontext.c:121
autorotate
static int autorotate
Definition: ffplay.c:351
UNKNOWN
@ UNKNOWN
Definition: ftp.c:38
video_disable
static int video_disable
Definition: ffplay.c:318
mathematics.h
AVDictionary
Definition: dict.c:34
HWDevice
Definition: ffmpeg.h:109
hw_device_init_from_string
int hw_device_init_from_string(const char *arg, HWDevice **dev)
Definition: ffmpeg_hw.c:94
do_benchmark
int do_benchmark
Definition: ffmpeg_opt.c:69
OptionDef
Definition: cmdutils.h:126
subtitle_disable
static int subtitle_disable
Definition: ffplay.c:319
OPT_DATA
#define OPT_DATA
Definition: cmdutils.h:146
OptionsContext::chapters_input_file
int chapters_input_file
Definition: ffmpeg.h:165
fifo.h
opt_filter_threads
static int opt_filter_threads(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:317
do_hex_dump
int do_hex_dump
Definition: ffmpeg_opt.c:71
OptionGroupList
A list of option groups that all have the same group type (e.g.
Definition: cmdutils.h:288
bsf.h
do_pkt_dump
int do_pkt_dump
Definition: ffmpeg_opt.c:72
uninit_options
static void uninit_options(OptionsContext *o)
Definition: ffmpeg_opt.c:95
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:1010
OptionsContext::g
OptionGroup * g
Definition: ffmpeg.h:124
fail
#define fail()
Definition: checkasm.h:179
StreamMap::disabled
int disabled
Definition: ffmpeg.h:117
fg_finalise_bindings
int fg_finalise_bindings(FilterGraph *fg)
Definition: ffmpeg_filter.c:1205
opt_data_frames
static int opt_data_frames(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:857
ifile_open
int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
Definition: ffmpeg_demux.c:1523
OptionParseContext
Definition: cmdutils.h:295
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
sws_get_class
const AVClass * sws_get_class(void)
Get the AVClass for swsContext.
Definition: options.c:97
OptionsContext
Definition: ffmpeg.h:123
OPT_TYPE_FLOAT
@ OPT_TYPE_FLOAT
Definition: cmdutils.h:86
loop
static int loop
Definition: ffplay.c:338
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:996
InputFile
Definition: ffmpeg.h:389
opt_filter_complex_script
static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1041
OptionGroupDef
Definition: cmdutils.h:256
AV_OPT_FLAG_AUDIO_PARAM
#define AV_OPT_FLAG_AUDIO_PARAM
Definition: opt.h:274
OptionsContext::recording_time
int64_t recording_time
Definition: ffmpeg.h:167
OPT_PERSTREAM
#define OPT_PERSTREAM
Definition: cmdutils.h:164
OptionsContext::nb_stream_maps
int nb_stream_maps
Definition: ffmpeg.h:161
check_stream_specifier
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
Definition: cmdutils.c:982
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
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:422
OptionGroup::codec_opts
AVDictionary * codec_opts
Definition: cmdutils.h:278
SpecifierOptList::nb_opt
int nb_opt
Definition: cmdutils.h:119
opt_attach
static int opt_attach(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:477
opt_recording_timestamp
static int opt_recording_timestamp(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:558
StreamMap::linklabel
char * linklabel
Definition: ffmpeg.h:120
SpecifierOpt::specifier
char * specifier
stream/chapter/program/...
Definition: cmdutils.h:106
AVCodecDescriptor
This struct describes the properties of a single codec described by an AVCodecID.
Definition: codec_desc.h:38
intreadwrite.h
SpecifierOptList::type
enum OptionType type
Definition: cmdutils.h:123
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:776
format
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
AVFormatContext::iformat
const struct AVInputFormat * iformat
The input container format.
Definition: avformat.h:1267
g
const char * g
Definition: vf_curves.c:127
AVDictionaryEntry::key
char * key
Definition: dict.h:90
OptionsContext::limit_filesize
int64_t limit_filesize
Definition: ffmpeg.h:169
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:178
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:1024
filters
#define filters(fmt, type, inverse, clp, inverset, clip, one, clip_fn, packed)
Definition: af_crystalizer.c:54
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
AVHWDeviceType
AVHWDeviceType
Definition: hwcontext.h:27
term_init
void term_init(void)
Definition: ffmpeg.c:222
AVIO_FLAG_WRITE
#define AVIO_FLAG_WRITE
write-only
Definition: avio.h:618
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
exit_on_error
int exit_on_error
Definition: ffmpeg_opt.c:77
ctx
AVFormatContext * ctx
Definition: movenc.c:48
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:152
av_hwdevice_get_type_name
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
Definition: hwcontext.c:112
do_benchmark_all
int do_benchmark_all
Definition: ffmpeg_opt.c:70
OptionsContext::accurate_seek
int accurate_seek
Definition: ffmpeg.h:147
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:845
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:289
sch_sdp_filename
int sch_sdp_filename(Scheduler *sch, const char *sdp_filename)
Set the file path for the SDP.
Definition: ffmpeg_sched.c:607
arg
const char * arg
Definition: jacosubdec.c:67
if
if(ret)
Definition: filter_design.txt:179
OPT_SPEC
#define OPT_SPEC
Definition: cmdutils.h:160
OptionsContext::start_time
int64_t start_time
Definition: ffmpeg.h:127
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:219
AVFormatContext
Format I/O context.
Definition: avformat.h:1255
OptionGroup::format_opts
AVDictionary * format_opts
Definition: cmdutils.h:279
opts
AVDictionary * opts
Definition: movenc.c:50
opt_target
static int opt_target(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:679
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:766
open_file
static int open_file(AVFormatContext *avf, unsigned fileno)
Definition: concatdec.c:334
opt_profile
static int opt_profile(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:978
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
dec_create
int dec_create(const OptionsContext *o, const char *arg, Scheduler *sch)
Create a standalone decoder.
Definition: ffmpeg_dec.c:1278
strip_specifiers
AVDictionary * strip_specifiers(const AVDictionary *dict)
Definition: ffmpeg_opt.c:162
avcodec_get_class
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
Definition: options.c:185
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:782
NULL
#define NULL
Definition: coverity.c:32
OPT_HAS_ALT
#define OPT_HAS_ALT
Definition: cmdutils.h:173
OptionParseContext::global_opts
OptionGroup global_opts
Definition: cmdutils.h:296
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:999
av_bsf_get_class
const AVClass * av_bsf_get_class(void)
Get the AVClass for AVBSFContext.
Definition: bsf.c:99
OPT_EXPERT
#define OPT_EXPERT
Definition: cmdutils.h:142
swr_get_class
const AVClass * swr_get_class(void)
Get the AVClass for SwrContext.
Definition: options.c:142
InputFile::start_time_effective
int64_t start_time_effective
Effective format start time based on enabled streams.
Definition: ffmpeg.h:400
AVCodec::type
enum AVMediaType type
Definition: codec.h:200
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
parseutils.h
parse_and_set_vsync
int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global)
Definition: ffmpeg_opt.c:192
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:589
AV_DICT_DONT_OVERWRITE
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
Definition: dict.h:81
OptionsContext::input_sync_ref
int input_sync_ref
Definition: ffmpeg.h:149
OptionGroup
Definition: cmdutils.h:271
correct_input_start_times
static void correct_input_start_times(void)
Definition: ffmpeg_opt.c:228
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:269
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:125
Scheduler
Definition: ffmpeg_sched.c:269
avcodec_find_decoder
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: allcodecs.c:971
opt_streamid
static int opt_streamid(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:660
file_read
char * file_read(const char *filename)
Definition: cmdutils.c:1132
opt_preset
static int opt_preset(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:883
opt_vstats_file
static int opt_vstats_file(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:822
codec_opts
AVDictionary * codec_opts
Definition: cmdutils.c:61
options
const OptionDef options[]
VideoSyncMethod
VideoSyncMethod
Definition: ffmpeg.h:65
opt_bitrate
static int opt_bitrate(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:945
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:298
max_error_rate
float max_error_rate
Definition: ffmpeg_opt.c:81
frame_sizes
static const uint8_t frame_sizes[]
Definition: rtpdec_qcelp.c:24
f
f
Definition: af_crystalizer.c:121
AVIOContext
Bytestream IO Context.
Definition: avio.h:160
OptionsContext::thread_queue_size
int thread_queue_size
Definition: ffmpeg.h:148
AVMediaType
AVMediaType
Definition: avutil.h:199
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:529
SpecifierOptList
Definition: cmdutils.h:117
OPT_AUDIO
#define OPT_AUDIO
Definition: cmdutils.h:144
opt_map
static int opt_map(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:385
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:121
start_time
static int64_t start_time
Definition: ffplay.c:329
AVFormatContext::url
char * url
input or output URL.
Definition: avformat.h:1371
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:910
StreamMap
Definition: ffmpeg.h:116
file_overwrite
static int file_overwrite
Definition: ffmpeg_opt.c:89
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
opt_subtitle_codec
static int opt_subtitle_codec(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:373
OptionsContext::streamid
AVDictionary * streamid
Definition: ffmpeg.h:182
PAL
#define PAL
Definition: bktr.c:67
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:663
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:59
OPT_TYPE_INT64
@ OPT_TYPE_INT64
Definition: cmdutils.h:85
printf
printf("static const uint8_t my_array[100] = {\n")
show_usage
void show_usage(void)
Definition: ffmpeg_opt.c:1172
opt_sdp_file
static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:491
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:164
OPT_FLAG_SPEC
#define OPT_FLAG_SPEC
Definition: cmdutils.h:159
OptionsContext::find_stream_info
int find_stream_info
Definition: ffmpeg.h:150
SpecifierOptList::opt
SpecifierOpt * opt
Definition: cmdutils.h:118
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:379
init_options
static void init_options(OptionsContext *o)
Definition: ffmpeg_opt.c:131
av_dict_free
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition: dict.c:223
NTSC
#define NTSC
Definition: bktr.c:69
OPT_TYPE_FUNC
@ OPT_TYPE_FUNC
Definition: cmdutils.h:81
OPT_DECODER
#define OPT_DECODER
Definition: cmdutils.h:179
OPT_TYPE_BOOL
@ OPT_TYPE_BOOL
Definition: cmdutils.h:82
video_sync_method
enum VideoSyncMethod video_sync_method
Definition: ffmpeg_opt.c:66
OPT_HAS_CANON
#define OPT_HAS_CANON
Definition: cmdutils.h:176
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
start_at_zero
int start_at_zero
Definition: ffmpeg_opt.c:74
bprint.h
apply_sync_offsets
static int apply_sync_offsets(void)
Definition: ffmpeg_opt.c:265
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
StreamMap::stream_index
int stream_index
Definition: ffmpeg.h:119
OPT_TYPE_TIME
@ OPT_TYPE_TIME
Definition: cmdutils.h:88
OptionsContext::codec_names
SpecifierOptList codec_names
Definition: ffmpeg.h:132
OptionsContext::stream_maps
StreamMap * stream_maps
Definition: ffmpeg.h:160
OptionsContext::start_time_eof
int64_t start_time_eof
Definition: ffmpeg.h:128
VSYNC_CFR
@ VSYNC_CFR
Definition: ffmpeg.h:68
OptionsContext::shortest_buf_duration
float shortest_buf_duration
Definition: ffmpeg.h:172
opt_video_codec
static int opt_video_codec(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:367
opt_qscale
static int opt_qscale(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:961
display.h
stdin_interaction
int stdin_interaction
Definition: ffmpeg_opt.c:80
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:394
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_OPT_FLAG_VIDEO_PARAM
#define AV_OPT_FLAG_VIDEO_PARAM
Definition: opt.h:275
OPT_FUNC_ARG
#define OPT_FUNC_ARG
Definition: cmdutils.h:136
opt_vstats
static int opt_vstats(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:829
OPT_OUTPUT
#define OPT_OUTPUT
Definition: cmdutils.h:169
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
dts_error_threshold
float dts_error_threshold
Definition: ffmpeg_opt.c:63
filtergraphs
FilterGraph ** filtergraphs
Definition: ffmpeg.c:131
int_cb
const AVIOInterruptCB int_cb
Definition: ffmpeg.c:328
OPT_OFFSET
#define OPT_OFFSET
Definition: cmdutils.h:155
OptionParseContext::groups
OptionGroupList * groups
Definition: cmdutils.h:298
opt_audio_frames
static int opt_audio_frames(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:851
avcodec.h
av_opt_eval_flags
int av_opt_eval_flags(void *obj, const AVOption *o, const char *val, int *flags_out)
find_codec
int find_codec(void *logctx, const char *name, enum AVMediaType type, int encoder, const AVCodec **pcodec)
Definition: ffmpeg_opt.c:581
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:743
AV_LOG_FATAL
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:174
pixfmt.h
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:899
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:71
VSYNC_DROP
@ VSYNC_DROP
Definition: ffmpeg.h:72
uninit_parse_context
void uninit_parse_context(OptionParseContext *octx)
Free all allocated memory in an OptionParseContext.
Definition: cmdutils.c:751
OPT_PERFILE
#define OPT_PERFILE
Definition: cmdutils.h:150
find_stream_info
static int find_stream_info
Definition: ffplay.c:352
avformat.h
CMDUTILS_COMMON_OPTIONS
#define CMDUTILS_COMMON_OPTIONS
Definition: opt_common.h:199
filter_nbthreads
char * filter_nbthreads
Definition: ffmpeg_opt.c:82
OPT_FLAG_PERSTREAM
#define OPT_FLAG_PERSTREAM
Definition: cmdutils.h:163
parse_option
int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options)
Parse one given option.
Definition: cmdutils.c:368
OptionsContext::mux_preload
float mux_preload
Definition: ffmpeg.h:170
channel_layout.h
audio_drift_threshold
float audio_drift_threshold
Definition: ffmpeg_opt.c:61
opt_match_per_type_str
const char * opt_match_per_type_str(const SpecifierOptList *sol, char mediatype)
Definition: ffmpeg_opt.c:179
opt_common.h
AVInputFormat::flags
int flags
Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, AVFMT_NOTIMESTAMPS,...
Definition: avformat.h:567
AVRational::den
int den
Denominator.
Definition: rational.h:60
SpecifierOpt::str
uint8_t * str
Definition: cmdutils.h:108
OPT_SUBTITLE
#define OPT_SUBTITLE
Definition: cmdutils.h:145
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:112
ffmpeg_parse_options
int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
GROW_ARRAY
#define GROW_ARRAY(array, nb_elems)
Definition: cmdutils.h:465
InputFile::ts_offset
int64_t ts_offset
Definition: ffmpeg.h:401
VSYNC_AUTO
@ VSYNC_AUTO
Definition: ffmpeg.h:66
opt_vsync
static int opt_vsync(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1003
parse_optgroup
int parse_optgroup(void *optctx, OptionGroup *g, const OptionDef *defs)
Parse an options group and write results into optctx.
Definition: cmdutils.c:444
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:585
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:270
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:273
desc
const char * desc
Definition: libsvtav1.c:75
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVERROR_ENCODER_NOT_FOUND
#define AVERROR_ENCODER_NOT_FOUND
Encoder not found.
Definition: error.h:56
avutil.h
AVFMT_TS_DISCONT
#define AVFMT_TS_DISCONT
Format allows timestamp discontinuities.
Definition: avformat.h:481
copy_tb
int copy_tb
Definition: ffmpeg_opt.c:75
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:343
vstats_version
int vstats_version
Definition: ffmpeg_opt.c:84
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:490
of_open
int of_open(const OptionsContext *o, const char *filename, Scheduler *sch)
Definition: ffmpeg_mux_init.c:2938
OptionDef::name
const char * name
Definition: cmdutils.h:127
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
ffmpeg_sched.h
OPT_VIDEO
#define OPT_VIDEO
Definition: cmdutils.h:143
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
AVDictionaryEntry
Definition: dict.h:89
OptionsContext::attachments
const char ** attachments
Definition: ffmpeg.h:162
OPT_TYPE_STRING
@ OPT_TYPE_STRING
Definition: cmdutils.h:83
audio_disable
static int audio_disable
Definition: ffplay.c:317
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
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:88
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:237
copy_ts
int copy_ts
Definition: ffmpeg_opt.c:73
cmdutils.h
OFFSET
#define OFFSET(x)
InputFile::input_ts_offset
int64_t input_ts_offset
Definition: ffmpeg.h:395
nb_filtergraphs
int nb_filtergraphs
Definition: ffmpeg.c:132
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:656
codec_string
Definition: dashenc.c:208
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:234
frame_drop_threshold
float frame_drop_threshold
Definition: ffmpeg_opt.c:68
recast_media
int recast_media
Definition: ffmpeg_opt.c:93
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
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:79
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_EXIT
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:58
AVDictionaryEntry::value
char * value
Definition: dict.h:91
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:792
avstring.h
avcodec_descriptor_get_by_name
const AVCodecDescriptor * avcodec_descriptor_get_by_name(const char *name)
Definition: codec_desc.c:3742
InputFile::nb_streams
int nb_streams
Definition: ffmpeg.h:409
hw_device_get_by_name
HWDevice * hw_device_get_by_name(const char *name)
Definition: ffmpeg_hw.c:44
avfilter_get_class
const AVClass * avfilter_get_class(void)
Definition: avfilter.c:1611
dump_attachment
static int dump_attachment(InputStream *ist, const char *filename)
Definition: ffmpeg_demux.c:1456
VSYNC_PASSTHROUGH
@ VSYNC_PASSTHROUGH
Definition: ffmpeg.h:67
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
snprintf
#define snprintf
Definition: snprintf.h:34
ABORT_ON_FLAG_EMPTY_OUTPUT
#define ABORT_ON_FLAG_EMPTY_OUTPUT
Definition: ffmpeg.h:421
opt_filter_complex
static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1030
av_dict_iterate
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition: dict.c:44
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:994
dts_delta_threshold
float dts_delta_threshold
Definition: ffmpeg_opt.c:62
abort_on_flags
int abort_on_flags
Definition: ffmpeg_opt.c:78
filter_complex_nbthreads
int filter_complex_nbthreads
Definition: ffmpeg_opt.c:83