FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/fftools/ffmpeg_opt.c
Date: 2026-10-30 17:37:53
Exec Total Coverage
Lines: 387 847 45.7%
Functions: 36 59 61.0%
Branches: 216 520 41.5%

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