FFmpeg coverage


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