FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/fftools/ffmpeg_opt.c
Date: 2024-07-14 13:34:57
Exec Total Coverage
Lines: 254 696 36.5%
Functions: 24 51 47.1%
Branches: 127 384 33.1%

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