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