FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/fftools/ffmpeg_opt.c
Date: 2022-11-26 13:19:19
Exec Total Coverage
Lines: 307 717 42.8%
Branches: 142 392 36.2%

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