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