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