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