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_get(dict, "", e, AV_DICT_IGNORE_SUFFIX))) {
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(const char *name, enum AVMediaType type, int encoder)
627 {
628  const AVCodecDescriptor *desc;
629  const char *codec_string = encoder ? "encoder" : "decoder";
630  const AVCodec *codec;
631 
632  codec = encoder ?
635 
636  if (!codec && (desc = avcodec_descriptor_get_by_name(name))) {
637  codec = encoder ? avcodec_find_encoder(desc->id) :
639  if (codec)
640  av_log(NULL, AV_LOG_VERBOSE, "Matched %s '%s' for codec '%s'.\n",
641  codec_string, codec->name, desc->name);
642  }
643 
644  if (!codec) {
645  av_log(NULL, AV_LOG_FATAL, "Unknown %s '%s'\n", codec_string, name);
646  exit_program(1);
647  }
648  if (codec->type != type && !recast_media) {
649  av_log(NULL, AV_LOG_FATAL, "Invalid %s type '%s'\n", codec_string, name);
650  exit_program(1);
651  }
652  return codec;
653 }
654 
655 void assert_file_overwrite(const char *filename)
656 {
657  const char *proto_name = avio_find_protocol_name(filename);
658 
660  fprintf(stderr, "Error, both -y and -n supplied. Exiting.\n");
661  exit_program(1);
662  }
663 
664  if (!file_overwrite) {
665  if (proto_name && !strcmp(proto_name, "file") && avio_check(filename, 0) == 0) {
667  fprintf(stderr,"File '%s' already exists. Overwrite? [y/N] ", filename);
668  fflush(stderr);
669  term_exit();
670  signal(SIGINT, SIG_DFL);
671  if (!read_yesno()) {
672  av_log(NULL, AV_LOG_FATAL, "Not overwriting - exiting\n");
673  exit_program(1);
674  }
675  term_init();
676  }
677  else {
678  av_log(NULL, AV_LOG_FATAL, "File '%s' already exists. Exiting.\n", filename);
679  exit_program(1);
680  }
681  }
682  }
683 
684  if (proto_name && !strcmp(proto_name, "file")) {
685  for (int i = 0; i < nb_input_files; i++) {
686  InputFile *file = input_files[i];
687  if (file->ctx->iformat->flags & AVFMT_NOFILE)
688  continue;
689  if (!strcmp(filename, file->ctx->url)) {
690  av_log(NULL, AV_LOG_FATAL, "Output %s same as Input #%d - exiting\n", filename, i);
691  av_log(NULL, AV_LOG_WARNING, "FFmpeg cannot edit existing files in-place.\n");
692  exit_program(1);
693  }
694  }
695  }
696 }
697 
698 /* read file contents into a string */
699 char *file_read(const char *filename)
700 {
701  AVIOContext *pb = NULL;
702  int ret = avio_open(&pb, filename, AVIO_FLAG_READ);
703  AVBPrint bprint;
704  char *str;
705 
706  if (ret < 0) {
707  av_log(NULL, AV_LOG_ERROR, "Error opening file %s.\n", filename);
708  return NULL;
709  }
710 
712  ret = avio_read_to_bprint(pb, &bprint, SIZE_MAX);
713  avio_closep(&pb);
714  if (ret < 0) {
715  av_bprint_finalize(&bprint, NULL);
716  return NULL;
717  }
718  ret = av_bprint_finalize(&bprint, &str);
719  if (ret < 0)
720  return NULL;
721  return str;
722 }
723 
724 /* arg format is "output-stream-index:streamid-value". */
725 static int opt_streamid(void *optctx, const char *opt, const char *arg)
726 {
727  OptionsContext *o = optctx;
728  int idx;
729  char *p;
730  char idx_str[16];
731 
732  av_strlcpy(idx_str, arg, sizeof(idx_str));
733  p = strchr(idx_str, ':');
734  if (!p) {
736  "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
737  arg, opt);
738  exit_program(1);
739  }
740  *p++ = '\0';
741  idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1);
742  o->streamid_map = grow_array(o->streamid_map, sizeof(*o->streamid_map), &o->nb_streamid_map, idx+1);
743  o->streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);
744  return 0;
745 }
746 
747 static int init_complex_filters(void)
748 {
749  int i, ret = 0;
750 
751  for (i = 0; i < nb_filtergraphs; i++) {
753  if (ret < 0)
754  return ret;
755  }
756  return 0;
757 }
758 
759 static int opt_target(void *optctx, const char *opt, const char *arg)
760 {
761  OptionsContext *o = optctx;
762  enum { PAL, NTSC, FILM, UNKNOWN } norm = UNKNOWN;
763  static const char *const frame_rates[] = { "25", "30000/1001", "24000/1001" };
764 
765  if (!strncmp(arg, "pal-", 4)) {
766  norm = PAL;
767  arg += 4;
768  } else if (!strncmp(arg, "ntsc-", 5)) {
769  norm = NTSC;
770  arg += 5;
771  } else if (!strncmp(arg, "film-", 5)) {
772  norm = FILM;
773  arg += 5;
774  } else {
775  /* Try to determine PAL/NTSC by peeking in the input files */
776  if (nb_input_files) {
777  int i, j;
778  for (j = 0; j < nb_input_files; j++) {
779  for (i = 0; i < input_files[j]->nb_streams; i++) {
780  AVStream *st = input_files[j]->ctx->streams[i];
781  int64_t fr;
783  continue;
784  fr = st->time_base.den * 1000LL / st->time_base.num;
785  if (fr == 25000) {
786  norm = PAL;
787  break;
788  } else if ((fr == 29970) || (fr == 23976)) {
789  norm = NTSC;
790  break;
791  }
792  }
793  if (norm != UNKNOWN)
794  break;
795  }
796  }
797  if (norm != UNKNOWN)
798  av_log(NULL, AV_LOG_INFO, "Assuming %s for target.\n", norm == PAL ? "PAL" : "NTSC");
799  }
800 
801  if (norm == UNKNOWN) {
802  av_log(NULL, AV_LOG_FATAL, "Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
803  av_log(NULL, AV_LOG_FATAL, "Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
804  av_log(NULL, AV_LOG_FATAL, "or set a framerate with \"-r xxx\".\n");
805  exit_program(1);
806  }
807 
808  if (!strcmp(arg, "vcd")) {
809  opt_video_codec(o, "c:v", "mpeg1video");
810  opt_audio_codec(o, "c:a", "mp2");
811  parse_option(o, "f", "vcd", options);
812 
813  parse_option(o, "s", norm == PAL ? "352x288" : "352x240", options);
814  parse_option(o, "r", frame_rates[norm], options);
815  opt_default(NULL, "g", norm == PAL ? "15" : "18");
816 
817  opt_default(NULL, "b:v", "1150000");
818  opt_default(NULL, "maxrate:v", "1150000");
819  opt_default(NULL, "minrate:v", "1150000");
820  opt_default(NULL, "bufsize:v", "327680"); // 40*1024*8;
821 
822  opt_default(NULL, "b:a", "224000");
823  parse_option(o, "ar", "44100", options);
824  parse_option(o, "ac", "2", options);
825 
826  opt_default(NULL, "packetsize", "2324");
827  opt_default(NULL, "muxrate", "1411200"); // 2352 * 75 * 8;
828 
829  /* We have to offset the PTS, so that it is consistent with the SCR.
830  SCR starts at 36000, but the first two packs contain only padding
831  and the first pack from the other stream, respectively, may also have
832  been written before.
833  So the real data starts at SCR 36000+3*1200. */
834  o->mux_preload = (36000 + 3 * 1200) / 90000.0; // 0.44
835  } else if (!strcmp(arg, "svcd")) {
836 
837  opt_video_codec(o, "c:v", "mpeg2video");
838  opt_audio_codec(o, "c:a", "mp2");
839  parse_option(o, "f", "svcd", options);
840 
841  parse_option(o, "s", norm == PAL ? "480x576" : "480x480", options);
842  parse_option(o, "r", frame_rates[norm], options);
843  parse_option(o, "pix_fmt", "yuv420p", options);
844  opt_default(NULL, "g", norm == PAL ? "15" : "18");
845 
846  opt_default(NULL, "b:v", "2040000");
847  opt_default(NULL, "maxrate:v", "2516000");
848  opt_default(NULL, "minrate:v", "0"); // 1145000;
849  opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;
850  opt_default(NULL, "scan_offset", "1");
851 
852  opt_default(NULL, "b:a", "224000");
853  parse_option(o, "ar", "44100", options);
854 
855  opt_default(NULL, "packetsize", "2324");
856 
857  } else if (!strcmp(arg, "dvd")) {
858 
859  opt_video_codec(o, "c:v", "mpeg2video");
860  opt_audio_codec(o, "c:a", "ac3");
861  parse_option(o, "f", "dvd", options);
862 
863  parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
864  parse_option(o, "r", frame_rates[norm], options);
865  parse_option(o, "pix_fmt", "yuv420p", options);
866  opt_default(NULL, "g", norm == PAL ? "15" : "18");
867 
868  opt_default(NULL, "b:v", "6000000");
869  opt_default(NULL, "maxrate:v", "9000000");
870  opt_default(NULL, "minrate:v", "0"); // 1500000;
871  opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;
872 
873  opt_default(NULL, "packetsize", "2048"); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
874  opt_default(NULL, "muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8
875 
876  opt_default(NULL, "b:a", "448000");
877  parse_option(o, "ar", "48000", options);
878 
879  } else if (!strncmp(arg, "dv", 2)) {
880 
881  parse_option(o, "f", "dv", options);
882 
883  parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
884  parse_option(o, "pix_fmt", !strncmp(arg, "dv50", 4) ? "yuv422p" :
885  norm == PAL ? "yuv420p" : "yuv411p", options);
886  parse_option(o, "r", frame_rates[norm], options);
887 
888  parse_option(o, "ar", "48000", options);
889  parse_option(o, "ac", "2", options);
890 
891  } else {
892  av_log(NULL, AV_LOG_ERROR, "Unknown target: %s\n", arg);
893  return AVERROR(EINVAL);
894  }
895 
898 
899  return 0;
900 }
901 
902 static int opt_vstats_file(void *optctx, const char *opt, const char *arg)
903 {
906  return 0;
907 }
908 
909 static int opt_vstats(void *optctx, const char *opt, const char *arg)
910 {
911  char filename[40];
912  time_t today2 = time(NULL);
913  struct tm *today = localtime(&today2);
914 
915  if (!today) { // maybe tomorrow
916  av_log(NULL, AV_LOG_FATAL, "Unable to get current time: %s\n", strerror(errno));
917  exit_program(1);
918  }
919 
920  snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
921  today->tm_sec);
922  return opt_vstats_file(NULL, opt, filename);
923 }
924 
925 static int opt_video_frames(void *optctx, const char *opt, const char *arg)
926 {
927  OptionsContext *o = optctx;
928  return parse_option(o, "frames:v", arg, options);
929 }
930 
931 static int opt_audio_frames(void *optctx, const char *opt, const char *arg)
932 {
933  OptionsContext *o = optctx;
934  return parse_option(o, "frames:a", arg, options);
935 }
936 
937 static int opt_data_frames(void *optctx, const char *opt, const char *arg)
938 {
939  OptionsContext *o = optctx;
940  return parse_option(o, "frames:d", arg, options);
941 }
942 
943 static int opt_default_new(OptionsContext *o, const char *opt, const char *arg)
944 {
945  int ret;
946  AVDictionary *cbak = codec_opts;
947  AVDictionary *fbak = format_opts;
948  codec_opts = NULL;
949  format_opts = NULL;
950 
951  ret = opt_default(NULL, opt, arg);
952 
953  av_dict_copy(&o->g->codec_opts , codec_opts, 0);
957  codec_opts = cbak;
958  format_opts = fbak;
959 
960  return ret;
961 }
962 
963 static int opt_preset(void *optctx, const char *opt, const char *arg)
964 {
965  OptionsContext *o = optctx;
966  FILE *f=NULL;
967  char filename[1000], line[1000], tmp_line[1000];
968  const char *codec_name = NULL;
969 
970  tmp_line[0] = *opt;
971  tmp_line[1] = 0;
972  MATCH_PER_TYPE_OPT(codec_names, str, codec_name, NULL, tmp_line);
973 
974  if (!(f = get_preset_file(filename, sizeof(filename), arg, *opt == 'f', codec_name))) {
975  if(!strncmp(arg, "libx264-lossless", strlen("libx264-lossless"))){
976  av_log(NULL, AV_LOG_FATAL, "Please use -preset <speed> -qp 0\n");
977  }else
978  av_log(NULL, AV_LOG_FATAL, "File for preset '%s' not found\n", arg);
979  exit_program(1);
980  }
981 
982  while (fgets(line, sizeof(line), f)) {
983  char *key = tmp_line, *value, *endptr;
984 
985  if (strcspn(line, "#\n\r") == 0)
986  continue;
987  av_strlcpy(tmp_line, line, sizeof(tmp_line));
988  if (!av_strtok(key, "=", &value) ||
989  !av_strtok(value, "\r\n", &endptr)) {
990  av_log(NULL, AV_LOG_FATAL, "%s: Invalid syntax: '%s'\n", filename, line);
991  exit_program(1);
992  }
993  av_log(NULL, AV_LOG_DEBUG, "ffpreset[%s]: set '%s' = '%s'\n", filename, key, value);
994 
995  if (!strcmp(key, "acodec")) opt_audio_codec (o, key, value);
996  else if (!strcmp(key, "vcodec")) opt_video_codec (o, key, value);
997  else if (!strcmp(key, "scodec")) opt_subtitle_codec(o, key, value);
998  else if (!strcmp(key, "dcodec")) opt_data_codec (o, key, value);
999  else if (opt_default_new(o, key, value) < 0) {
1000  av_log(NULL, AV_LOG_FATAL, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n",
1001  filename, line, key, value);
1002  exit_program(1);
1003  }
1004  }
1005 
1006  fclose(f);
1007 
1008  return 0;
1009 }
1010 
1011 static int opt_old2new(void *optctx, const char *opt, const char *arg)
1012 {
1013  OptionsContext *o = optctx;
1014  int ret;
1015  char *s = av_asprintf("%s:%c", opt + 1, *opt);
1016  if (!s)
1017  return AVERROR(ENOMEM);
1018  ret = parse_option(o, s, arg, options);
1019  av_free(s);
1020  return ret;
1021 }
1022 
1023 static int opt_bitrate(void *optctx, const char *opt, const char *arg)
1024 {
1025  OptionsContext *o = optctx;
1026 
1027  if(!strcmp(opt, "ab")){
1028  av_dict_set(&o->g->codec_opts, "b:a", arg, 0);
1029  return 0;
1030  } else if(!strcmp(opt, "b")){
1031  av_log(NULL, AV_LOG_WARNING, "Please use -b:a or -b:v, -b is ambiguous\n");
1032  av_dict_set(&o->g->codec_opts, "b:v", arg, 0);
1033  return 0;
1034  }
1035  av_dict_set(&o->g->codec_opts, opt, arg, 0);
1036  return 0;
1037 }
1038 
1039 static int opt_qscale(void *optctx, const char *opt, const char *arg)
1040 {
1041  OptionsContext *o = optctx;
1042  char *s;
1043  int ret;
1044  if(!strcmp(opt, "qscale")){
1045  av_log(NULL, AV_LOG_WARNING, "Please use -q:a or -q:v, -qscale is ambiguous\n");
1046  return parse_option(o, "q:v", arg, options);
1047  }
1048  s = av_asprintf("q%s", opt + 6);
1049  if (!s)
1050  return AVERROR(ENOMEM);
1051  ret = parse_option(o, s, arg, options);
1052  av_free(s);
1053  return ret;
1054 }
1055 
1056 static int opt_profile(void *optctx, const char *opt, const char *arg)
1057 {
1058  OptionsContext *o = optctx;
1059  if(!strcmp(opt, "profile")){
1060  av_log(NULL, AV_LOG_WARNING, "Please use -profile:a or -profile:v, -profile is ambiguous\n");
1061  av_dict_set(&o->g->codec_opts, "profile:v", arg, 0);
1062  return 0;
1063  }
1064  av_dict_set(&o->g->codec_opts, opt, arg, 0);
1065  return 0;
1066 }
1067 
1068 static int opt_video_filters(void *optctx, const char *opt, const char *arg)
1069 {
1070  OptionsContext *o = optctx;
1071  return parse_option(o, "filter:v", arg, options);
1072 }
1073 
1074 static int opt_audio_filters(void *optctx, const char *opt, const char *arg)
1075 {
1076  OptionsContext *o = optctx;
1077  return parse_option(o, "filter:a", arg, options);
1078 }
1079 
1080 static int opt_vsync(void *optctx, const char *opt, const char *arg)
1081 {
1082  av_log(NULL, AV_LOG_WARNING, "-vsync is deprecated. Use -fps_mode\n");
1084  return 0;
1085 }
1086 
1087 static int opt_timecode(void *optctx, const char *opt, const char *arg)
1088 {
1089  OptionsContext *o = optctx;
1090  int ret;
1091  char *tcr = av_asprintf("timecode=%s", arg);
1092  if (!tcr)
1093  return AVERROR(ENOMEM);
1094  ret = parse_option(o, "metadata:g", tcr, options);
1095  if (ret >= 0)
1096  ret = av_dict_set(&o->g->codec_opts, "gop_timecode", arg, 0);
1097  av_free(tcr);
1098  return ret;
1099 }
1100 
1101 static int opt_audio_qscale(void *optctx, const char *opt, const char *arg)
1102 {
1103  OptionsContext *o = optctx;
1104  return parse_option(o, "q:a", arg, options);
1105 }
1106 
1107 static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
1108 {
1110 
1111  fg->index = nb_filtergraphs - 1;
1112  fg->graph_desc = av_strdup(arg);
1113  if (!fg->graph_desc)
1114  return AVERROR(ENOMEM);
1115 
1116  return 0;
1117 }
1118 
1119 static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
1120 {
1121  FilterGraph *fg;
1122  char *graph_desc = file_read(arg);
1123  if (!graph_desc)
1124  return AVERROR(EINVAL);
1125 
1127  fg->index = nb_filtergraphs - 1;
1128  fg->graph_desc = graph_desc;
1129 
1130  return 0;
1131 }
1132 
1133 void show_help_default(const char *opt, const char *arg)
1134 {
1135  /* per-file options have at least one of those set */
1136  const int per_file = OPT_SPEC | OPT_OFFSET | OPT_PERFILE;
1137  int show_advanced = 0, show_avoptions = 0;
1138 
1139  if (opt && *opt) {
1140  if (!strcmp(opt, "long"))
1141  show_advanced = 1;
1142  else if (!strcmp(opt, "full"))
1143  show_advanced = show_avoptions = 1;
1144  else
1145  av_log(NULL, AV_LOG_ERROR, "Unknown help option '%s'.\n", opt);
1146  }
1147 
1148  show_usage();
1149 
1150  printf("Getting help:\n"
1151  " -h -- print basic options\n"
1152  " -h long -- print more options\n"
1153  " -h full -- print all options (including all format and codec specific options, very long)\n"
1154  " -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf/protocol\n"
1155  " See man %s for detailed description of the options.\n"
1156  "\n", program_name);
1157 
1158  show_help_options(options, "Print help / information / capabilities:",
1159  OPT_EXIT, 0, 0);
1160 
1161  show_help_options(options, "Global options (affect whole program "
1162  "instead of just one file):",
1163  0, per_file | OPT_EXIT | OPT_EXPERT, 0);
1164  if (show_advanced)
1165  show_help_options(options, "Advanced global options:", OPT_EXPERT,
1166  per_file | OPT_EXIT, 0);
1167 
1168  show_help_options(options, "Per-file main options:", 0,
1170  OPT_EXIT, per_file);
1171  if (show_advanced)
1172  show_help_options(options, "Advanced per-file options:",
1173  OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, per_file);
1174 
1175  show_help_options(options, "Video options:",
1177  if (show_advanced)
1178  show_help_options(options, "Advanced Video options:",
1180 
1181  show_help_options(options, "Audio options:",
1183  if (show_advanced)
1184  show_help_options(options, "Advanced Audio options:",
1186  show_help_options(options, "Subtitle options:",
1187  OPT_SUBTITLE, 0, 0);
1188  printf("\n");
1189 
1190  if (show_avoptions) {
1194 #if CONFIG_SWSCALE
1196 #endif
1197 #if CONFIG_SWRESAMPLE
1199 #endif
1202  }
1203 }
1204 
1205 void show_usage(void)
1206 {
1207  av_log(NULL, AV_LOG_INFO, "Hyper fast Audio and Video encoder\n");
1208  av_log(NULL, AV_LOG_INFO, "usage: %s [options] [[infile options] -i infile]... {[outfile options] outfile}...\n", program_name);
1209  av_log(NULL, AV_LOG_INFO, "\n");
1210 }
1211 
1212 enum OptGroup {
1213  GROUP_OUTFILE,
1214  GROUP_INFILE,
1215 };
1216 
1217 static const OptionGroupDef groups[] = {
1218  [GROUP_OUTFILE] = { "output url", NULL, OPT_OUTPUT },
1219  [GROUP_INFILE] = { "input url", "i", OPT_INPUT },
1220 };
1221 
1222 static int open_files(OptionGroupList *l, const char *inout,
1223  int (*open_file)(const OptionsContext*, const char*))
1224 {
1225  int i, ret;
1226 
1227  for (i = 0; i < l->nb_groups; i++) {
1228  OptionGroup *g = &l->groups[i];
1229  OptionsContext o;
1230 
1231  init_options(&o);
1232  o.g = g;
1233 
1234  ret = parse_optgroup(&o, g);
1235  if (ret < 0) {
1236  av_log(NULL, AV_LOG_ERROR, "Error parsing options for %s file "
1237  "%s.\n", inout, g->arg);
1238  uninit_options(&o);
1239  return ret;
1240  }
1241 
1242  av_log(NULL, AV_LOG_DEBUG, "Opening an %s file: %s.\n", inout, g->arg);
1243  ret = open_file(&o, g->arg);
1244  uninit_options(&o);
1245  if (ret < 0) {
1246  av_log(NULL, AV_LOG_ERROR, "Error opening %s file %s.\n",
1247  inout, g->arg);
1248  return ret;
1249  }
1250  av_log(NULL, AV_LOG_DEBUG, "Successfully opened the file.\n");
1251  }
1252 
1253  return 0;
1254 }
1255 
1256 int ffmpeg_parse_options(int argc, char **argv)
1257 {
1258  OptionParseContext octx;
1259  int ret;
1260 
1261  memset(&octx, 0, sizeof(octx));
1262 
1263  /* split the commandline into an internal representation */
1264  ret = split_commandline(&octx, argc, argv, options, groups,
1265  FF_ARRAY_ELEMS(groups));
1266  if (ret < 0) {
1267  av_log(NULL, AV_LOG_FATAL, "Error splitting the argument list: ");
1268  goto fail;
1269  }
1270 
1271  /* apply global options */
1272  ret = parse_optgroup(NULL, &octx.global_opts);
1273  if (ret < 0) {
1274  av_log(NULL, AV_LOG_FATAL, "Error parsing global options: ");
1275  goto fail;
1276  }
1277 
1278  /* configure terminal and setup signal handlers */
1279  term_init();
1280 
1281  /* open input files */
1282  ret = open_files(&octx.groups[GROUP_INFILE], "input", ifile_open);
1283  if (ret < 0) {
1284  av_log(NULL, AV_LOG_FATAL, "Error opening input files: ");
1285  goto fail;
1286  }
1287 
1288  /* create the complex filtergraphs */
1290  if (ret < 0) {
1291  av_log(NULL, AV_LOG_FATAL, "Error initializing complex filters.\n");
1292  goto fail;
1293  }
1294 
1295  /* open output files */
1296  ret = open_files(&octx.groups[GROUP_OUTFILE], "output", of_open);
1297  if (ret < 0) {
1298  av_log(NULL, AV_LOG_FATAL, "Error opening output files: ");
1299  goto fail;
1300  }
1301 
1303 
1305 
1307 
1308 fail:
1309  uninit_parse_context(&octx);
1310  if (ret < 0) {
1311  av_log(NULL, AV_LOG_FATAL, "%s\n", av_err2str(ret));
1312  }
1313  return ret;
1314 }
1315 
1316 static int opt_progress(void *optctx, const char *opt, const char *arg)
1317 {
1318  AVIOContext *avio = NULL;
1319  int ret;
1320 
1321  if (!strcmp(arg, "-"))
1322  arg = "pipe:";
1323  ret = avio_open2(&avio, arg, AVIO_FLAG_WRITE, &int_cb, NULL);
1324  if (ret < 0) {
1325  av_log(NULL, AV_LOG_ERROR, "Failed to open progress URL \"%s\": %s\n",
1326  arg, av_err2str(ret));
1327  return ret;
1328  }
1329  progress_avio = avio;
1330  return 0;
1331 }
1332 
1333 int opt_timelimit(void *optctx, const char *opt, const char *arg)
1334 {
1335 #if HAVE_SETRLIMIT
1336  int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
1337  struct rlimit rl = { lim, lim + 1 };
1338  if (setrlimit(RLIMIT_CPU, &rl))
1339  perror("setrlimit");
1340 #else
1341  av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
1342 #endif
1343  return 0;
1344 }
1345 
1346 #define OFFSET(x) offsetof(OptionsContext, x)
1347 const OptionDef options[] = {
1348  /* main options */
1350  { "f", HAS_ARG | OPT_STRING | OPT_OFFSET |
1351  OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(format) },
1352  "force format", "fmt" },
1353  { "y", OPT_BOOL, { &file_overwrite },
1354  "overwrite output files" },
1355  { "n", OPT_BOOL, { &no_file_overwrite },
1356  "never overwrite output files" },
1357  { "ignore_unknown", OPT_BOOL, { &ignore_unknown_streams },
1358  "Ignore unknown stream types" },
1359  { "copy_unknown", OPT_BOOL | OPT_EXPERT, { &copy_unknown_streams },
1360  "Copy unknown stream types" },
1361  { "recast_media", OPT_BOOL | OPT_EXPERT, { &recast_media },
1362  "allow recasting stream type in order to force a decoder of different media type" },
1363  { "c", HAS_ARG | OPT_STRING | OPT_SPEC |
1364  OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(codec_names) },
1365  "codec name", "codec" },
1366  { "codec", HAS_ARG | OPT_STRING | OPT_SPEC |
1367  OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(codec_names) },
1368  "codec name", "codec" },
1369  { "pre", HAS_ARG | OPT_STRING | OPT_SPEC |
1370  OPT_OUTPUT, { .off = OFFSET(presets) },
1371  "preset name", "preset" },
1372  { "map", HAS_ARG | OPT_EXPERT | OPT_PERFILE |
1373  OPT_OUTPUT, { .func_arg = opt_map },
1374  "set input stream mapping",
1375  "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
1376 #if FFMPEG_OPT_MAP_CHANNEL
1377  { "map_channel", HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_map_channel },
1378  "map an audio channel from one stream to another (deprecated)", "file.stream.channel[:syncfile.syncstream]" },
1379 #endif
1380  { "map_metadata", HAS_ARG | OPT_STRING | OPT_SPEC |
1381  OPT_OUTPUT, { .off = OFFSET(metadata_map) },
1382  "set metadata information of outfile from infile",
1383  "outfile[,metadata]:infile[,metadata]" },
1384  { "map_chapters", HAS_ARG | OPT_INT | OPT_EXPERT | OPT_OFFSET |
1385  OPT_OUTPUT, { .off = OFFSET(chapters_input_file) },
1386  "set chapters mapping", "input_file_index" },
1387  { "t", HAS_ARG | OPT_TIME | OPT_OFFSET |
1388  OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(recording_time) },
1389  "record or transcode \"duration\" seconds of audio/video",
1390  "duration" },
1391  { "to", HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(stop_time) },
1392  "record or transcode stop time", "time_stop" },
1393  { "fs", HAS_ARG | OPT_INT64 | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(limit_filesize) },
1394  "set the limit file size in bytes", "limit_size" },
1395  { "ss", HAS_ARG | OPT_TIME | OPT_OFFSET |
1396  OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(start_time) },
1397  "set the start time offset", "time_off" },
1398  { "sseof", HAS_ARG | OPT_TIME | OPT_OFFSET |
1399  OPT_INPUT, { .off = OFFSET(start_time_eof) },
1400  "set the start time offset relative to EOF", "time_off" },
1401  { "seek_timestamp", HAS_ARG | OPT_INT | OPT_OFFSET |
1402  OPT_INPUT, { .off = OFFSET(seek_timestamp) },
1403  "enable/disable seeking by timestamp with -ss" },
1404  { "accurate_seek", OPT_BOOL | OPT_OFFSET | OPT_EXPERT |
1405  OPT_INPUT, { .off = OFFSET(accurate_seek) },
1406  "enable/disable accurate seeking with -ss" },
1407  { "isync", HAS_ARG | OPT_INT | OPT_OFFSET |
1408  OPT_EXPERT | OPT_INPUT, { .off = OFFSET(input_sync_ref) },
1409  "Indicate the input index for sync reference", "sync ref" },
1410  { "itsoffset", HAS_ARG | OPT_TIME | OPT_OFFSET |
1411  OPT_EXPERT | OPT_INPUT, { .off = OFFSET(input_ts_offset) },
1412  "set the input ts offset", "time_off" },
1413  { "itsscale", HAS_ARG | OPT_DOUBLE | OPT_SPEC |
1414  OPT_EXPERT | OPT_INPUT, { .off = OFFSET(ts_scale) },
1415  "set the input ts scale", "scale" },
1416  { "timestamp", HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_recording_timestamp },
1417  "set the recording timestamp ('now' to set the current time)", "time" },
1418  { "metadata", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(metadata) },
1419  "add metadata", "string=string" },
1420  { "program", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(program) },
1421  "add program with specified streams", "title=string:st=number..." },
1422  { "dframes", HAS_ARG | OPT_PERFILE | OPT_EXPERT |
1423  OPT_OUTPUT, { .func_arg = opt_data_frames },
1424  "set the number of data frames to output", "number" },
1425  { "benchmark", OPT_BOOL | OPT_EXPERT, { &do_benchmark },
1426  "add timings for benchmarking" },
1427  { "benchmark_all", OPT_BOOL | OPT_EXPERT, { &do_benchmark_all },
1428  "add timings for each task" },
1429  { "progress", HAS_ARG | OPT_EXPERT, { .func_arg = opt_progress },
1430  "write program-readable progress information", "url" },
1431  { "stdin", OPT_BOOL | OPT_EXPERT, { &stdin_interaction },
1432  "enable or disable interaction on standard input" },
1433  { "timelimit", HAS_ARG | OPT_EXPERT, { .func_arg = opt_timelimit },
1434  "set max runtime in seconds in CPU user time", "limit" },
1435  { "dump", OPT_BOOL | OPT_EXPERT, { &do_pkt_dump },
1436  "dump each input packet" },
1437  { "hex", OPT_BOOL | OPT_EXPERT, { &do_hex_dump },
1438  "when dumping packets, also dump the payload" },
1439  { "re", OPT_BOOL | OPT_EXPERT | OPT_OFFSET |
1440  OPT_INPUT, { .off = OFFSET(rate_emu) },
1441  "read input at native frame rate; equivalent to -readrate 1", "" },
1442  { "readrate", HAS_ARG | OPT_FLOAT | OPT_OFFSET |
1443  OPT_EXPERT | OPT_INPUT, { .off = OFFSET(readrate) },
1444  "read input at specified rate", "speed" },
1445  { "target", HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_target },
1446  "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\" or \"dv50\" "
1447  "with optional prefixes \"pal-\", \"ntsc-\" or \"film-\")", "type" },
1448  { "vsync", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vsync },
1449  "set video sync method globally; deprecated, use -fps_mode", "" },
1450  { "frame_drop_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &frame_drop_threshold },
1451  "frame drop threshold", "" },
1452  { "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &audio_drift_threshold },
1453  "audio drift threshold", "threshold" },
1454  { "copyts", OPT_BOOL | OPT_EXPERT, { &copy_ts },
1455  "copy timestamps" },
1456  { "start_at_zero", OPT_BOOL | OPT_EXPERT, { &start_at_zero },
1457  "shift input timestamps to start at 0 when using copyts" },
1458  { "copytb", HAS_ARG | OPT_INT | OPT_EXPERT, { &copy_tb },
1459  "copy input stream time base when stream copying", "mode" },
1460  { "shortest", OPT_BOOL | OPT_EXPERT | OPT_OFFSET |
1461  OPT_OUTPUT, { .off = OFFSET(shortest) },
1462  "finish encoding within shortest input" },
1463  { "shortest_buf_duration", HAS_ARG | OPT_FLOAT | OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(shortest_buf_duration) },
1464  "maximum buffering duration (in seconds) for the -shortest option" },
1465  { "bitexact", OPT_BOOL | OPT_EXPERT | OPT_OFFSET |
1466  OPT_OUTPUT | OPT_INPUT, { .off = OFFSET(bitexact) },
1467  "bitexact mode" },
1468  { "apad", OPT_STRING | HAS_ARG | OPT_SPEC |
1469  OPT_OUTPUT, { .off = OFFSET(apad) },
1470  "audio pad", "" },
1471  { "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &dts_delta_threshold },
1472  "timestamp discontinuity delta threshold", "threshold" },
1473  { "dts_error_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &dts_error_threshold },
1474  "timestamp error delta threshold", "threshold" },
1475  { "xerror", OPT_BOOL | OPT_EXPERT, { &exit_on_error },
1476  "exit on error", "error" },
1477  { "abort_on", HAS_ARG | OPT_EXPERT, { .func_arg = opt_abort_on },
1478  "abort on the specified condition flags", "flags" },
1479  { "copyinkf", OPT_BOOL | OPT_EXPERT | OPT_SPEC |
1480  OPT_OUTPUT, { .off = OFFSET(copy_initial_nonkeyframes) },
1481  "copy initial non-keyframes" },
1482  { "copypriorss", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(copy_prior_start) },
1483  "copy or discard frames before start time" },
1484  { "frames", OPT_INT64 | HAS_ARG | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(max_frames) },
1485  "set the number of frames to output", "number" },
1486  { "tag", OPT_STRING | HAS_ARG | OPT_SPEC |
1487  OPT_EXPERT | OPT_OUTPUT | OPT_INPUT, { .off = OFFSET(codec_tags) },
1488  "force codec tag/fourcc", "fourcc/tag" },
1489  { "q", HAS_ARG | OPT_EXPERT | OPT_DOUBLE |
1490  OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(qscale) },
1491  "use fixed quality scale (VBR)", "q" },
1492  { "qscale", HAS_ARG | OPT_EXPERT | OPT_PERFILE |
1493  OPT_OUTPUT, { .func_arg = opt_qscale },
1494  "use fixed quality scale (VBR)", "q" },
1495  { "profile", HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_profile },
1496  "set profile", "profile" },
1497  { "filter", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filters) },
1498  "set stream filtergraph", "filter_graph" },
1499  { "filter_threads", HAS_ARG, { .func_arg = opt_filter_threads },
1500  "number of non-complex filter threads" },
1501  { "filter_script", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filter_scripts) },
1502  "read stream filtergraph description from a file", "filename" },
1503  { "reinit_filter", HAS_ARG | OPT_INT | OPT_SPEC | OPT_INPUT, { .off = OFFSET(reinit_filters) },
1504  "reinit filtergraph on input parameter changes", "" },
1505  { "filter_complex", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex },
1506  "create a complex filtergraph", "graph_description" },
1507  { "filter_complex_threads", HAS_ARG | OPT_INT, { &filter_complex_nbthreads },
1508  "number of threads for -filter_complex" },
1509  { "lavfi", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex },
1510  "create a complex filtergraph", "graph_description" },
1511  { "filter_complex_script", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex_script },
1512  "read complex filtergraph description from a file", "filename" },
1513  { "auto_conversion_filters", OPT_BOOL | OPT_EXPERT, { &auto_conversion_filters },
1514  "enable automatic conversion filters globally" },
1515  { "stats", OPT_BOOL, { &print_stats },
1516  "print progress report during encoding", },
1517  { "stats_period", HAS_ARG | OPT_EXPERT, { .func_arg = opt_stats_period },
1518  "set the period at which ffmpeg updates stats and -progress output", "time" },
1519  { "attach", HAS_ARG | OPT_PERFILE | OPT_EXPERT |
1520  OPT_OUTPUT, { .func_arg = opt_attach },
1521  "add an attachment to the output file", "filename" },
1522  { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC |
1523  OPT_EXPERT | OPT_INPUT, { .off = OFFSET(dump_attachment) },
1524  "extract an attachment into a file", "filename" },
1525  { "stream_loop", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_INPUT |
1526  OPT_OFFSET, { .off = OFFSET(loop) }, "set number of times input stream shall be looped", "loop count" },
1527  { "debug_ts", OPT_BOOL | OPT_EXPERT, { &debug_ts },
1528  "print timestamp debugging info" },
1529  { "max_error_rate", HAS_ARG | OPT_FLOAT, { &max_error_rate },
1530  "ratio of decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.", "maximum error rate" },
1531  { "discard", OPT_STRING | HAS_ARG | OPT_SPEC |
1532  OPT_INPUT, { .off = OFFSET(discard) },
1533  "discard", "" },
1534  { "disposition", OPT_STRING | HAS_ARG | OPT_SPEC |
1535  OPT_OUTPUT, { .off = OFFSET(disposition) },
1536  "disposition", "" },
1537  { "thread_queue_size", HAS_ARG | OPT_INT | OPT_OFFSET | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT,
1538  { .off = OFFSET(thread_queue_size) },
1539  "set the maximum number of queued packets from the demuxer" },
1540  { "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT | OPT_OFFSET, { .off = OFFSET(find_stream_info) },
1541  "read and decode the streams to fill missing information with heuristics" },
1542  { "bits_per_raw_sample", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
1543  { .off = OFFSET(bits_per_raw_sample) },
1544  "set the number of bits per raw sample", "number" },
1545 
1546  /* video options */
1547  { "vframes", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_video_frames },
1548  "set the number of video frames to output", "number" },
1549  { "r", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_SPEC |
1550  OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(frame_rates) },
1551  "set frame rate (Hz value, fraction or abbreviation)", "rate" },
1552  { "fpsmax", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_SPEC |
1553  OPT_OUTPUT, { .off = OFFSET(max_frame_rates) },
1554  "set max frame rate (Hz value, fraction or abbreviation)", "rate" },
1556  OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(frame_sizes) },
1557  "set frame size (WxH or abbreviation)", "size" },
1558  { "aspect", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_SPEC |
1559  OPT_OUTPUT, { .off = OFFSET(frame_aspect_ratios) },
1560  "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
1561  { "pix_fmt", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC |
1562  OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(frame_pix_fmts) },
1563  "set pixel format", "format" },
1564  { "display_rotation", OPT_VIDEO | HAS_ARG | OPT_DOUBLE | OPT_SPEC |
1565  OPT_INPUT, { .off = OFFSET(display_rotations) },
1566  "set pure counter-clockwise rotation in degrees for stream(s)",
1567  "angle" },
1568  { "display_hflip", OPT_VIDEO | OPT_BOOL | OPT_SPEC | OPT_INPUT, { .off = OFFSET(display_hflips) },
1569  "set display horizontal flip for stream(s) "
1570  "(overrides any display rotation if it is not set)"},
1571  { "display_vflip", OPT_VIDEO | OPT_BOOL | OPT_SPEC | OPT_INPUT, { .off = OFFSET(display_vflips) },
1572  "set display vertical flip for stream(s) "
1573  "(overrides any display rotation if it is not set)"},
1575  "disable video" },
1576  { "rc_override", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC |
1577  OPT_OUTPUT, { .off = OFFSET(rc_overrides) },
1578  "rate control override for specific intervals", "override" },
1579  { "vcodec", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_INPUT |
1580  OPT_OUTPUT, { .func_arg = opt_video_codec },
1581  "force video codec ('copy' to copy stream)", "codec" },
1582  { "timecode", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_timecode },
1583  "set initial TimeCode value.", "hh:mm:ss[:;.]ff" },
1584  { "pass", OPT_VIDEO | HAS_ARG | OPT_SPEC | OPT_INT | OPT_OUTPUT, { .off = OFFSET(pass) },
1585  "select the pass number (1 to 3)", "n" },
1586  { "passlogfile", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC |
1587  OPT_OUTPUT, { .off = OFFSET(passlogfiles) },
1588  "select two pass log file name prefix", "prefix" },
1589 #if FFMPEG_OPT_PSNR
1590  { "psnr", OPT_VIDEO | OPT_BOOL | OPT_EXPERT, { &do_psnr },
1591  "calculate PSNR of compressed frames (deprecated, use -flags +psnr)" },
1592 #endif
1593  { "vstats", OPT_VIDEO | OPT_EXPERT , { .func_arg = opt_vstats },
1594  "dump video coding statistics to file" },
1595  { "vstats_file", OPT_VIDEO | HAS_ARG | OPT_EXPERT , { .func_arg = opt_vstats_file },
1596  "dump video coding statistics to file", "file" },
1597  { "vstats_version", OPT_VIDEO | OPT_INT | HAS_ARG | OPT_EXPERT , { &vstats_version },
1598  "Version of the vstats format to use."},
1599  { "vf", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_video_filters },
1600  "set video filters", "filter_graph" },
1601  { "intra_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC |
1602  OPT_OUTPUT, { .off = OFFSET(intra_matrices) },
1603  "specify intra matrix coeffs", "matrix" },
1604  { "inter_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC |
1605  OPT_OUTPUT, { .off = OFFSET(inter_matrices) },
1606  "specify inter matrix coeffs", "matrix" },
1607  { "chroma_intra_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC |
1608  OPT_OUTPUT, { .off = OFFSET(chroma_intra_matrices) },
1609  "specify intra matrix coeffs", "matrix" },
1610  { "top", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_INT| OPT_SPEC |
1611  OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(top_field_first) },
1612  "top=1/bottom=0/auto=-1 field first", "" },
1613  { "vtag", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_PERFILE |
1614  OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_old2new },
1615  "force video tag/fourcc", "fourcc/tag" },
1616  { "qphist", OPT_VIDEO | OPT_BOOL | OPT_EXPERT , { &qp_hist },
1617  "show QP histogram" },
1618  { "fps_mode", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_EXPERT |
1619  OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(fps_mode) },
1620  "set framerate mode for matching video streams; overrides vsync" },
1621  { "force_fps", OPT_VIDEO | OPT_BOOL | OPT_EXPERT | OPT_SPEC |
1622  OPT_OUTPUT, { .off = OFFSET(force_fps) },
1623  "force the selected framerate, disable the best supported framerate selection" },
1624  { "streamid", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_PERFILE |
1625  OPT_OUTPUT, { .func_arg = opt_streamid },
1626  "set the value of an outfile streamid", "streamIndex:value" },
1627  { "force_key_frames", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
1628  OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(forced_key_frames) },
1629  "force key frames at specified timestamps", "timestamps" },
1630  { "ab", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_bitrate },
1631  "audio bitrate (please use -b:a)", "bitrate" },
1632  { "b", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_bitrate },
1633  "video bitrate (please use -b:v)", "bitrate" },
1634  { "hwaccel", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
1635  OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccels) },
1636  "use HW accelerated decoding", "hwaccel name" },
1637  { "hwaccel_device", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
1638  OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccel_devices) },
1639  "select a device for HW acceleration", "devicename" },
1640  { "hwaccel_output_format", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
1641  OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccel_output_formats) },
1642  "select output format used with HW accelerated decoding", "format" },
1643  { "hwaccels", OPT_EXIT, { .func_arg = show_hwaccels },
1644  "show available HW acceleration methods" },
1645  { "autorotate", HAS_ARG | OPT_BOOL | OPT_SPEC |
1646  OPT_EXPERT | OPT_INPUT, { .off = OFFSET(autorotate) },
1647  "automatically insert correct rotate filters" },
1648  { "autoscale", HAS_ARG | OPT_BOOL | OPT_SPEC |
1649  OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(autoscale) },
1650  "automatically insert a scale filter at the end of the filter graph" },
1651 
1652  /* audio options */
1653  { "aframes", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_frames },
1654  "set the number of audio frames to output", "number" },
1655  { "aq", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_qscale },
1656  "set audio quality (codec-specific)", "quality", },
1657  { "ar", OPT_AUDIO | HAS_ARG | OPT_INT | OPT_SPEC |
1658  OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(audio_sample_rate) },
1659  "set audio sampling rate (in Hz)", "rate" },
1660  { "ac", OPT_AUDIO | HAS_ARG | OPT_INT | OPT_SPEC |
1661  OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(audio_channels) },
1662  "set number of audio channels", "channels" },
1664  "disable audio" },
1665  { "acodec", OPT_AUDIO | HAS_ARG | OPT_PERFILE |
1666  OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_audio_codec },
1667  "force audio codec ('copy' to copy stream)", "codec" },
1668  { "atag", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_PERFILE |
1669  OPT_OUTPUT, { .func_arg = opt_old2new },
1670  "force audio tag/fourcc", "fourcc/tag" },
1671  { "sample_fmt", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_SPEC |
1673  "set sample format", "format" },
1674  { "channel_layout", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_SPEC |
1675  OPT_STRING | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(audio_ch_layouts) },
1676  "set channel layout", "layout" },
1677  { "ch_layout", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_SPEC |
1678  OPT_STRING | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(audio_ch_layouts) },
1679  "set channel layout", "layout" },
1680  { "af", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_filters },
1681  "set audio filters", "filter_graph" },
1682  { "guess_layout_max", OPT_AUDIO | HAS_ARG | OPT_INT | OPT_SPEC | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(guess_layout_max) },
1683  "set the maximum number of channels to try to guess the channel layout" },
1684 
1685  /* subtitle options */
1687  "disable subtitle" },
1688  { "scodec", OPT_SUBTITLE | HAS_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_subtitle_codec },
1689  "force subtitle codec ('copy' to copy stream)", "codec" },
1690  { "stag", OPT_SUBTITLE | HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_old2new }
1691  , "force subtitle tag/fourcc", "fourcc/tag" },
1692  { "fix_sub_duration", OPT_BOOL | OPT_EXPERT | OPT_SUBTITLE | OPT_SPEC | OPT_INPUT, { .off = OFFSET(fix_sub_duration) },
1693  "fix subtitles duration" },
1694  { "canvas_size", OPT_SUBTITLE | HAS_ARG | OPT_STRING | OPT_SPEC | OPT_INPUT, { .off = OFFSET(canvas_sizes) },
1695  "set canvas size (WxH or abbreviation)", "size" },
1696 
1697  /* muxer options */
1698  { "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(mux_max_delay) },
1699  "set the maximum demux-decode delay", "seconds" },
1700  { "muxpreload", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(mux_preload) },
1701  "set the initial demux-decode delay", "seconds" },
1702  { "sdp_file", HAS_ARG | OPT_EXPERT | OPT_OUTPUT, { .func_arg = opt_sdp_file },
1703  "specify a file in which to print sdp information", "file" },
1704 
1705  { "time_base", HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(time_bases) },
1706  "set the desired time base hint for output stream (1:24, 1:48000 or 0.04166, 2.0833e-5)", "ratio" },
1707  { "enc_time_base", HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(enc_time_bases) },
1708  "set the desired time base for the encoder (1:24, 1:48000 or 0.04166, 2.0833e-5). "
1709  "two special values are defined - "
1710  "0 = use frame rate (video) or sample rate (audio),"
1711  "-1 = match source time base", "ratio" },
1712 
1713  { "bsf", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(bitstream_filters) },
1714  "A comma-separated list of bitstream filters", "bitstream_filters" },
1715  { "absf", HAS_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_old2new },
1716  "deprecated", "audio bitstream_filters" },
1717  { "vbsf", OPT_VIDEO | HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_old2new },
1718  "deprecated", "video bitstream_filters" },
1719 
1720  { "apre", HAS_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_preset },
1721  "set the audio options to the indicated preset", "preset" },
1722  { "vpre", OPT_VIDEO | HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_preset },
1723  "set the video options to the indicated preset", "preset" },
1724  { "spre", HAS_ARG | OPT_SUBTITLE | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_preset },
1725  "set the subtitle options to the indicated preset", "preset" },
1726  { "fpre", HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_preset },
1727  "set options from indicated preset file", "filename" },
1728 
1729  { "max_muxing_queue_size", HAS_ARG | OPT_INT | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(max_muxing_queue_size) },
1730  "maximum number of packets that can be buffered while waiting for all streams to initialize", "packets" },
1731  { "muxing_queue_data_threshold", HAS_ARG | OPT_INT | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(muxing_queue_data_threshold) },
1732  "set the threshold after which max_muxing_queue_size is taken into account", "bytes" },
1733 
1734  /* data codec support */
1735  { "dcodec", HAS_ARG | OPT_DATA | OPT_PERFILE | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_data_codec },
1736  "force data codec ('copy' to copy stream)", "codec" },
1737  { "dn", OPT_BOOL | OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(data_disable) },
1738  "disable data" },
1739 
1740 #if CONFIG_VAAPI
1741  { "vaapi_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vaapi_device },
1742  "set VAAPI hardware device (DRM path or X11 display name)", "device" },
1743 #endif
1744 
1745 #if CONFIG_QSV
1746  { "qsv_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_qsv_device },
1747  "set QSV hardware device (DirectX adapter index, DRM path or X11 display name)", "device"},
1748 #endif
1749 
1750  { "init_hw_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_init_hw_device },
1751  "initialise hardware device", "args" },
1752  { "filter_hw_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_hw_device },
1753  "set hardware device used when filtering", "device" },
1754 
1755  { NULL, },
1756 };
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:1898
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:136
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:1068
show_help_default
void show_help_default(const char *opt, const char *arg)
Per-fftool specific help handler.
Definition: ffmpeg_opt.c:1133
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:307
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:1011
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:819
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:325
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:943
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:946
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:306
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
AV_DICT_IGNORE_SUFFIX
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
Definition: dict.h:75
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:133
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:1087
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:937
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:1074
OptionsContext::nb_audio_channel_maps
int nb_audio_channel_maps
Definition: ffmpeg.h:150
InputFile
Definition: ffmpeg.h:434
opt_filter_complex_script
static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1119
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:747
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:481
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
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:60
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:1101
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:387
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:316
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:925
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:759
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:1056
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:183
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:979
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:135
avcodec_find_decoder
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: allcodecs.c:951
FilterGraph
Definition: ffmpeg.h:305
opt_streamid
static int opt_streamid(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:725
opt_preset
static int opt_preset(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:963
opt_vstats_file
static int opt_vstats_file(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:902
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:1023
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
find_codec_or_die
const AVCodec * find_codec_or_die(const char *name, enum AVMediaType type, int encoder)
Definition: ffmpeg_opt.c:626
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:1205
opt_sdp_file
static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:543
OptionsContext::find_stream_info
int find_stream_info
Definition: ffmpeg.h:130
check_filter_outputs
void check_filter_outputs(void)
Definition: ffmpeg_filter.c:649
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:655
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:1039
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:437
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:909
file_read
char * file_read(const char *filename)
Definition: ffmpeg_opt.c:699
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:141
int_cb
const AVIOInterruptCB int_cb
Definition: ffmpeg.c:492
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:931
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:458
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:1080
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
diff
static av_always_inline int diff(const uint32_t a, const uint32_t b)
Definition: vf_palettegen.c:139
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:142
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:206
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:3632
InputFile::nb_streams
int nb_streams
Definition: ffmpeg.h:459
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:1557
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:480
opt_filter_complex
static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
Definition: ffmpeg_opt.c:1107
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:974
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