FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/fftools/ffmpeg_opt.c
Date: 2026-04-24 10:13:59
Exec Total Coverage
Lines: 366 856 42.8%
Functions: 33 62 53.2%
Branches: 206 516 39.9%

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 15989 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 3181811 times.
✓ Branch 1 taken 15989 times.
3197800 for (const OptionDef *po = options; po->name; po++) {
106 void *dst;
107
108
2/2
✓ Branch 0 taken 1662856 times.
✓ Branch 1 taken 1518955 times.
3181811 if (!(po->flags & OPT_FLAG_OFFSET))
109 1662856 continue;
110
111 1518955 dst = (uint8_t*)o + po->u.off;
112
2/2
✓ Branch 0 taken 1087252 times.
✓ Branch 1 taken 431703 times.
1518955 if (po->flags & OPT_FLAG_SPEC) {
113 1087252 SpecifierOptList *so = dst;
114
2/2
✓ Branch 0 taken 33525 times.
✓ Branch 1 taken 1087252 times.
1120777 for (int i = 0; i < so->nb_opt; i++) {
115 33525 av_freep(&so->opt[i].specifier);
116
2/2
✓ Branch 0 taken 33263 times.
✓ Branch 1 taken 262 times.
33525 if (po->flags & OPT_FLAG_PERSTREAM)
117 33263 stream_specifier_uninit(&so->opt[i].stream_spec);
118
2/2
✓ Branch 0 taken 27679 times.
✓ Branch 1 taken 5846 times.
33525 if (po->type == OPT_TYPE_STRING)
119 27679 av_freep(&so->opt[i].u.str);
120 }
121 1087252 av_freep(&so->opt);
122 1087252 so->nb_opt = 0;
123
2/2
✓ Branch 0 taken 15989 times.
✓ Branch 1 taken 415714 times.
431703 } else if (po->type == OPT_TYPE_STRING)
124 15989 av_freep(dst);
125 }
126
127
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 15989 times.
16479 for (int i = 0; i < o->nb_stream_maps; i++)
128 490 av_freep(&o->stream_maps[i].linklabel);
129 15989 av_freep(&o->stream_maps);
130
131
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15989 times.
15990 for (int i = 0; i < o->nb_attachments; i++)
132 1 av_freep(&o->attachments[i]);
133 15989 av_freep(&o->attachments);
134
135 15989 av_dict_free(&o->streamid);
136 15989 }
137
138 15989 static void init_options(OptionsContext *o)
139 {
140 15989 memset(o, 0, sizeof(*o));
141
142 15989 o->stop_time = INT64_MAX;
143 15989 o->mux_max_delay = 0.7;
144 15989 o->start_time = AV_NOPTS_VALUE;
145 15989 o->start_time_eof = AV_NOPTS_VALUE;
146 15989 o->recording_time = INT64_MAX;
147 15989 o->limit_filesize = INT64_MAX;
148 15989 o->chapters_input_file = INT_MAX;
149 15989 o->accurate_seek = 1;
150 15989 o->thread_queue_size = 0;
151 15989 o->input_sync_ref = -1;
152 15989 o->find_stream_info = 1;
153 15989 o->shortest_buf_duration = 10.f;
154 15989 }
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 38128 const char *opt_match_per_type_str(const SpecifierOptList *sol,
169 char mediatype)
170 {
171
3/4
✓ Branch 0 taken 17110 times.
✓ Branch 1 taken 21018 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17110 times.
38128 av_assert0(!sol->nb_opt || sol->type == OPT_TYPE_STRING);
172
173
2/2
✓ Branch 0 taken 17214 times.
✓ Branch 1 taken 34937 times.
52151 for (int i = 0; i < sol->nb_opt; i++) {
174 17214 const char *spec = sol->opt[i].specifier;
175
3/4
✓ Branch 0 taken 3191 times.
✓ Branch 1 taken 14023 times.
✓ Branch 2 taken 3191 times.
✗ Branch 3 not taken.
17214 if (spec[0] == mediatype && !spec[1])
176 3191 return sol->opt[i].u.str;
177 }
178 34937 return NULL;
179 }
180
181 444311 static unsigned opt_match_per_stream(void *logctx, enum OptionType type,
182 const SpecifierOptList *sol,
183 AVFormatContext *fc, AVStream *st)
184 {
185 444311 int matches = 0, match_idx = -1;
186
187
3/4
✓ Branch 0 taken 412262 times.
✓ Branch 1 taken 32049 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 412262 times.
444311 av_assert0((type == sol->type) || !sol->nb_opt);
188
189
2/2
✓ Branch 0 taken 34759 times.
✓ Branch 1 taken 444311 times.
479070 for (int i = 0; i < sol->nb_opt; i++) {
190 34759 const StreamSpecifier *ss = &sol->opt[i].stream_spec;
191
192
2/2
✓ Branch 1 taken 34289 times.
✓ Branch 2 taken 470 times.
34759 if (stream_specifier_match(ss, fc, st, logctx)) {
193 34289 match_idx = i;
194 34289 matches++;
195 }
196 }
197
198
3/4
✓ Branch 0 taken 2398 times.
✓ Branch 1 taken 441913 times.
✓ Branch 2 taken 2398 times.
✗ Branch 3 not taken.
444311 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 444311 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 28461 times.
✓ Branch 2 taken 253142 times.
281603 OPT_MATCH_PER_STREAM(str, const char *, OPT_TYPE_STRING, str);
241
2/2
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 130370 times.
130424 OPT_MATCH_PER_STREAM(int, int, OPT_TYPE_INT, i);
242
2/2
✓ Branch 1 taken 3102 times.
✓ Branch 2 taken 5944 times.
9046 OPT_MATCH_PER_STREAM(int64, int64_t, OPT_TYPE_INT64, i64);
243
2/2
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 22964 times.
23238 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 395 int view_specifier_parse(const char **pspec, ViewSpecifier *vs)
310 {
311 395 const char *spec = *pspec;
312 char *endptr;
313
314 395 vs->type = VIEW_SPECIFIER_TYPE_NONE;
315
316
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 386 times.
395 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 383 times.
386 } 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 381 times.
383 } 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 381 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 8536 static void correct_input_start_times(void)
399 {
400
2/2
✓ Branch 0 taken 7447 times.
✓ Branch 1 taken 8536 times.
15983 for (int i = 0; i < nb_input_files; i++) {
401 7447 InputFile *ifile = input_files[i];
402 7447 AVFormatContext *is = ifile->ctx;
403 7447 int64_t new_start_time = INT64_MAX, diff, abs_start_seek;
404
405 7447 ifile->start_time_effective = is->start_time;
406
407
2/2
✓ Branch 0 taken 5708 times.
✓ Branch 1 taken 1739 times.
7447 if (is->start_time == AV_NOPTS_VALUE ||
408
2/2
✓ Branch 0 taken 5589 times.
✓ Branch 1 taken 119 times.
5708 !(is->iformat->flags & AVFMT_TS_DISCONT))
409 7328 continue;
410
411
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 119 times.
297 for (int j = 0; j < is->nb_streams; j++) {
412 178 AVStream *st = is->streams[j];
413
3/4
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 134 times.
178 if(st->discard == AVDISCARD_ALL || st->start_time == AV_NOPTS_VALUE)
414 44 continue;
415
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 3 times.
134 new_start_time = FFMIN(new_start_time, av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q));
416 }
417
418 119 diff = new_start_time - is->start_time;
419
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 115 times.
119 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 8536 }
434
435 8536 static int apply_sync_offsets(void)
436 {
437
2/2
✓ Branch 0 taken 7447 times.
✓ Branch 1 taken 8536 times.
15983 for (int i = 0; i < nb_input_files; i++) {
438 7447 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 7447 int start_times_set = 1;
442
443
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7447 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7447 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 8536 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 324 static int opt_map(void *optctx, const char *opt, const char *arg)
556 {
557 324 OptionsContext *o = optctx;
558 324 StreamMap *m = NULL;
559 StreamSpecifier ss;
560 324 int i, negative = 0, file_idx, disabled = 0;
561 324 int ret, allow_unused = 0;
562
563 324 memset(&ss, 0, sizeof(ss));
564
565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 324 times.
324 if (*arg == '-') {
566 negative = 1;
567 arg++;
568 }
569
570
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 242 times.
324 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 242 file_idx = strtol(arg, &endptr, 0);
613
2/4
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 242 times.
242 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 242 arg = endptr;
619
620
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 125 times.
242 ret = stream_specifier_parse(&ss, *arg == ':' ? arg + 1 : arg, 1, NULL);
621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 242 times.
242 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 228 times.
242 arg = ss.remainder ? ss.remainder : "";
627
628 242 ret = view_specifier_parse(&arg, &vs);
629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 242 times.
242 if (ret < 0)
630 goto fail;
631
632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 242 times.
242 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 242 times.
242 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 stream_specifier_match(&ss,
649 input_files[m->file_index]->ctx,
650 input_files[m->file_index]->ctx->streams[m->stream_index],
651 NULL))
652 m->disabled = 1;
653 }
654 else
655
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 242 times.
810 for (i = 0; i < input_files[file_idx]->nb_streams; i++) {
656
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 408 times.
568 if (!stream_specifier_match(&ss,
657 568 input_files[file_idx]->ctx,
658 568 input_files[file_idx]->ctx->streams[i],
659 NULL))
660 160 continue;
661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if (input_files[file_idx]->streams[i]->user_set_discard == AVDISCARD_ALL) {
662 disabled = 1;
663 continue;
664 }
665 408 ret = GROW_ARRAY(o->stream_maps, o->nb_stream_maps);
666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if (ret < 0)
667 goto fail;
668
669 408 m = &o->stream_maps[o->nb_stream_maps - 1];
670
671 408 m->file_index = file_idx;
672 408 m->stream_index = i;
673
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 399 times.
408 m->group_index = ss.stream_list == STREAM_LIST_GROUP_IDX ? ss.list_id : -1;
674 408 m->vs = vs;
675 }
676 }
677
678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243 times.
243 if (!m) {
679 if (allow_unused) {
680 av_log(NULL, AV_LOG_VERBOSE, "Stream map '%s' matches no streams; ignoring.\n", arg);
681 } else if (disabled) {
682 av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches disabled streams.\n"
683 "To ignore this, add a trailing '?' to the map.\n", arg);
684 ret = AVERROR(EINVAL);
685 goto fail;
686 } else {
687 av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n"
688 "To ignore this, add a trailing '?' to the map.\n", arg);
689 ret = AVERROR(EINVAL);
690 goto fail;
691 }
692 }
693 243 end:
694 324 ret = 0;
695 324 fail:
696 324 stream_specifier_uninit(&ss);
697 324 return ret;
698 }
699
700 1 static int opt_attach(void *optctx, const char *opt, const char *arg)
701 {
702 1 OptionsContext *o = optctx;
703 1 int ret = GROW_ARRAY(o->attachments, o->nb_attachments);
704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (ret < 0)
705 return ret;
706
707 1 o->attachments[o->nb_attachments - 1] = av_strdup(arg);
708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!o->attachments[o->nb_attachments - 1])
709 return AVERROR(ENOMEM);
710
711 1 return 0;
712 }
713
714 static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
715 {
716 GlobalOptionsContext *go = optctx;
717 return sch_sdp_filename(go->sch, arg);
718 }
719
720 #if CONFIG_VAAPI
721 static int opt_vaapi_device(void *optctx, const char *opt, const char *arg)
722 {
723 const char *prefix = "vaapi:";
724 char *tmp;
725 int err;
726 tmp = av_asprintf("%s%s", prefix, arg);
727 if (!tmp)
728 return AVERROR(ENOMEM);
729 err = hw_device_init_from_string(tmp, NULL);
730 av_free(tmp);
731 return err;
732 }
733 #endif
734
735 #if CONFIG_QSV
736 static int opt_qsv_device(void *optctx, const char *opt, const char *arg)
737 {
738 const char *prefix = "qsv=__qsv_device:hw_any,child_device=";
739 int err;
740 char *tmp = av_asprintf("%s%s", prefix, arg);
741
742 if (!tmp)
743 return AVERROR(ENOMEM);
744
745 err = hw_device_init_from_string(tmp, NULL);
746 av_free(tmp);
747
748 return err;
749 }
750 #endif
751
752 static int opt_init_hw_device(void *optctx, const char *opt, const char *arg)
753 {
754 if (!strcmp(arg, "list")) {
755 enum AVHWDeviceType type = AV_HWDEVICE_TYPE_NONE;
756 printf("Supported hardware device types:\n");
757 while ((type = av_hwdevice_iterate_types(type)) !=
758 AV_HWDEVICE_TYPE_NONE)
759 printf("%s\n", av_hwdevice_get_type_name(type));
760 printf("\n");
761 return AVERROR_EXIT;
762 } else {
763 return hw_device_init_from_string(arg, NULL);
764 }
765 }
766
767 static int opt_filter_hw_device(void *optctx, const char *opt, const char *arg)
768 {
769 if (filter_hw_device) {
770 av_log(NULL, AV_LOG_ERROR, "Only one filter device can be used.\n");
771 return AVERROR(EINVAL);
772 }
773 filter_hw_device = hw_device_get_by_name(arg);
774 if (!filter_hw_device) {
775 av_log(NULL, AV_LOG_ERROR, "Invalid filter device %s.\n", arg);
776 return AVERROR(EINVAL);
777 }
778 return 0;
779 }
780
781 static int opt_recording_timestamp(void *optctx, const char *opt, const char *arg)
782 {
783 OptionsContext *o = optctx;
784 char buf[128];
785 int64_t recording_timestamp;
786 int ret;
787 struct tm time;
788
789 ret = av_parse_time(&recording_timestamp, arg, 0);
790 if (ret < 0)
791 return ret;
792
793 recording_timestamp /= 1e6;
794 time = *gmtime((time_t*)&recording_timestamp);
795 if (!strftime(buf, sizeof(buf), "creation_time=%Y-%m-%dT%H:%M:%S%z", &time))
796 return -1;
797 parse_option(o, "metadata", buf, options);
798
799 av_log(NULL, AV_LOG_WARNING, "%s is deprecated, set the 'creation_time' metadata "
800 "tag instead.\n", opt);
801 return 0;
802 }
803
804 13649 int find_codec(void *logctx, const char *name,
805 enum AVMediaType type, int encoder, const AVCodec **pcodec)
806 {
807 const AVCodecDescriptor *desc;
808
2/2
✓ Branch 0 taken 4092 times.
✓ Branch 1 taken 9557 times.
13649 const char *codec_string = encoder ? "encoder" : "decoder";
809 const AVCodec *codec;
810
811 13649 codec = encoder ?
812
2/2
✓ Branch 0 taken 4092 times.
✓ Branch 1 taken 9557 times.
13649 avcodec_find_encoder_by_name(name) :
813 9557 avcodec_find_decoder_by_name(name);
814
815
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13648 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
13649 if (!codec && (desc = avcodec_descriptor_get_by_name(name))) {
816
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 codec = encoder ? avcodec_find_encoder(desc->id) :
817 avcodec_find_decoder(desc->id);
818
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (codec)
819 1 av_log(logctx, AV_LOG_VERBOSE, "Matched %s '%s' for codec '%s'.\n",
820 1 codec_string, codec->name, desc->name);
821 }
822
823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13649 times.
13649 if (!codec) {
824 av_log(logctx, AV_LOG_FATAL, "Unknown %s '%s'\n", codec_string, name);
825 return encoder ? AVERROR_ENCODER_NOT_FOUND :
826 AVERROR_DECODER_NOT_FOUND;
827 }
828
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13649 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13649 if (codec->type != type && !recast_media) {
829 av_log(logctx, AV_LOG_FATAL, "Invalid %s type '%s'\n", codec_string, name);
830 return AVERROR(EINVAL);
831 }
832
833 13649 *pcodec = codec;
834 13649 return 0;;
835 }
836
837 8444 int assert_file_overwrite(const char *filename)
838 {
839 8444 const char *proto_name = avio_find_protocol_name(filename);
840
841
3/4
✓ Branch 0 taken 3068 times.
✓ Branch 1 taken 5376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3068 times.
8444 if (file_overwrite && no_file_overwrite) {
842 fprintf(stderr, "Error, both -y and -n supplied. Exiting.\n");
843 return AVERROR(EINVAL);
844 }
845
846
2/2
✓ Branch 0 taken 5376 times.
✓ Branch 1 taken 3068 times.
8444 if (!file_overwrite) {
847
2/6
✓ Branch 0 taken 5376 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5376 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
5376 if (proto_name && !strcmp(proto_name, "file") && avio_check(filename, 0) == 0) {
848 if (stdin_interaction && !no_file_overwrite) {
849 fprintf(stderr,"File '%s' already exists. Overwrite? [y/N] ", filename);
850 fflush(stderr);
851 term_exit();
852 signal(SIGINT, SIG_DFL);
853 if (!read_yesno()) {
854 av_log(NULL, AV_LOG_FATAL, "Not overwriting - exiting\n");
855 return AVERROR_EXIT;
856 }
857 term_init();
858 }
859 else {
860 av_log(NULL, AV_LOG_FATAL, "File '%s' already exists. Exiting.\n", filename);
861 return AVERROR_EXIT;
862 }
863 }
864 }
865
866
3/4
✓ Branch 0 taken 8444 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2918 times.
✓ Branch 3 taken 5526 times.
8444 if (proto_name && !strcmp(proto_name, "file")) {
867
2/2
✓ Branch 0 taken 1865 times.
✓ Branch 1 taken 2918 times.
4783 for (int i = 0; i < nb_input_files; i++) {
868 1865 InputFile *file = input_files[i];
869
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1760 times.
1865 if (file->ctx->iformat->flags & AVFMT_NOFILE)
870 105 continue;
871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1760 times.
1760 if (!strcmp(filename, file->ctx->url)) {
872 av_log(NULL, AV_LOG_FATAL, "Output %s same as Input #%d - exiting\n", filename, i);
873 av_log(NULL, AV_LOG_WARNING, "FFmpeg cannot edit existing files in-place.\n");
874 return AVERROR(EINVAL);
875 }
876 }
877 }
878
879 8444 return 0;
880 }
881
882 /* arg format is "output-stream-index:streamid-value". */
883 67 static int opt_streamid(void *optctx, const char *opt, const char *arg)
884 {
885 67 OptionsContext *o = optctx;
886 char *p;
887 char idx_str[16];
888
889 67 av_strlcpy(idx_str, arg, sizeof(idx_str));
890 67 p = strchr(idx_str, ':');
891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if (!p) {
892 av_log(NULL, AV_LOG_FATAL,
893 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
894 arg, opt);
895 return AVERROR(EINVAL);
896 }
897 67 *p++ = '\0';
898
899 67 return av_dict_set(&o->streamid, idx_str, p, 0);
900 }
901
902 static int opt_target(void *optctx, const char *opt, const char *arg)
903 {
904 OptionsContext *o = optctx;
905 enum { PAL, NTSC, FILM, UNKNOWN } norm = UNKNOWN;
906 static const char *const frame_rates[] = { "25", "30000/1001", "24000/1001" };
907
908 if (!strncmp(arg, "pal-", 4)) {
909 norm = PAL;
910 arg += 4;
911 } else if (!strncmp(arg, "ntsc-", 5)) {
912 norm = NTSC;
913 arg += 5;
914 } else if (!strncmp(arg, "film-", 5)) {
915 norm = FILM;
916 arg += 5;
917 } else {
918 /* Try to determine PAL/NTSC by peeking in the input files */
919 if (nb_input_files) {
920 int i, j;
921 for (j = 0; j < nb_input_files; j++) {
922 for (i = 0; i < input_files[j]->nb_streams; i++) {
923 AVStream *st = input_files[j]->ctx->streams[i];
924 int64_t fr;
925 if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
926 continue;
927 fr = st->time_base.den * 1000LL / st->time_base.num;
928 if (fr == 25000) {
929 norm = PAL;
930 break;
931 } else if ((fr == 29970) || (fr == 23976)) {
932 norm = NTSC;
933 break;
934 }
935 }
936 if (norm != UNKNOWN)
937 break;
938 }
939 }
940 if (norm != UNKNOWN)
941 av_log(NULL, AV_LOG_INFO, "Assuming %s for target.\n", norm == PAL ? "PAL" : "NTSC");
942 }
943
944 if (norm == UNKNOWN) {
945 av_log(NULL, AV_LOG_FATAL, "Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
946 av_log(NULL, AV_LOG_FATAL, "Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
947 av_log(NULL, AV_LOG_FATAL, "or set a framerate with \"-r xxx\".\n");
948 return AVERROR(EINVAL);
949 }
950
951 if (!strcmp(arg, "vcd")) {
952 opt_video_codec(o, "c:v", "mpeg1video");
953 opt_audio_codec(o, "c:a", "mp2");
954 parse_option(o, "f", "vcd", options);
955
956 parse_option(o, "s", norm == PAL ? "352x288" : "352x240", options);
957 parse_option(o, "r", frame_rates[norm], options);
958 opt_default(NULL, "g", norm == PAL ? "15" : "18");
959
960 opt_default(NULL, "b:v", "1150000");
961 opt_default(NULL, "maxrate:v", "1150000");
962 opt_default(NULL, "minrate:v", "1150000");
963 opt_default(NULL, "bufsize:v", "327680"); // 40*1024*8;
964
965 opt_default(NULL, "b:a", "224000");
966 parse_option(o, "ar", "44100", options);
967 parse_option(o, "ac", "2", options);
968
969 opt_default(NULL, "packetsize", "2324");
970 opt_default(NULL, "muxrate", "1411200"); // 2352 * 75 * 8;
971
972 /* We have to offset the PTS, so that it is consistent with the SCR.
973 SCR starts at 36000, but the first two packs contain only padding
974 and the first pack from the other stream, respectively, may also have
975 been written before.
976 So the real data starts at SCR 36000+3*1200. */
977 o->mux_preload = (36000 + 3 * 1200) / 90000.0; // 0.44
978 } else if (!strcmp(arg, "svcd")) {
979
980 opt_video_codec(o, "c:v", "mpeg2video");
981 opt_audio_codec(o, "c:a", "mp2");
982 parse_option(o, "f", "svcd", options);
983
984 parse_option(o, "s", norm == PAL ? "480x576" : "480x480", options);
985 parse_option(o, "r", frame_rates[norm], options);
986 parse_option(o, "pix_fmt", "yuv420p", options);
987 opt_default(NULL, "g", norm == PAL ? "15" : "18");
988
989 opt_default(NULL, "b:v", "2040000");
990 opt_default(NULL, "maxrate:v", "2516000");
991 opt_default(NULL, "minrate:v", "0"); // 1145000;
992 opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;
993 opt_default(NULL, "scan_offset", "1");
994
995 opt_default(NULL, "b:a", "224000");
996 parse_option(o, "ar", "44100", options);
997
998 opt_default(NULL, "packetsize", "2324");
999
1000 } else if (!strcmp(arg, "dvd")) {
1001
1002 opt_video_codec(o, "c:v", "mpeg2video");
1003 opt_audio_codec(o, "c:a", "ac3");
1004 parse_option(o, "f", "dvd", options);
1005
1006 parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
1007 parse_option(o, "r", frame_rates[norm], options);
1008 parse_option(o, "pix_fmt", "yuv420p", options);
1009 opt_default(NULL, "g", norm == PAL ? "15" : "18");
1010
1011 opt_default(NULL, "b:v", "6000000");
1012 opt_default(NULL, "maxrate:v", "9000000");
1013 opt_default(NULL, "minrate:v", "0"); // 1500000;
1014 opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;
1015
1016 opt_default(NULL, "packetsize", "2048"); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
1017 opt_default(NULL, "muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8
1018
1019 opt_default(NULL, "b:a", "448000");
1020 parse_option(o, "ar", "48000", options);
1021
1022 } else if (!strncmp(arg, "dv", 2)) {
1023
1024 parse_option(o, "f", "dv", options);
1025
1026 parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
1027 parse_option(o, "pix_fmt", !strncmp(arg, "dv50", 4) ? "yuv422p" :
1028 norm == PAL ? "yuv420p" : "yuv411p", options);
1029 parse_option(o, "r", frame_rates[norm], options);
1030
1031 parse_option(o, "ar", "48000", options);
1032 parse_option(o, "ac", "2", options);
1033
1034 } else {
1035 av_log(NULL, AV_LOG_ERROR, "Unknown target: %s\n", arg);
1036 return AVERROR(EINVAL);
1037 }
1038
1039 av_dict_copy(&o->g->codec_opts, codec_opts, AV_DICT_DONT_OVERWRITE);
1040 av_dict_copy(&o->g->format_opts, format_opts, AV_DICT_DONT_OVERWRITE);
1041
1042 return 0;
1043 }
1044
1045 static int opt_vstats_file(void *optctx, const char *opt, const char *arg)
1046 {
1047 av_free (vstats_filename);
1048 vstats_filename = av_strdup (arg);
1049 return 0;
1050 }
1051
1052 static int opt_vstats(void *optctx, const char *opt, const char *arg)
1053 {
1054 char filename[40];
1055 time_t today2 = time(NULL);
1056 struct tm *today = localtime(&today2);
1057
1058 if (!today) { // maybe tomorrow
1059 av_log(NULL, AV_LOG_FATAL, "Unable to get current time: %s\n", strerror(errno));
1060 return AVERROR(errno);
1061 }
1062
1063 snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
1064 today->tm_sec);
1065 return opt_vstats_file(NULL, opt, filename);
1066 }
1067
1068 static int opt_video_frames(void *optctx, const char *opt, const char *arg)
1069 {
1070 OptionsContext *o = optctx;
1071 return parse_option(o, "frames:v", arg, options);
1072 }
1073
1074 static int opt_audio_frames(void *optctx, const char *opt, const char *arg)
1075 {
1076 OptionsContext *o = optctx;
1077 return parse_option(o, "frames:a", arg, options);
1078 }
1079
1080 static int opt_data_frames(void *optctx, const char *opt, const char *arg)
1081 {
1082 OptionsContext *o = optctx;
1083 return parse_option(o, "frames:d", arg, options);
1084 }
1085
1086 static int opt_default_new(OptionsContext *o, const char *opt, const char *arg)
1087 {
1088 int ret;
1089 AVDictionary *cbak = codec_opts;
1090 AVDictionary *fbak = format_opts;
1091 codec_opts = NULL;
1092 format_opts = NULL;
1093
1094 ret = opt_default(NULL, opt, arg);
1095
1096 av_dict_copy(&o->g->codec_opts , codec_opts, 0);
1097 av_dict_copy(&o->g->format_opts, format_opts, 0);
1098 av_dict_free(&codec_opts);
1099 av_dict_free(&format_opts);
1100 codec_opts = cbak;
1101 format_opts = fbak;
1102
1103 return ret;
1104 }
1105
1106 static int opt_preset(void *optctx, const char *opt, const char *arg)
1107 {
1108 OptionsContext *o = optctx;
1109 FILE *f=NULL;
1110 char filename[1000], line[1000], tmp_line[1000];
1111 const char *codec_name = NULL;
1112 int ret = 0;
1113 int depth = o->depth;
1114
1115 if (depth > 2) {
1116 av_log(NULL, AV_LOG_ERROR, "too deep recursion\n");
1117 return AVERROR(EINVAL);
1118 }
1119
1120 codec_name = opt_match_per_type_str(&o->codec_names, *opt);
1121
1122 if (!(f = get_preset_file(filename, sizeof(filename), arg, *opt == 'f', codec_name))) {
1123 if(!strncmp(arg, "libx264-lossless", strlen("libx264-lossless"))){
1124 av_log(NULL, AV_LOG_FATAL, "Please use -preset <speed> -qp 0\n");
1125 }else
1126 av_log(NULL, AV_LOG_FATAL, "File for preset '%s' not found\n", arg);
1127 return AVERROR(ENOENT);
1128 }
1129
1130 o->depth ++;
1131 while (fgets(line, sizeof(line), f)) {
1132 char *key = tmp_line, *value, *endptr;
1133
1134 if (strcspn(line, "#\n\r") == 0)
1135 continue;
1136 av_strlcpy(tmp_line, line, sizeof(tmp_line));
1137 if (!av_strtok(key, "=", &value) ||
1138 !av_strtok(value, "\r\n", &endptr)) {
1139 av_log(NULL, AV_LOG_FATAL, "%s: Invalid syntax: '%s'\n", filename, line);
1140 ret = AVERROR(EINVAL);
1141 goto fail;
1142 }
1143 av_log(NULL, AV_LOG_DEBUG, "ffpreset[%s]: set '%s' = '%s'\n", filename, key, value);
1144
1145 if (!strcmp(key, "acodec")) opt_audio_codec (o, key, value);
1146 else if (!strcmp(key, "vcodec")) opt_video_codec (o, key, value);
1147 else if (!strcmp(key, "scodec")) opt_subtitle_codec(o, key, value);
1148 else if (!strcmp(key, "dcodec")) opt_data_codec (o, key, value);
1149 else if ((parse_option(o, key, value, options) < 0) &&
1150 (opt_default_new(o, key, value) < 0)) {
1151 av_log(NULL, AV_LOG_FATAL, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n",
1152 filename, line, key, value);
1153 ret = AVERROR(EINVAL);
1154 goto fail;
1155 }
1156 }
1157
1158 fail:
1159 o->depth = depth;
1160 fclose(f);
1161
1162 return ret;
1163 }
1164
1165 static int opt_old2new(void *optctx, const char *opt, const char *arg)
1166 {
1167 OptionsContext *o = optctx;
1168 int ret;
1169 char *s = av_asprintf("%s:%c", opt + 1, *opt);
1170 if (!s)
1171 return AVERROR(ENOMEM);
1172 ret = parse_option(o, s, arg, options);
1173 av_free(s);
1174 return ret;
1175 }
1176
1177 175 static int opt_bitrate(void *optctx, const char *opt, const char *arg)
1178 {
1179 175 OptionsContext *o = optctx;
1180
1181
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 173 times.
175 if(!strcmp(opt, "ab")){
1182 2 av_dict_set(&o->g->codec_opts, "b:a", arg, 0);
1183 2 return 0;
1184
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 130 times.
173 } else if(!strcmp(opt, "b")){
1185 43 av_log(NULL, AV_LOG_WARNING, "Please use -b:a or -b:v, -b is ambiguous\n");
1186 43 av_dict_set(&o->g->codec_opts, "b:v", arg, 0);
1187 43 return 0;
1188 }
1189 130 av_dict_set(&o->g->codec_opts, opt, arg, 0);
1190 130 return 0;
1191 }
1192
1193 295 static int opt_qscale(void *optctx, const char *opt, const char *arg)
1194 {
1195 295 OptionsContext *o = optctx;
1196 char *s;
1197 int ret;
1198
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 42 times.
295 if(!strcmp(opt, "qscale")){
1199 253 av_log(NULL, AV_LOG_WARNING, "Please use -q:a or -q:v, -qscale is ambiguous\n");
1200 253 return parse_option(o, "q:v", arg, options);
1201 }
1202 42 s = av_asprintf("q%s", opt + 6);
1203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if (!s)
1204 return AVERROR(ENOMEM);
1205 42 ret = parse_option(o, s, arg, options);
1206 42 av_free(s);
1207 42 return ret;
1208 }
1209
1210 45 static int opt_profile(void *optctx, const char *opt, const char *arg)
1211 {
1212 45 OptionsContext *o = optctx;
1213
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 40 times.
45 if(!strcmp(opt, "profile")){
1214 5 av_log(NULL, AV_LOG_WARNING, "Please use -profile:a or -profile:v, -profile is ambiguous\n");
1215 5 av_dict_set(&o->g->codec_opts, "profile:v", arg, 0);
1216 5 return 0;
1217 }
1218 40 av_dict_set(&o->g->codec_opts, opt, arg, 0);
1219 40 return 0;
1220 }
1221
1222 3322 static int opt_video_filters(void *optctx, const char *opt, const char *arg)
1223 {
1224 3322 OptionsContext *o = optctx;
1225 3322 return parse_option(o, "filter:v", arg, options);
1226 }
1227
1228 581 static int opt_audio_filters(void *optctx, const char *opt, const char *arg)
1229 {
1230 581 OptionsContext *o = optctx;
1231 581 return parse_option(o, "filter:a", arg, options);
1232 }
1233
1234 #if FFMPEG_OPT_VSYNC
1235 static int opt_vsync(void *optctx, const char *opt, const char *arg)
1236 {
1237 av_log(NULL, AV_LOG_WARNING, "-vsync is deprecated. Use -fps_mode\n");
1238 return parse_and_set_vsync(arg, &video_sync_method, -1, -1, 1);
1239 }
1240 #endif
1241
1242 15 static int opt_timecode(void *optctx, const char *opt, const char *arg)
1243 {
1244 15 OptionsContext *o = optctx;
1245 int ret;
1246 15 char *tcr = av_asprintf("timecode=%s", arg);
1247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if (!tcr)
1248 return AVERROR(ENOMEM);
1249 15 ret = parse_option(o, "metadata:g", tcr, options);
1250
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if (ret >= 0)
1251 15 ret = av_dict_set(&o->g->codec_opts, "gop_timecode", arg, 0);
1252 15 av_free(tcr);
1253 15 return ret;
1254 }
1255
1256 static int opt_audio_qscale(void *optctx, const char *opt, const char *arg)
1257 {
1258 OptionsContext *o = optctx;
1259 return parse_option(o, "q:a", arg, options);
1260 }
1261
1262 1257 static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
1263 {
1264 1257 GlobalOptionsContext *go = optctx;
1265 char *graph_desc;
1266 int ret;
1267
1268 1257 graph_desc = av_strdup(arg);
1269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
1257 if (!graph_desc)
1270 return AVERROR(ENOMEM);
1271
1272 1257 ret = GROW_ARRAY(go->filtergraphs, go->nb_filtergraphs);
1273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
1257 if (ret < 0) {
1274 av_freep(&graph_desc);
1275 return ret;
1276 }
1277 1257 go->filtergraphs[go->nb_filtergraphs - 1] = graph_desc;
1278
1279 1257 return 0;
1280 }
1281
1282 #if FFMPEG_OPT_FILTER_SCRIPT
1283 static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
1284 {
1285 GlobalOptionsContext *go = optctx;
1286 char *graph_desc;
1287 int ret;
1288
1289 graph_desc = read_file_to_string(arg);
1290 if (!graph_desc)
1291 return AVERROR(EINVAL);
1292
1293 av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -/filter_complex %s instead\n",
1294 opt, arg);
1295
1296 ret = GROW_ARRAY(go->filtergraphs, go->nb_filtergraphs);
1297 if (ret < 0) {
1298 av_freep(&graph_desc);
1299 return ret;
1300 }
1301 go->filtergraphs[go->nb_filtergraphs - 1] = graph_desc;
1302
1303 return 0;
1304 }
1305 #endif
1306
1307 void show_help_default(const char *opt, const char *arg)
1308 {
1309 int show_advanced = 0, show_avoptions = 0;
1310
1311 if (opt && *opt) {
1312 if (!strcmp(opt, "long"))
1313 show_advanced = 1;
1314 else if (!strcmp(opt, "full"))
1315 show_advanced = show_avoptions = 1;
1316 else
1317 av_log(NULL, AV_LOG_ERROR, "Unknown help option '%s'.\n", opt);
1318 }
1319
1320 show_usage();
1321
1322 printf("Getting help:\n"
1323 " -h -- print basic options\n"
1324 " -h long -- print more options\n"
1325 " -h full -- print all options (including all format and codec specific options, very long)\n"
1326 " -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf/protocol\n"
1327 " See man %s for detailed description of the options.\n"
1328 "\n"
1329 "Per-stream options can be followed by :<stream_spec> to apply that option to specific streams only. "
1330 "<stream_spec> can be a stream index, or v/a/s for video/audio/subtitle (see manual for full syntax).\n"
1331 "\n", program_name);
1332
1333 show_help_options(options, "Print help / information / capabilities:",
1334 OPT_EXIT, OPT_EXPERT);
1335 if (show_advanced)
1336 show_help_options(options, "Advanced information / capabilities:",
1337 OPT_EXIT | OPT_EXPERT, 0);
1338
1339 show_help_options(options, "Global options (affect whole program "
1340 "instead of just one file):",
1341 0, OPT_PERFILE | OPT_EXIT | OPT_EXPERT);
1342 if (show_advanced)
1343 show_help_options(options, "Advanced global options:", OPT_EXPERT,
1344 OPT_PERFILE | OPT_EXIT);
1345
1346 show_help_options(options, "Per-file options (input and output):",
1347 OPT_PERFILE | OPT_INPUT | OPT_OUTPUT,
1348 OPT_EXIT | OPT_FLAG_PERSTREAM | OPT_EXPERT |
1349 OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
1350 if (show_advanced)
1351 show_help_options(options, "Advanced per-file options (input and output):",
1352 OPT_PERFILE | OPT_INPUT | OPT_OUTPUT | OPT_EXPERT,
1353 OPT_EXIT | OPT_FLAG_PERSTREAM |
1354 OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
1355
1356 show_help_options(options, "Per-file options (input-only):",
1357 OPT_PERFILE | OPT_INPUT,
1358 OPT_EXIT | OPT_FLAG_PERSTREAM | OPT_OUTPUT | OPT_EXPERT |
1359 OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
1360 if (show_advanced)
1361 show_help_options(options, "Advanced per-file options (input-only):",
1362 OPT_PERFILE | OPT_INPUT | OPT_EXPERT,
1363 OPT_EXIT | OPT_FLAG_PERSTREAM | OPT_OUTPUT |
1364 OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
1365
1366 show_help_options(options, "Per-file options (output-only):",
1367 OPT_PERFILE | OPT_OUTPUT,
1368 OPT_EXIT | OPT_FLAG_PERSTREAM | OPT_INPUT | OPT_EXPERT |
1369 OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
1370 if (show_advanced)
1371 show_help_options(options, "Advanced per-file options (output-only):",
1372 OPT_PERFILE | OPT_OUTPUT | OPT_EXPERT,
1373 OPT_EXIT | OPT_FLAG_PERSTREAM | OPT_INPUT |
1374 OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
1375
1376 show_help_options(options, "Per-stream options:",
1377 OPT_FLAG_PERSTREAM,
1378 OPT_EXIT | OPT_EXPERT |
1379 OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
1380 if (show_advanced)
1381 show_help_options(options, "Advanced per-stream options:",
1382 OPT_FLAG_PERSTREAM | OPT_EXPERT,
1383 OPT_EXIT |
1384 OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
1385
1386 show_help_options(options, "Video options:",
1387 OPT_VIDEO, OPT_EXPERT | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
1388 if (show_advanced)
1389 show_help_options(options, "Advanced Video options:",
1390 OPT_EXPERT | OPT_VIDEO, OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
1391
1392 show_help_options(options, "Audio options:",
1393 OPT_AUDIO, OPT_EXPERT | OPT_VIDEO | OPT_SUBTITLE | OPT_DATA);
1394 if (show_advanced)
1395 show_help_options(options, "Advanced Audio options:",
1396 OPT_EXPERT | OPT_AUDIO, OPT_VIDEO | OPT_SUBTITLE | OPT_DATA);
1397
1398 show_help_options(options, "Subtitle options:",
1399 OPT_SUBTITLE, OPT_EXPERT | OPT_VIDEO | OPT_AUDIO | OPT_DATA);
1400 if (show_advanced)
1401 show_help_options(options, "Advanced Subtitle options:",
1402 OPT_EXPERT | OPT_SUBTITLE, OPT_VIDEO | OPT_AUDIO | OPT_DATA);
1403
1404 if (show_advanced)
1405 show_help_options(options, "Data stream options:",
1406 OPT_DATA, OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE);
1407 printf("\n");
1408
1409 if (show_avoptions) {
1410 int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;
1411 show_help_children(avcodec_get_class(), flags);
1412 show_help_children(avformat_get_class(), flags);
1413 #if CONFIG_SWSCALE
1414 show_help_children(sws_get_class(), flags);
1415 #endif
1416 #if CONFIG_SWRESAMPLE
1417 show_help_children(swr_get_class(), AV_OPT_FLAG_AUDIO_PARAM);
1418 #endif
1419 show_help_children(avfilter_get_class(), AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM);
1420 show_help_children(av_bsf_get_class(), AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_BSF_PARAM);
1421 }
1422 }
1423
1424 void show_usage(void)
1425 {
1426 av_log(NULL, AV_LOG_INFO, "Universal media converter\n");
1427 av_log(NULL, AV_LOG_INFO, "usage: %s [options] [[infile options] -i infile]... {[outfile options] outfile}...\n", program_name);
1428 av_log(NULL, AV_LOG_INFO, "\n");
1429 }
1430
1431 enum OptGroup {
1432 GROUP_OUTFILE,
1433 GROUP_INFILE,
1434 GROUP_DECODER,
1435 };
1436
1437 static const OptionGroupDef groups[] = {
1438 [GROUP_OUTFILE] = { "output url", NULL, OPT_OUTPUT },
1439 [GROUP_INFILE] = { "input url", "i", OPT_INPUT },
1440 [GROUP_DECODER] = { "loopback decoder", "dec", OPT_DECODER },
1441 };
1442
1443 25609 static int open_files(OptionGroupList *l, const char *inout, Scheduler *sch,
1444 int (*open_file)(const OptionsContext*, const char*,
1445 Scheduler*))
1446 {
1447 int i, ret;
1448
1449
2/2
✓ Branch 0 taken 15989 times.
✓ Branch 1 taken 25608 times.
41597 for (i = 0; i < l->nb_groups; i++) {
1450 15989 OptionGroup *g = &l->groups[i];
1451 OptionsContext o;
1452
1453 15989 init_options(&o);
1454 15989 o.g = g;
1455
1456 15989 ret = parse_optgroup(&o, g, options);
1457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15989 times.
15989 if (ret < 0) {
1458 av_log(NULL, AV_LOG_ERROR, "Error parsing options for %s file "
1459 "%s.\n", inout, g->arg);
1460 uninit_options(&o);
1461 1 return ret;
1462 }
1463
1464 15989 av_log(NULL, AV_LOG_DEBUG, "Opening an %s file: %s.\n", inout, g->arg);
1465 15989 ret = open_file(&o, g->arg, sch);
1466 15989 uninit_options(&o);
1467
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15988 times.
15989 if (ret < 0) {
1468 1 av_log(NULL, AV_LOG_ERROR, "Error opening %s file %s.\n",
1469 inout, g->arg);
1470 1 return ret;
1471 }
1472 15988 av_log(NULL, AV_LOG_DEBUG, "Successfully opened the file.\n");
1473 }
1474
1475 25608 return 0;
1476 }
1477
1478 8539 int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
1479 {
1480 8539 GlobalOptionsContext go = { .sch = sch };
1481 OptionParseContext octx;
1482 8539 const char *errmsg = NULL;
1483 int ret;
1484
1485 8539 memset(&octx, 0, sizeof(octx));
1486
1487 /* split the commandline into an internal representation */
1488 8539 ret = split_commandline(&octx, argc, argv, options, groups,
1489 FF_ARRAY_ELEMS(groups));
1490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8539 times.
8539 if (ret < 0) {
1491 errmsg = "splitting the argument list";
1492 goto fail;
1493 }
1494
1495 /* apply global options */
1496 8539 ret = parse_optgroup(&go, &octx.global_opts, options);
1497
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8537 times.
8539 if (ret < 0) {
1498 2 errmsg = "parsing global options";
1499 2 goto fail;
1500 }
1501
1502 /* configure terminal and setup signal handlers */
1503 8537 term_init();
1504
1505 /* create complex filtergraphs */
1506
2/2
✓ Branch 0 taken 1257 times.
✓ Branch 1 taken 8537 times.
9794 for (int i = 0; i < go.nb_filtergraphs; i++) {
1507 1257 ret = fg_create(NULL, &go.filtergraphs[i], sch, NULL);
1508 1257 go.filtergraphs[i] = NULL;
1509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
1257 if (ret < 0)
1510 goto fail;
1511 }
1512
1513 /* open input files */
1514 8537 ret = open_files(&octx.groups[GROUP_INFILE], "input", sch, ifile_open);
1515
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8536 times.
8537 if (ret < 0) {
1516 1 errmsg = "opening input files";
1517 1 goto fail;
1518 }
1519
1520 /* open output files */
1521 8536 ret = open_files(&octx.groups[GROUP_OUTFILE], "output", sch, of_open);
1522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8536 times.
8536 if (ret < 0) {
1523 errmsg = "opening output files";
1524 goto fail;
1525 }
1526
1527 /* create loopback decoders */
1528 8536 ret = open_files(&octx.groups[GROUP_DECODER], "decoder", sch, dec_create);
1529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8536 times.
8536 if (ret < 0) {
1530 errmsg = "creating loopback decoders";
1531 goto fail;
1532 }
1533
1534 // bind unbound filtegraph inputs/outputs and check consistency
1535 8536 ret = fg_finalise_bindings();
1536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8536 times.
8536 if (ret < 0) {
1537 errmsg = "binding filtergraph inputs/outputs";
1538 goto fail;
1539 }
1540
1541 8536 correct_input_start_times();
1542
1543 8536 ret = apply_sync_offsets();
1544
1/2
✓ Branch 0 taken 8536 times.
✗ Branch 1 not taken.
8536 if (ret < 0)
1545 goto fail;
1546
1547 8536 fail:
1548
2/2
✓ Branch 0 taken 1257 times.
✓ Branch 1 taken 8539 times.
9796 for (int i = 0; i < go.nb_filtergraphs; i++)
1549 1257 av_freep(&go.filtergraphs[i]);
1550 8539 av_freep(&go.filtergraphs);
1551
1552 8539 uninit_parse_context(&octx);
1553
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8536 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
8539 if (ret < 0 && ret != AVERROR_EXIT) {
1554
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 av_log(NULL, AV_LOG_FATAL, "Error %s: %s\n",
1555 1 errmsg ? errmsg : "", av_err2str(ret));
1556 }
1557 8539 return ret;
1558 }
1559
1560 static int opt_progress(void *optctx, const char *opt, const char *arg)
1561 {
1562 AVIOContext *avio = NULL;
1563 int ret;
1564
1565 if (!strcmp(arg, "-"))
1566 arg = "pipe:";
1567 ret = avio_open2(&avio, arg, AVIO_FLAG_WRITE, &int_cb, NULL);
1568 if (ret < 0) {
1569 av_log(NULL, AV_LOG_ERROR, "Failed to open progress URL \"%s\": %s\n",
1570 arg, av_err2str(ret));
1571 return ret;
1572 }
1573 progress_avio = avio;
1574 return 0;
1575 }
1576
1577 int opt_timelimit(void *optctx, const char *opt, const char *arg)
1578 {
1579 #if HAVE_SETRLIMIT
1580 int ret;
1581 double lim;
1582 struct rlimit rl;
1583
1584 ret = parse_number(opt, arg, OPT_TYPE_INT64, 0, INT_MAX, &lim);
1585 if (ret < 0)
1586 return ret;
1587
1588 rl = (struct rlimit){ lim, lim + 1 };
1589 if (setrlimit(RLIMIT_CPU, &rl))
1590 perror("setrlimit");
1591 #else
1592 av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
1593 #endif
1594 return 0;
1595 }
1596
1597 #if FFMPEG_OPT_QPHIST
1598 static int opt_qphist(void *optctx, const char *opt, const char *arg)
1599 {
1600 av_log(NULL, AV_LOG_WARNING, "Option -%s is deprecated and has no effect\n", opt);
1601 return 0;
1602 }
1603 #endif
1604
1605 #if FFMPEG_OPT_ADRIFT_THRESHOLD
1606 static int opt_adrift_threshold(void *optctx, const char *opt, const char *arg)
1607 {
1608 av_log(NULL, AV_LOG_WARNING, "Option -%s is deprecated and has no effect\n", opt);
1609 return 0;
1610 }
1611 #endif
1612
1613 static const char *const alt_channel_layout[] = { "ch_layout", NULL};
1614 static const char *const alt_codec[] = { "c", "acodec", "vcodec", "scodec", "dcodec", NULL };
1615 static const char *const alt_filter[] = { "af", "vf", NULL };
1616 static const char *const alt_frames[] = { "aframes", "vframes", "dframes", NULL };
1617 static const char *const alt_pre[] = { "apre", "vpre", "spre", NULL};
1618 static const char *const alt_qscale[] = { "q", NULL};
1619 static const char *const alt_tag[] = { "atag", "vtag", "stag", NULL };
1620
1621 #define OFFSET(x) offsetof(OptionsContext, x)
1622 const OptionDef options[] = {
1623 /* main options */
1624 CMDUTILS_COMMON_OPTIONS
1625 { "f", OPT_TYPE_STRING, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
1626 { .off = OFFSET(format) },
1627 "force container format (auto-detected otherwise)", "fmt" },
1628 { "y", OPT_TYPE_BOOL, 0,
1629 { &file_overwrite },
1630 "overwrite output files" },
1631 { "n", OPT_TYPE_BOOL, 0,
1632 { &no_file_overwrite },
1633 "never overwrite output files" },
1634 { "ignore_unknown", OPT_TYPE_BOOL, OPT_EXPERT,
1635 { &ignore_unknown_streams },
1636 "Ignore unknown stream types" },
1637 { "copy_unknown", OPT_TYPE_BOOL, OPT_EXPERT,
1638 { &copy_unknown_streams },
1639 "Copy unknown stream types" },
1640 { "recast_media", OPT_TYPE_BOOL, OPT_EXPERT,
1641 { &recast_media },
1642 "allow recasting stream type in order to force a decoder of different media type" },
1643 { "c", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT | OPT_DECODER | OPT_HAS_CANON,
1644 { .off = OFFSET(codec_names) },
1645 "select encoder/decoder ('copy' to copy stream without reencoding)", "codec",
1646 .u1.name_canon = "codec", },
1647 { "codec", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT | OPT_DECODER | OPT_EXPERT | OPT_HAS_ALT,
1648 { .off = OFFSET(codec_names) },
1649 "alias for -c (select encoder/decoder)", "codec",
1650 .u1.names_alt = alt_codec, },
1651 { "pre", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_OUTPUT | OPT_EXPERT | OPT_HAS_ALT,
1652 { .off = OFFSET(presets) },
1653 "preset name", "preset",
1654 .u1.names_alt = alt_pre, },
1655 { "map", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
1656 { .func_arg = opt_map },
1657 "set input stream mapping",
1658 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
1659 { "map_metadata", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | OPT_EXPERT,
1660 { .off = OFFSET(metadata_map) },
1661 "set metadata information of outfile from infile",
1662 "outfile[,metadata]:infile[,metadata]" },
1663 { "map_chapters", OPT_TYPE_INT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
1664 { .off = OFFSET(chapters_input_file) },
1665 "set chapters mapping", "input_file_index" },
1666 { "t", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
1667 { .off = OFFSET(recording_time) },
1668 "stop transcoding after specified duration",
1669 "duration" },
1670 { "to", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
1671 { .off = OFFSET(stop_time) },
1672 "stop transcoding after specified time is reached",
1673 "time_stop" },
1674 { "fs", OPT_TYPE_INT64, OPT_OFFSET | OPT_OUTPUT | OPT_EXPERT,
1675 { .off = OFFSET(limit_filesize) },
1676 "set the limit file size in bytes", "limit_size" },
1677 { "ss", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
1678 { .off = OFFSET(start_time) },
1679 "start transcoding at specified time", "time_off" },
1680 { "sseof", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_EXPERT,
1681 { .off = OFFSET(start_time_eof) },
1682 "set the start time offset relative to EOF", "time_off" },
1683 { "seek_timestamp", OPT_TYPE_INT, OPT_OFFSET | OPT_INPUT | OPT_EXPERT,
1684 { .off = OFFSET(seek_timestamp) },
1685 "enable/disable seeking by timestamp with -ss" },
1686 { "accurate_seek", OPT_TYPE_BOOL, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1687 { .off = OFFSET(accurate_seek) },
1688 "enable/disable accurate seeking with -ss" },
1689 { "isync", OPT_TYPE_INT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1690 { .off = OFFSET(input_sync_ref) },
1691 "Indicate the input index for sync reference", "sync ref" },
1692 { "itsoffset", OPT_TYPE_TIME, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1693 { .off = OFFSET(input_ts_offset) },
1694 "set the input ts offset", "time_off" },
1695 { "itsscale", OPT_TYPE_DOUBLE, OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
1696 { .off = OFFSET(ts_scale) },
1697 "set the input ts scale", "scale" },
1698 { "timestamp", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
1699 { .func_arg = opt_recording_timestamp },
1700 "set the recording timestamp ('now' to set the current time)", "time" },
1701 { "metadata", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
1702 { .off = OFFSET(metadata) },
1703 "add metadata", "key=value" },
1704 { "program", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
1705 { .off = OFFSET(program) },
1706 "add program with specified streams", "title=string:st=number..." },
1707 { "stream_group", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | OPT_EXPERT,
1708 { .off = OFFSET(stream_groups) },
1709 "add stream group with specified streams and group type-specific arguments", "id=number:st=number..." },
1710 { "dframes", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT | OPT_HAS_CANON,
1711 { .func_arg = opt_data_frames },
1712 "set the number of data frames to output", "number",
1713 .u1.name_canon = "frames" },
1714 { "benchmark", OPT_TYPE_BOOL, OPT_EXPERT,
1715 { &do_benchmark },
1716 "add timings for benchmarking" },
1717 { "benchmark_all", OPT_TYPE_BOOL, OPT_EXPERT,
1718 { &do_benchmark_all },
1719 "add timings for each task" },
1720 { "progress", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1721 { .func_arg = opt_progress },
1722 "write program-readable progress information", "url" },
1723 { "stdin", OPT_TYPE_BOOL, OPT_EXPERT,
1724 { &stdin_interaction },
1725 "enable or disable interaction on standard input" },
1726 { "timelimit", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1727 { .func_arg = opt_timelimit },
1728 "set max runtime in seconds in CPU user time", "limit" },
1729 { "dump", OPT_TYPE_BOOL, OPT_EXPERT,
1730 { &do_pkt_dump },
1731 "dump each input packet" },
1732 { "hex", OPT_TYPE_BOOL, OPT_EXPERT,
1733 { &do_hex_dump },
1734 "when dumping packets, also dump the payload" },
1735 { "re", OPT_TYPE_BOOL, OPT_EXPERT | OPT_OFFSET | OPT_INPUT,
1736 { .off = OFFSET(rate_emu) },
1737 "read input at native frame rate; equivalent to -readrate 1", "" },
1738 { "readrate", OPT_TYPE_FLOAT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1739 { .off = OFFSET(readrate) },
1740 "read input at specified rate", "speed" },
1741 { "readrate_initial_burst", OPT_TYPE_DOUBLE, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1742 { .off = OFFSET(readrate_initial_burst) },
1743 "The initial amount of input to burst read before imposing any readrate", "seconds" },
1744 { "readrate_catchup", OPT_TYPE_FLOAT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
1745 { .off = OFFSET(readrate_catchup) },
1746 "Temporary readrate used to catch up if an input lags behind the specified readrate", "speed" },
1747 { "target", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
1748 { .func_arg = opt_target },
1749 "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\" or \"dv50\" "
1750 "with optional prefixes \"pal-\", \"ntsc-\" or \"film-\")", "type" },
1751 { "frame_drop_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
1752 { &frame_drop_threshold },
1753 "frame drop threshold", "" },
1754 { "copyts", OPT_TYPE_BOOL, OPT_EXPERT,
1755 { &copy_ts },
1756 "copy timestamps" },
1757 { "start_at_zero", OPT_TYPE_BOOL, OPT_EXPERT,
1758 { &start_at_zero },
1759 "shift input timestamps to start at 0 when using copyts" },
1760 { "copytb", OPT_TYPE_INT, OPT_EXPERT,
1761 { &copy_tb },
1762 "copy input stream time base when stream copying", "mode" },
1763 { "shortest", OPT_TYPE_BOOL, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
1764 { .off = OFFSET(shortest) },
1765 "finish encoding within shortest input" },
1766 { "shortest_buf_duration", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
1767 { .off = OFFSET(shortest_buf_duration) },
1768 "maximum buffering duration (in seconds) for the -shortest option" },
1769 { "bitexact", OPT_TYPE_BOOL, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT | OPT_INPUT,
1770 { .off = OFFSET(bitexact) },
1771 "bitexact mode" },
1772 { "dts_delta_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
1773 { &dts_delta_threshold },
1774 "timestamp discontinuity delta threshold", "threshold" },
1775 { "dts_error_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
1776 { &dts_error_threshold },
1777 "timestamp error delta threshold", "threshold" },
1778 { "xerror", OPT_TYPE_BOOL, OPT_EXPERT,
1779 { &exit_on_error },
1780 "exit on error", "error" },
1781 { "abort_on", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1782 { .func_arg = opt_abort_on },
1783 "abort on the specified condition flags", "flags" },
1784 { "copyinkf", OPT_TYPE_BOOL, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1785 { .off = OFFSET(copy_initial_nonkeyframes) },
1786 "copy initial non-keyframes" },
1787 { "copypriorss", OPT_TYPE_INT, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1788 { .off = OFFSET(copy_prior_start) },
1789 "copy or discard frames before start time" },
1790 { "frames", OPT_TYPE_INT64, OPT_PERSTREAM | OPT_OUTPUT | OPT_EXPERT | OPT_HAS_ALT,
1791 { .off = OFFSET(max_frames) },
1792 "set the number of frames to output", "number",
1793 .u1.names_alt = alt_frames, },
1794 { "tag", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT | OPT_INPUT | OPT_HAS_ALT,
1795 { .off = OFFSET(codec_tags) },
1796 "force codec tag/fourcc", "fourcc/tag",
1797 .u1.names_alt = alt_tag, },
1798 { "q", OPT_TYPE_DOUBLE, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT | OPT_HAS_CANON,
1799 { .off = OFFSET(qscale) },
1800 "use fixed quality scale (VBR)", "q",
1801 .u1.name_canon = "qscale", },
1802 { "qscale", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_ALT,
1803 { .func_arg = opt_qscale },
1804 "use fixed quality scale (VBR)", "q",
1805 .u1.names_alt = alt_qscale, },
1806 { "profile", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
1807 { .func_arg = opt_profile },
1808 "set profile", "profile" },
1809 { "filter", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_OUTPUT | OPT_HAS_ALT,
1810 { .off = OFFSET(filters) },
1811 "apply specified filters to audio/video", "filter_graph",
1812 .u1.names_alt = alt_filter, },
1813 { "filter_threads", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1814 { .func_arg = opt_filter_threads },
1815 "number of non-complex filter threads" },
1816 { "filter_buffered_frames", OPT_TYPE_INT, OPT_EXPERT,
1817 { &filter_buffered_frames },
1818 "maximum number of buffered frames in a filter graph" },
1819 #if FFMPEG_OPT_FILTER_SCRIPT
1820 { "filter_script", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1821 { .off = OFFSET(filter_scripts) },
1822 "deprecated, use -/filter", "filename" },
1823 #endif
1824 { "reinit_filter", OPT_TYPE_INT, OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1825 { .off = OFFSET(reinit_filters) },
1826 "reinit filtergraph on input parameter changes", "" },
1827 { "drop_changed", OPT_TYPE_INT, OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1828 { .off = OFFSET(drop_changed) },
1829 "drop frame instead of reiniting filtergraph on input parameter changes", "" },
1830 { "filter_complex", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1831 { .func_arg = opt_filter_complex },
1832 "create a complex filtergraph", "graph_description" },
1833 { "filter_complex_threads", OPT_TYPE_INT, OPT_EXPERT,
1834 { &filter_complex_nbthreads },
1835 "number of threads for -filter_complex" },
1836 { "lavfi", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1837 { .func_arg = opt_filter_complex },
1838 "create a complex filtergraph", "graph_description" },
1839 #if FFMPEG_OPT_FILTER_SCRIPT
1840 { "filter_complex_script", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1841 { .func_arg = opt_filter_complex_script },
1842 "deprecated, use -/filter_complex instead", "filename" },
1843 #endif
1844 { "print_graphs", OPT_TYPE_BOOL, 0,
1845 { &print_graphs },
1846 "print execution graph data to stderr" },
1847 { "print_graphs_file", OPT_TYPE_STRING, 0,
1848 { &print_graphs_file },
1849 "write execution graph data to the specified file", "filename" },
1850 { "print_graphs_format", OPT_TYPE_STRING, 0,
1851 { &print_graphs_format },
1852 "set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml, mermaid, mermaidhtml)", "format" },
1853 { "auto_conversion_filters", OPT_TYPE_BOOL, OPT_EXPERT,
1854 { &auto_conversion_filters },
1855 "enable automatic conversion filters globally" },
1856 { "stats", OPT_TYPE_BOOL, 0,
1857 { &print_stats },
1858 "print progress report during encoding", },
1859 { "stats_period", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
1860 { .func_arg = opt_stats_period },
1861 "set the period at which ffmpeg updates stats and -progress output", "time" },
1862 { "attach", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
1863 { .func_arg = opt_attach },
1864 "add an attachment to the output file", "filename" },
1865 { "dump_attachment", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_INPUT,
1866 { .off = OFFSET(dump_attachment) },
1867 "extract an attachment into a file", "filename" },
1868 { "stream_loop", OPT_TYPE_INT, OPT_EXPERT | OPT_INPUT | OPT_OFFSET,
1869 { .off = OFFSET(loop) }, "set number of times input stream shall be looped", "loop count" },
1870 { "debug_ts", OPT_TYPE_BOOL, OPT_EXPERT,
1871 { &debug_ts },
1872 "print timestamp debugging info" },
1873 { "max_error_rate", OPT_TYPE_FLOAT, OPT_EXPERT,
1874 { &max_error_rate },
1875 "ratio of decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.", "maximum error rate" },
1876 { "discard", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1877 { .off = OFFSET(discard) },
1878 "discard", "" },
1879 { "disposition", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_OUTPUT | OPT_EXPERT,
1880 { .off = OFFSET(disposition) },
1881 "disposition", "" },
1882 { "thread_queue_size", OPT_TYPE_INT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT,
1883 { .off = OFFSET(thread_queue_size) },
1884 "set the maximum number of queued packets from the demuxer" },
1885 { "find_stream_info", OPT_TYPE_BOOL, OPT_INPUT | OPT_EXPERT | OPT_OFFSET,
1886 { .off = OFFSET(find_stream_info) },
1887 "read and decode the streams to fill missing information with heuristics" },
1888 { "bits_per_raw_sample", OPT_TYPE_INT, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1889 { .off = OFFSET(bits_per_raw_sample) },
1890 "set the number of bits per raw sample", "number" },
1891
1892 { "stats_enc_pre", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1893 { .off = OFFSET(enc_stats_pre) },
1894 "write encoding stats before encoding" },
1895 { "stats_enc_post", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1896 { .off = OFFSET(enc_stats_post) },
1897 "write encoding stats after encoding" },
1898 { "stats_mux_pre", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1899 { .off = OFFSET(mux_stats) },
1900 "write packets stats before muxing" },
1901 { "stats_enc_pre_fmt", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1902 { .off = OFFSET(enc_stats_pre_fmt) },
1903 "format of the stats written with -stats_enc_pre" },
1904 { "stats_enc_post_fmt", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1905 { .off = OFFSET(enc_stats_post_fmt) },
1906 "format of the stats written with -stats_enc_post" },
1907 { "stats_mux_pre_fmt", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
1908 { .off = OFFSET(mux_stats_fmt) },
1909 "format of the stats written with -stats_mux_pre" },
1910
1911 /* video options */
1912 { "vframes", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_EXPERT | OPT_HAS_CANON,
1913 { .func_arg = opt_video_frames },
1914 "set the number of video frames to output", "number",
1915 .u1.name_canon = "frames", },
1916 { "r", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
1917 { .off = OFFSET(frame_rates) },
1918 "override input framerate/convert to given output framerate (Hz value, fraction or abbreviation)", "rate" },
1919 { "fpsmax", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_OUTPUT | OPT_EXPERT,
1920 { .off = OFFSET(max_frame_rates) },
1921 "set max frame rate (Hz value, fraction or abbreviation)", "rate" },
1922 { "s", OPT_TYPE_STRING, OPT_VIDEO | OPT_SUBTITLE | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
1923 { .off = OFFSET(frame_sizes) },
1924 "set frame size (WxH or abbreviation)", "size" },
1925 { "aspect", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_OUTPUT,
1926 { .off = OFFSET(frame_aspect_ratios) },
1927 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
1928 { "pix_fmt", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
1929 { .off = OFFSET(frame_pix_fmts) },
1930 "set pixel format", "format" },
1931 { "display_rotation", OPT_TYPE_DOUBLE, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1932 { .off = OFFSET(display_rotations) },
1933 "set pure counter-clockwise rotation in degrees for stream(s)",
1934 "angle" },
1935 { "display_hflip", OPT_TYPE_BOOL, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1936 { .off = OFFSET(display_hflips) },
1937 "set display horizontal flip for stream(s) "
1938 "(overrides any display rotation if it is not set)"},
1939 { "display_vflip", OPT_TYPE_BOOL, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1940 { .off = OFFSET(display_vflips) },
1941 "set display vertical flip for stream(s) "
1942 "(overrides any display rotation if it is not set)"},
1943 { "mastering_display", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1944 { .off = OFFSET(mastering_displays) },
1945 "set SMPTE2084 mastering display color volume info" },
1946 { "content_light", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
1947 { .off = OFFSET(content_lights) },
1948 "set SMPTE2084 Max CLL and Max FALL values" },
1949 { "vn", OPT_TYPE_BOOL, OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
1950 { .off = OFFSET(video_disable) },
1951 "disable video" },
1952 { "rc_override", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1953 { .off = OFFSET(rc_overrides) },
1954 "rate control override for specific intervals", "override" },
1955 { "vcodec", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
1956 { .func_arg = opt_video_codec },
1957 "alias for -c:v (select encoder/decoder for video streams)", "codec",
1958 .u1.name_canon = "codec", },
1959 { "timecode", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_EXPERT,
1960 { .func_arg = opt_timecode },
1961 "set initial TimeCode value.", "hh:mm:ss[:;.]ff" },
1962 { "pass", OPT_TYPE_INT, OPT_VIDEO | OPT_PERSTREAM | OPT_OUTPUT | OPT_EXPERT,
1963 { .off = OFFSET(pass) },
1964 "select the pass number (1 to 3)", "n" },
1965 { "passlogfile", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1966 { .off = OFFSET(passlogfiles) },
1967 "select two pass log file name prefix", "prefix" },
1968 { "vstats", OPT_TYPE_FUNC, OPT_VIDEO | OPT_EXPERT,
1969 { .func_arg = opt_vstats },
1970 "dump video coding statistics to file" },
1971 { "vstats_file", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT,
1972 { .func_arg = opt_vstats_file },
1973 "dump video coding statistics to file", "file" },
1974 { "vstats_version", OPT_TYPE_INT, OPT_VIDEO | OPT_EXPERT,
1975 { &vstats_version },
1976 "Version of the vstats format to use."},
1977 { "vf", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
1978 { .func_arg = opt_video_filters },
1979 "alias for -filter:v (apply filters to video streams)", "filter_graph",
1980 .u1.name_canon = "filter", },
1981 { "intra_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1982 { .off = OFFSET(intra_matrices) },
1983 "specify intra matrix coeffs", "matrix" },
1984 { "inter_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1985 { .off = OFFSET(inter_matrices) },
1986 "specify inter matrix coeffs", "matrix" },
1987 { "chroma_intra_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1988 { .off = OFFSET(chroma_intra_matrices) },
1989 "specify intra matrix coeffs", "matrix" },
1990 { "vtag", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
1991 { .func_arg = opt_old2new },
1992 "force video tag/fourcc", "fourcc/tag",
1993 .u1.name_canon = "tag", },
1994 { "fps_mode", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1995 { .off = OFFSET(fps_mode) },
1996 "set framerate mode for matching video streams; overrides vsync" },
1997 { "force_fps", OPT_TYPE_BOOL, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
1998 { .off = OFFSET(force_fps) },
1999 "force the selected framerate, disable the best supported framerate selection" },
2000 { "streamid", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
2001 { .func_arg = opt_streamid },
2002 "set the value of an outfile streamid", "streamIndex:value" },
2003 { "force_key_frames", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
2004 { .off = OFFSET(forced_key_frames) },
2005 "force key frames at specified timestamps", "timestamps" },
2006 { "b", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT,
2007 { .func_arg = opt_bitrate },
2008 "video bitrate (please use -b:v)", "bitrate" },
2009 { "hwaccel", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT,
2010 { .off = OFFSET(hwaccels) },
2011 "use HW accelerated decoding", "hwaccel name" },
2012 { "hwaccel_device", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT,
2013 { .off = OFFSET(hwaccel_devices) },
2014 "select a device for HW acceleration", "devicename" },
2015 { "hwaccel_output_format", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT,
2016 { .off = OFFSET(hwaccel_output_formats) },
2017 "select output format used with HW accelerated decoding", "format" },
2018 { "hwaccels", OPT_TYPE_FUNC, OPT_EXIT | OPT_EXPERT,
2019 { .func_arg = show_hwaccels },
2020 "show available HW acceleration methods" },
2021 { "autorotate", OPT_TYPE_BOOL, OPT_VIDEO | OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
2022 { .off = OFFSET(autorotate) },
2023 "automatically insert correct rotate filters" },
2024 { "autoscale", OPT_TYPE_BOOL, OPT_VIDEO | OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
2025 { .off = OFFSET(autoscale) },
2026 "automatically insert a scale filter at the end of the filter graph" },
2027 { "apply_cropping", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
2028 { .off = OFFSET(apply_cropping) },
2029 "select the cropping to apply" },
2030 { "fix_sub_duration_heartbeat", OPT_TYPE_BOOL, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
2031 { .off = OFFSET(fix_sub_duration_heartbeat) },
2032 "set this video output stream to be a heartbeat stream for "
2033 "fix_sub_duration, according to which subtitles should be split at "
2034 "random access points" },
2035
2036 /* audio options */
2037 { "aframes", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_EXPERT | OPT_HAS_CANON,
2038 { .func_arg = opt_audio_frames },
2039 "set the number of audio frames to output", "number",
2040 .u1.name_canon = "frames", },
2041 { "aq", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT,
2042 { .func_arg = opt_audio_qscale },
2043 "set audio quality (codec-specific)", "quality", },
2044 { "ar", OPT_TYPE_INT, OPT_AUDIO | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
2045 { .off = OFFSET(audio_sample_rate) },
2046 "set audio sampling rate (in Hz)", "rate" },
2047 { "ac", OPT_TYPE_INT, OPT_AUDIO | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
2048 { .off = OFFSET(audio_channels) },
2049 "set number of audio channels", "channels" },
2050 { "an", OPT_TYPE_BOOL, OPT_AUDIO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
2051 { .off = OFFSET(audio_disable) },
2052 "disable audio" },
2053 { "acodec", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
2054 { .func_arg = opt_audio_codec },
2055 "alias for -c:a (select encoder/decoder for audio streams)", "codec",
2056 .u1.name_canon = "codec", },
2057 { "ab", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT,
2058 { .func_arg = opt_bitrate },
2059 "alias for -b:a (select bitrate for audio streams)", "bitrate" },
2060 { "apad", OPT_TYPE_STRING, OPT_AUDIO | OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
2061 { .off = OFFSET(apad) },
2062 "audio pad", "" },
2063 { "atag", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
2064 { .func_arg = opt_old2new },
2065 "force audio tag/fourcc", "fourcc/tag",
2066 .u1.name_canon = "tag", },
2067 { "sample_fmt", OPT_TYPE_STRING, OPT_AUDIO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
2068 { .off = OFFSET(sample_fmts) },
2069 "set sample format", "format" },
2070 { "channel_layout", OPT_TYPE_STRING, OPT_AUDIO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT | OPT_HAS_ALT,
2071 { .off = OFFSET(audio_ch_layouts) },
2072 "set channel layout", "layout",
2073 .u1.names_alt = alt_channel_layout, },
2074 { "ch_layout", OPT_TYPE_STRING, OPT_AUDIO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
2075 { .off = OFFSET(audio_ch_layouts) },
2076 "set channel layout", "layout",
2077 .u1.name_canon = "channel_layout", },
2078 { "af", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
2079 { .func_arg = opt_audio_filters },
2080 "alias for -filter:a (apply filters to audio streams)", "filter_graph",
2081 .u1.name_canon = "filter", },
2082 { "guess_layout_max", OPT_TYPE_INT, OPT_AUDIO | OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
2083 { .off = OFFSET(guess_layout_max) },
2084 "set the maximum number of channels to try to guess the channel layout" },
2085
2086 /* subtitle options */
2087 { "sn", OPT_TYPE_BOOL, OPT_SUBTITLE | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
2088 { .off = OFFSET(subtitle_disable) },
2089 "disable subtitle" },
2090 { "scodec", OPT_TYPE_FUNC, OPT_SUBTITLE | OPT_FUNC_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
2091 { .func_arg = opt_subtitle_codec },
2092 "alias for -c:s (select encoder/decoder for subtitle streams)", "codec",
2093 .u1.name_canon = "codec", },
2094 { "stag", OPT_TYPE_FUNC, OPT_SUBTITLE | OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
2095 { .func_arg = opt_old2new }
2096 , "force subtitle tag/fourcc", "fourcc/tag",
2097 .u1.name_canon = "tag" },
2098 { "fix_sub_duration", OPT_TYPE_BOOL, OPT_EXPERT | OPT_SUBTITLE | OPT_PERSTREAM | OPT_INPUT,
2099 { .off = OFFSET(fix_sub_duration) },
2100 "fix subtitles duration" },
2101 { "canvas_size", OPT_TYPE_STRING, OPT_SUBTITLE | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
2102 { .off = OFFSET(canvas_sizes) },
2103 "set canvas size (WxH or abbreviation)", "size" },
2104
2105 /* muxer options */
2106 { "muxdelay", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
2107 { .off = OFFSET(mux_max_delay) },
2108 "set the maximum demux-decode delay", "seconds" },
2109 { "muxpreload", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
2110 { .off = OFFSET(mux_preload) },
2111 "set the initial demux-decode delay", "seconds" },
2112 { "sdp_file", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_OUTPUT,
2113 { .func_arg = opt_sdp_file },
2114 "specify a file in which to print sdp information", "file" },
2115
2116 { "time_base", OPT_TYPE_STRING, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
2117 { .off = OFFSET(time_bases) },
2118 "set the desired time base hint for output stream (1:24, 1:48000 or 0.04166, 2.0833e-5)", "ratio" },
2119 { "enc_time_base", OPT_TYPE_STRING, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
2120 { .off = OFFSET(enc_time_bases) },
2121 "set the desired time base for the encoder (1:24, 1:48000 or 0.04166, 2.0833e-5). "
2122 "two special values are defined - "
2123 "0 = use frame rate (video) or sample rate (audio),"
2124 "-1 = match source time base", "ratio" },
2125
2126 { "bsf", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT | OPT_INPUT,
2127 { .off = OFFSET(bitstream_filters) },
2128 "A comma-separated list of bitstream filters", "bitstream_filters", },
2129
2130 { "apre", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
2131 { .func_arg = opt_preset },
2132 "set the audio options to the indicated preset", "preset",
2133 .u1.name_canon = "pre", },
2134 { "vpre", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
2135 { .func_arg = opt_preset },
2136 "set the video options to the indicated preset", "preset",
2137 .u1.name_canon = "pre", },
2138 { "spre", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_SUBTITLE | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
2139 { .func_arg = opt_preset },
2140 "set the subtitle options to the indicated preset", "preset",
2141 .u1.name_canon = "pre", },
2142 { "fpre", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
2143 { .func_arg = opt_preset },
2144 "set options from indicated preset file", "filename",
2145 .u1.name_canon = "pre", },
2146
2147 { "max_muxing_queue_size", OPT_TYPE_INT, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
2148 { .off = OFFSET(max_muxing_queue_size) },
2149 "maximum number of packets that can be buffered while waiting for all streams to initialize", "packets" },
2150 { "muxing_queue_data_threshold", OPT_TYPE_INT, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
2151 { .off = OFFSET(muxing_queue_data_threshold) },
2152 "set the threshold after which max_muxing_queue_size is taken into account", "bytes" },
2153
2154 /* data codec support */
2155 { "dcodec", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_DATA | OPT_PERFILE | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
2156 { .func_arg = opt_data_codec },
2157 "alias for -c:d (select encoder/decoder for data streams)", "codec",
2158 .u1.name_canon = "codec", },
2159 { "dn", OPT_TYPE_BOOL, OPT_DATA | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
2160 { .off = OFFSET(data_disable) }, "disable data" },
2161
2162 #if CONFIG_VAAPI
2163 { "vaapi_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
2164 { .func_arg = opt_vaapi_device },
2165 "set VAAPI hardware device (DirectX adapter index, DRM path or X11 display name)", "device" },
2166 #endif
2167
2168 #if CONFIG_QSV
2169 { "qsv_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
2170 { .func_arg = opt_qsv_device },
2171 "set QSV hardware device (DirectX adapter index, DRM path or X11 display name)", "device"},
2172 #endif
2173
2174 { "init_hw_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
2175 { .func_arg = opt_init_hw_device },
2176 "initialise hardware device", "args" },
2177 { "filter_hw_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
2178 { .func_arg = opt_filter_hw_device },
2179 "set hardware device used when filtering", "device" },
2180
2181 // deprecated options
2182 #if FFMPEG_OPT_ADRIFT_THRESHOLD
2183 { "adrift_threshold", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
2184 { .func_arg = opt_adrift_threshold },
2185 "deprecated, does nothing", "threshold" },
2186 #endif
2187 #if FFMPEG_OPT_TOP
2188 { "top", OPT_TYPE_INT, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
2189 { .off = OFFSET(top_field_first) },
2190 "deprecated, use the setfield video filter", "" },
2191 #endif
2192 #if FFMPEG_OPT_QPHIST
2193 { "qphist", OPT_TYPE_FUNC, OPT_VIDEO | OPT_EXPERT,
2194 { .func_arg = opt_qphist },
2195 "deprecated, does nothing" },
2196 #endif
2197 #if FFMPEG_OPT_VSYNC
2198 { "vsync", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
2199 { .func_arg = opt_vsync },
2200 "set video sync method globally; deprecated, use -fps_mode", "" },
2201 #endif
2202
2203 { NULL, },
2204 };
2205