FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/fftools/ffmpeg_opt.c
Date: 2026-05-18 04:31:49
Exec Total Coverage
Lines: 366 859 42.6%
Functions: 33 62 53.2%
Branches: 206 522 39.5%

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