2012-08-01 19:23:12 +03:00
|
|
|
/*
|
2012-08-09 01:26:38 +03:00
|
|
|
* ffmpeg option parsing
|
2012-08-01 19:23:12 +03:00
|
|
|
*
|
2012-08-09 01:26:38 +03:00
|
|
|
* This file is part of FFmpeg.
|
2012-08-01 19:23:12 +03:00
|
|
|
*
|
2012-08-09 01:26:38 +03:00
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2012-08-01 19:23:12 +03:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
2012-08-09 01:26:38 +03:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2012-08-01 19:23:12 +03:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-08-09 01:26:38 +03:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2012-08-01 19:23:12 +03:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2022-03-09 13:16:16 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2012-08-01 19:23:12 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2022-03-09 13:16:16 +02:00
|
|
|
#if HAVE_SYS_RESOURCE_H
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#endif
|
|
|
|
|
2012-08-09 01:26:38 +03:00
|
|
|
#include "ffmpeg.h"
|
2023-05-18 16:56:15 +02:00
|
|
|
#include "ffmpeg_sched.h"
|
2012-08-01 19:23:12 +03:00
|
|
|
#include "cmdutils.h"
|
2022-03-09 13:11:09 +02:00
|
|
|
#include "opt_common.h"
|
2022-06-10 14:21:42 +02:00
|
|
|
#include "sync_queue.h"
|
2012-08-01 19:23:12 +03:00
|
|
|
|
|
|
|
#include "libavformat/avformat.h"
|
|
|
|
|
|
|
|
#include "libavcodec/avcodec.h"
|
2021-06-11 23:35:33 +02:00
|
|
|
#include "libavcodec/bsf.h"
|
2012-08-01 19:23:12 +03:00
|
|
|
|
|
|
|
#include "libavfilter/avfilter.h"
|
|
|
|
|
|
|
|
#include "libavutil/avassert.h"
|
|
|
|
#include "libavutil/avstring.h"
|
|
|
|
#include "libavutil/avutil.h"
|
2021-12-01 21:31:27 +02:00
|
|
|
#include "libavutil/bprint.h"
|
2012-11-10 18:00:00 +03:00
|
|
|
#include "libavutil/channel_layout.h"
|
2022-10-19 11:44:03 +02:00
|
|
|
#include "libavutil/display.h"
|
2012-08-01 19:23:12 +03:00
|
|
|
#include "libavutil/intreadwrite.h"
|
|
|
|
#include "libavutil/fifo.h"
|
|
|
|
#include "libavutil/mathematics.h"
|
|
|
|
#include "libavutil/opt.h"
|
|
|
|
#include "libavutil/parseutils.h"
|
|
|
|
#include "libavutil/pixdesc.h"
|
|
|
|
#include "libavutil/pixfmt.h"
|
|
|
|
|
2017-03-05 01:57:38 +02:00
|
|
|
HWDevice *filter_hw_device;
|
2013-11-03 00:06:36 +03:00
|
|
|
|
2012-08-01 19:23:12 +03:00
|
|
|
char *vstats_filename;
|
|
|
|
|
|
|
|
float audio_drift_threshold = 0.1;
|
|
|
|
float dts_delta_threshold = 10;
|
2012-08-09 01:26:38 +03:00
|
|
|
float dts_error_threshold = 3600*30;
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2021-12-04 15:53:58 +02:00
|
|
|
enum VideoSyncMethod video_sync_method = VSYNC_AUTO;
|
2015-01-17 05:38:32 +02:00
|
|
|
float frame_drop_threshold = 0;
|
2012-08-01 19:23:12 +03:00
|
|
|
int do_benchmark = 0;
|
2012-08-09 01:26:38 +03:00
|
|
|
int do_benchmark_all = 0;
|
2012-08-01 19:23:12 +03:00
|
|
|
int do_hex_dump = 0;
|
|
|
|
int do_pkt_dump = 0;
|
|
|
|
int copy_ts = 0;
|
2014-10-21 02:50:12 +03:00
|
|
|
int start_at_zero = 0;
|
2012-08-09 01:26:38 +03:00
|
|
|
int copy_tb = -1;
|
|
|
|
int debug_ts = 0;
|
2012-08-01 19:23:12 +03:00
|
|
|
int exit_on_error = 0;
|
2015-10-17 23:46:09 +02:00
|
|
|
int abort_on_flags = 0;
|
2013-03-03 21:33:37 +03:00
|
|
|
int print_stats = -1;
|
2012-08-09 01:26:38 +03:00
|
|
|
int stdin_interaction = 1;
|
2013-10-01 19:17:16 +03:00
|
|
|
float max_error_rate = 2.0/3;
|
2021-09-03 15:30:32 +02:00
|
|
|
char *filter_nbthreads;
|
2016-11-24 17:14:27 +02:00
|
|
|
int filter_complex_nbthreads = 0;
|
2017-01-26 02:41:44 +02:00
|
|
|
int vstats_version = 2;
|
2020-08-14 13:06:34 +02:00
|
|
|
int auto_conversion_filters = 1;
|
2020-12-21 10:46:49 +02:00
|
|
|
int64_t stats_period = 500000;
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2012-08-09 01:26:38 +03:00
|
|
|
|
2012-08-01 19:23:12 +03:00
|
|
|
static int file_overwrite = 0;
|
2012-08-09 01:26:38 +03:00
|
|
|
static int no_file_overwrite = 0;
|
2022-06-19 17:10:48 +02:00
|
|
|
#if FFMPEG_OPT_PSNR
|
2022-10-13 12:24:43 +02:00
|
|
|
int do_psnr = 0;
|
2022-06-19 17:10:48 +02:00
|
|
|
#endif
|
2022-10-13 12:24:43 +02:00
|
|
|
int ignore_unknown_streams = 0;
|
|
|
|
int copy_unknown_streams = 0;
|
2022-10-17 10:49:42 +02:00
|
|
|
int recast_media = 0;
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2013-08-06 12:58:40 +03:00
|
|
|
static void uninit_options(OptionsContext *o)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
|
|
|
const OptionDef *po = options;
|
|
|
|
int i;
|
|
|
|
|
2023-12-15 09:50:26 +02:00
|
|
|
/* all OPT_SPEC and OPT_TYPE_STRING can be freed in generic way */
|
2012-08-01 19:23:12 +03:00
|
|
|
while (po->name) {
|
|
|
|
void *dst = (uint8_t*)o + po->u.off;
|
|
|
|
|
2023-12-17 12:47:33 +02:00
|
|
|
if (po->flags & OPT_FLAG_SPEC) {
|
2023-12-17 15:20:57 +02:00
|
|
|
SpecifierOptList *so = dst;
|
|
|
|
for (int i = 0; i < so->nb_opt; i++) {
|
|
|
|
av_freep(&so->opt[i].specifier);
|
2023-12-15 09:50:26 +02:00
|
|
|
if (po->type == OPT_TYPE_STRING)
|
2023-12-17 15:20:57 +02:00
|
|
|
av_freep(&so->opt[i].u.str);
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
2023-12-17 15:20:57 +02:00
|
|
|
av_freep(&so->opt);
|
|
|
|
so->nb_opt = 0;
|
2023-12-17 12:47:33 +02:00
|
|
|
} else if (po->flags & OPT_FLAG_OFFSET && po->type == OPT_TYPE_STRING)
|
2012-08-01 19:23:12 +03:00
|
|
|
av_freep(dst);
|
|
|
|
po++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < o->nb_stream_maps; i++)
|
|
|
|
av_freep(&o->stream_maps[i].linklabel);
|
|
|
|
av_freep(&o->stream_maps);
|
2022-06-19 20:09:24 +02:00
|
|
|
#if FFMPEG_OPT_MAP_CHANNEL
|
2012-08-09 01:26:38 +03:00
|
|
|
av_freep(&o->audio_channel_maps);
|
2022-06-19 20:09:24 +02:00
|
|
|
#endif
|
2013-02-03 04:45:41 +03:00
|
|
|
av_freep(&o->attachments);
|
2023-07-13 17:36:57 +02:00
|
|
|
|
|
|
|
av_dict_free(&o->streamid);
|
2012-06-08 22:35:16 +03:00
|
|
|
}
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2013-08-06 12:58:40 +03:00
|
|
|
static void init_options(OptionsContext *o)
|
2012-06-08 22:35:16 +03:00
|
|
|
{
|
2012-08-01 19:23:12 +03:00
|
|
|
memset(o, 0, sizeof(*o));
|
|
|
|
|
2013-02-27 02:18:41 +03:00
|
|
|
o->stop_time = INT64_MAX;
|
2012-08-09 01:26:38 +03:00
|
|
|
o->mux_max_delay = 0.7;
|
2013-06-15 10:35:10 +03:00
|
|
|
o->start_time = AV_NOPTS_VALUE;
|
2015-07-27 04:30:26 +02:00
|
|
|
o->start_time_eof = AV_NOPTS_VALUE;
|
2013-08-06 12:58:40 +03:00
|
|
|
o->recording_time = INT64_MAX;
|
2022-01-11 11:26:49 +02:00
|
|
|
o->limit_filesize = INT64_MAX;
|
2012-08-01 19:23:12 +03:00
|
|
|
o->chapters_input_file = INT_MAX;
|
2013-06-15 10:59:40 +03:00
|
|
|
o->accurate_seek = 1;
|
2020-07-04 23:43:12 +02:00
|
|
|
o->thread_queue_size = -1;
|
2022-06-13 13:02:44 +02:00
|
|
|
o->input_sync_ref = -1;
|
2022-09-28 12:21:00 +02:00
|
|
|
o->find_stream_info = 1;
|
2022-06-10 14:21:42 +02:00
|
|
|
o->shortest_buf_duration = 10.f;
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
2015-08-26 01:43:53 +02:00
|
|
|
static int show_hwaccels(void *optctx, const char *opt, const char *arg)
|
|
|
|
{
|
2017-10-26 01:18:47 +02:00
|
|
|
enum AVHWDeviceType type = AV_HWDEVICE_TYPE_NONE;
|
2015-08-26 01:43:53 +02:00
|
|
|
|
|
|
|
printf("Hardware acceleration methods:\n");
|
2017-10-26 01:18:47 +02:00
|
|
|
while ((type = av_hwdevice_iterate_types(type)) !=
|
|
|
|
AV_HWDEVICE_TYPE_NONE)
|
|
|
|
printf("%s\n", av_hwdevice_get_type_name(type));
|
2015-08-26 01:43:53 +02:00
|
|
|
printf("\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-21 12:58:46 +03:00
|
|
|
/* return a copy of the input with the stream specifiers removed from the keys */
|
2022-11-14 12:18:26 +02:00
|
|
|
AVDictionary *strip_specifiers(const AVDictionary *dict)
|
2013-02-21 12:58:46 +03:00
|
|
|
{
|
2021-10-19 00:27:01 +02:00
|
|
|
const AVDictionaryEntry *e = NULL;
|
2013-02-21 12:58:46 +03:00
|
|
|
AVDictionary *ret = NULL;
|
|
|
|
|
2022-11-26 16:46:18 +02:00
|
|
|
while ((e = av_dict_iterate(dict, e))) {
|
2013-02-21 12:58:46 +03:00
|
|
|
char *p = strchr(e->key, ':');
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
*p = 0;
|
|
|
|
av_dict_set(&ret, e->key, e->value, 0);
|
|
|
|
if (p)
|
|
|
|
*p = ':';
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-12-17 15:42:38 +02:00
|
|
|
const char *opt_match_per_type_str(const SpecifierOptList *sol,
|
|
|
|
char mediatype)
|
|
|
|
{
|
|
|
|
av_assert0(!sol->nb_opt || sol->type == OPT_TYPE_STRING);
|
|
|
|
|
|
|
|
for (int i = 0; i < sol->nb_opt; i++) {
|
|
|
|
const char *spec = sol->opt[i].specifier;
|
|
|
|
if (spec[0] == mediatype && !spec[1])
|
|
|
|
return sol->opt[i].u.str;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-10-13 12:24:43 +02:00
|
|
|
int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global)
|
2022-06-07 14:06:54 +02:00
|
|
|
{
|
|
|
|
if (!av_strcasecmp(arg, "cfr")) *vsync_var = VSYNC_CFR;
|
|
|
|
else if (!av_strcasecmp(arg, "vfr")) *vsync_var = VSYNC_VFR;
|
|
|
|
else if (!av_strcasecmp(arg, "passthrough")) *vsync_var = VSYNC_PASSTHROUGH;
|
2023-12-14 14:42:17 +02:00
|
|
|
#if FFMPEG_OPT_VSYNC_DROP
|
|
|
|
else if (!av_strcasecmp(arg, "drop")) {
|
|
|
|
av_log(NULL, AV_LOG_WARNING, "-vsync/fps_mode drop is deprecated\n");
|
|
|
|
*vsync_var = VSYNC_DROP;
|
|
|
|
}
|
|
|
|
#endif
|
2022-06-07 14:06:54 +02:00
|
|
|
else if (!is_global && !av_strcasecmp(arg, "auto")) *vsync_var = VSYNC_AUTO;
|
|
|
|
else if (!is_global) {
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "Invalid value %s specified for fps_mode of #%d:%d.\n", arg, file_idx, st_idx);
|
2023-07-14 13:49:49 +02:00
|
|
|
return AVERROR(EINVAL);
|
2022-06-07 14:06:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_global && *vsync_var == VSYNC_AUTO) {
|
2023-07-14 13:47:23 +02:00
|
|
|
int ret;
|
|
|
|
double num;
|
|
|
|
|
2023-12-15 09:50:26 +02:00
|
|
|
ret = parse_number("vsync", arg, OPT_TYPE_INT, VSYNC_AUTO, VSYNC_VFR, &num);
|
2023-07-14 13:47:23 +02:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
video_sync_method = num;
|
2022-06-07 14:06:54 +02:00
|
|
|
av_log(NULL, AV_LOG_WARNING, "Passing a number to -vsync is deprecated,"
|
|
|
|
" use a string argument as described in the manual.\n");
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-10-21 15:59:25 +02:00
|
|
|
/* Correct input file start times based on enabled streams */
|
2022-10-21 15:07:37 +02:00
|
|
|
static void correct_input_start_times(void)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < nb_input_files; i++) {
|
|
|
|
InputFile *ifile = input_files[i];
|
|
|
|
AVFormatContext *is = ifile->ctx;
|
2022-10-21 15:59:25 +02:00
|
|
|
int64_t new_start_time = INT64_MAX, diff, abs_start_seek;
|
|
|
|
|
|
|
|
ifile->start_time_effective = is->start_time;
|
2022-10-21 15:07:37 +02:00
|
|
|
|
|
|
|
if (is->start_time == AV_NOPTS_VALUE ||
|
|
|
|
!(is->iformat->flags & AVFMT_TS_DISCONT))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (int j = 0; j < is->nb_streams; j++) {
|
|
|
|
AVStream *st = is->streams[j];
|
|
|
|
if(st->discard == AVDISCARD_ALL || st->start_time == AV_NOPTS_VALUE)
|
|
|
|
continue;
|
|
|
|
new_start_time = FFMIN(new_start_time, av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q));
|
|
|
|
}
|
2022-10-21 15:59:25 +02:00
|
|
|
|
|
|
|
diff = new_start_time - is->start_time;
|
|
|
|
if (diff) {
|
|
|
|
av_log(NULL, AV_LOG_VERBOSE, "Correcting start time of Input #%d by %"PRId64" us.\n", i, diff);
|
|
|
|
ifile->start_time_effective = new_start_time;
|
|
|
|
if (copy_ts && start_at_zero)
|
|
|
|
ifile->ts_offset = -new_start_time;
|
|
|
|
else if (!copy_ts) {
|
|
|
|
abs_start_seek = is->start_time + (ifile->start_time != AV_NOPTS_VALUE) ? ifile->start_time : 0;
|
|
|
|
ifile->ts_offset = abs_start_seek > new_start_time ? -abs_start_seek : -new_start_time;
|
|
|
|
} else if (copy_ts)
|
|
|
|
ifile->ts_offset = 0;
|
|
|
|
|
|
|
|
ifile->ts_offset += ifile->input_ts_offset;
|
2022-10-21 15:07:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-13 13:02:44 +02:00
|
|
|
static int apply_sync_offsets(void)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < nb_input_files; i++) {
|
|
|
|
InputFile *ref, *self = input_files[i];
|
|
|
|
int64_t adjustment;
|
|
|
|
int64_t self_start_time, ref_start_time, self_seek_start, ref_seek_start;
|
|
|
|
int start_times_set = 1;
|
|
|
|
|
|
|
|
if (self->input_sync_ref == -1 || self->input_sync_ref == i) continue;
|
|
|
|
if (self->input_sync_ref >= nb_input_files || self->input_sync_ref < -1) {
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "-isync for input %d references non-existent input %d.\n", i, self->input_sync_ref);
|
2023-07-14 13:49:49 +02:00
|
|
|
return AVERROR(EINVAL);
|
2022-06-13 13:02:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (copy_ts && !start_at_zero) {
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "Use of -isync requires that start_at_zero be set if copyts is set.\n");
|
2023-07-14 13:49:49 +02:00
|
|
|
return AVERROR(EINVAL);
|
2022-06-13 13:02:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ref = input_files[self->input_sync_ref];
|
|
|
|
if (ref->input_sync_ref != -1 && ref->input_sync_ref != self->input_sync_ref) {
|
|
|
|
av_log(NULL, AV_LOG_ERROR, "-isync for input %d references a resynced input %d. Sync not set.\n", i, self->input_sync_ref);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (self->ctx->start_time_realtime != AV_NOPTS_VALUE && ref->ctx->start_time_realtime != AV_NOPTS_VALUE) {
|
|
|
|
self_start_time = self->ctx->start_time_realtime;
|
|
|
|
ref_start_time = ref->ctx->start_time_realtime;
|
2022-10-21 15:59:25 +02:00
|
|
|
} else if (self->start_time_effective != AV_NOPTS_VALUE && ref->start_time_effective != AV_NOPTS_VALUE) {
|
|
|
|
self_start_time = self->start_time_effective;
|
|
|
|
ref_start_time = ref->start_time_effective;
|
2022-06-13 13:02:44 +02:00
|
|
|
} else {
|
|
|
|
start_times_set = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start_times_set) {
|
|
|
|
self_seek_start = self->start_time == AV_NOPTS_VALUE ? 0 : self->start_time;
|
|
|
|
ref_seek_start = ref->start_time == AV_NOPTS_VALUE ? 0 : ref->start_time;
|
|
|
|
|
|
|
|
adjustment = (self_start_time - ref_start_time) + !copy_ts*(self_seek_start - ref_seek_start) + ref->input_ts_offset;
|
|
|
|
|
|
|
|
self->ts_offset += adjustment;
|
|
|
|
|
|
|
|
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);
|
|
|
|
} else {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-09-03 15:30:32 +02:00
|
|
|
static int opt_filter_threads(void *optctx, const char *opt, const char *arg)
|
|
|
|
{
|
|
|
|
av_free(filter_nbthreads);
|
|
|
|
filter_nbthreads = av_strdup(arg);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-17 23:46:09 +02:00
|
|
|
static int opt_abort_on(void *optctx, const char *opt, const char *arg)
|
|
|
|
{
|
|
|
|
static const AVOption opts[] = {
|
2020-05-13 00:06:08 +02:00
|
|
|
{ "abort_on" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" },
|
|
|
|
{ "empty_output" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = ABORT_ON_FLAG_EMPTY_OUTPUT }, .unit = "flags" },
|
|
|
|
{ "empty_output_stream", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM }, .unit = "flags" },
|
2015-10-17 23:46:09 +02:00
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
static const AVClass class = {
|
|
|
|
.class_name = "",
|
|
|
|
.item_name = av_default_item_name,
|
|
|
|
.option = opts,
|
|
|
|
.version = LIBAVUTIL_VERSION_INT,
|
|
|
|
};
|
|
|
|
const AVClass *pclass = &class;
|
|
|
|
|
|
|
|
return av_opt_eval_flags(&pclass, &opts[0], arg, &abort_on_flags);
|
|
|
|
}
|
|
|
|
|
2020-12-21 10:46:49 +02:00
|
|
|
static int opt_stats_period(void *optctx, const char *opt, const char *arg)
|
|
|
|
{
|
2023-07-14 16:37:19 +02:00
|
|
|
int64_t user_stats_period;
|
|
|
|
int ret = av_parse_time(&user_stats_period, arg, 1);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2020-12-21 10:46:49 +02:00
|
|
|
|
|
|
|
if (user_stats_period <= 0) {
|
|
|
|
av_log(NULL, AV_LOG_ERROR, "stats_period %s must be positive.\n", arg);
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
stats_period = user_stats_period;
|
|
|
|
av_log(NULL, AV_LOG_INFO, "ffmpeg stats and -progress period set to %s.\n", arg);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-11 17:30:26 +03:00
|
|
|
static int opt_audio_codec(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-11 17:30:26 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-01 19:23:12 +03:00
|
|
|
return parse_option(o, "codec:a", arg, options);
|
|
|
|
}
|
|
|
|
|
2012-08-11 17:30:26 +03:00
|
|
|
static int opt_video_codec(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-11 17:30:26 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-01 19:23:12 +03:00
|
|
|
return parse_option(o, "codec:v", arg, options);
|
|
|
|
}
|
|
|
|
|
2012-08-11 17:30:26 +03:00
|
|
|
static int opt_subtitle_codec(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-11 17:30:26 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-01 19:23:12 +03:00
|
|
|
return parse_option(o, "codec:s", arg, options);
|
|
|
|
}
|
|
|
|
|
2012-08-11 17:30:26 +03:00
|
|
|
static int opt_data_codec(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-11 17:30:26 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-01 19:23:12 +03:00
|
|
|
return parse_option(o, "codec:d", arg, options);
|
|
|
|
}
|
|
|
|
|
2012-08-11 17:30:26 +03:00
|
|
|
static int opt_map(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-11 17:30:26 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-01 19:23:12 +03:00
|
|
|
StreamMap *m = NULL;
|
2018-12-29 12:47:05 +02:00
|
|
|
int i, negative = 0, file_idx, disabled = 0;
|
2023-07-14 12:28:18 +02:00
|
|
|
int ret;
|
2022-08-03 12:02:59 +02:00
|
|
|
char *map, *p;
|
2015-07-01 21:14:26 +02:00
|
|
|
char *allow_unused;
|
2012-08-01 19:23:12 +03:00
|
|
|
|
|
|
|
if (*arg == '-') {
|
|
|
|
negative = 1;
|
|
|
|
arg++;
|
|
|
|
}
|
|
|
|
map = av_strdup(arg);
|
2014-12-17 15:53:45 +02:00
|
|
|
if (!map)
|
|
|
|
return AVERROR(ENOMEM);
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2022-08-03 12:02:59 +02:00
|
|
|
#if FFMPEG_OPT_MAP_SYNC
|
2023-07-22 20:57:12 +02:00
|
|
|
{
|
|
|
|
/* parse sync stream first, just pick first matching stream */
|
|
|
|
char *sync = strchr(map, ',');
|
|
|
|
|
|
|
|
if (sync) {
|
|
|
|
*sync = 0;
|
|
|
|
av_log(NULL, AV_LOG_WARNING, "Specifying a sync stream is deprecated and has no effect\n");
|
|
|
|
}
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
2022-08-03 12:02:59 +02:00
|
|
|
#endif
|
2012-08-01 19:23:12 +03:00
|
|
|
|
|
|
|
|
|
|
|
if (map[0] == '[') {
|
|
|
|
/* this mapping refers to lavfi output */
|
|
|
|
const char *c = map + 1;
|
2023-07-14 12:28:18 +02:00
|
|
|
|
|
|
|
ret = GROW_ARRAY(o->stream_maps, o->nb_stream_maps);
|
|
|
|
if (ret < 0)
|
2023-07-22 20:55:10 +02:00
|
|
|
goto fail;
|
2023-07-14 12:28:18 +02:00
|
|
|
|
2012-08-01 19:23:12 +03:00
|
|
|
m = &o->stream_maps[o->nb_stream_maps - 1];
|
|
|
|
m->linklabel = av_get_token(&c, "]");
|
|
|
|
if (!m->linklabel) {
|
|
|
|
av_log(NULL, AV_LOG_ERROR, "Invalid output link label: %s.\n", map);
|
2023-07-22 20:55:10 +02:00
|
|
|
ret = AVERROR(EINVAL);
|
|
|
|
goto fail;
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
} else {
|
2015-07-01 21:14:26 +02:00
|
|
|
if (allow_unused = strchr(map, '?'))
|
|
|
|
*allow_unused = 0;
|
2012-08-01 19:23:12 +03:00
|
|
|
file_idx = strtol(map, &p, 0);
|
|
|
|
if (file_idx >= nb_input_files || file_idx < 0) {
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx);
|
2023-07-22 20:55:10 +02:00
|
|
|
ret = AVERROR(EINVAL);
|
|
|
|
goto fail;
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
if (negative)
|
|
|
|
/* disable some already defined maps */
|
|
|
|
for (i = 0; i < o->nb_stream_maps; i++) {
|
|
|
|
m = &o->stream_maps[i];
|
|
|
|
if (file_idx == m->file_index &&
|
|
|
|
check_stream_specifier(input_files[m->file_index]->ctx,
|
|
|
|
input_files[m->file_index]->ctx->streams[m->stream_index],
|
|
|
|
*p == ':' ? p + 1 : p) > 0)
|
|
|
|
m->disabled = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
for (i = 0; i < input_files[file_idx]->nb_streams; i++) {
|
|
|
|
if (check_stream_specifier(input_files[file_idx]->ctx, input_files[file_idx]->ctx->streams[i],
|
|
|
|
*p == ':' ? p + 1 : p) <= 0)
|
|
|
|
continue;
|
2022-11-17 10:49:27 +02:00
|
|
|
if (input_files[file_idx]->streams[i]->user_set_discard == AVDISCARD_ALL) {
|
2018-12-29 12:47:05 +02:00
|
|
|
disabled = 1;
|
|
|
|
continue;
|
|
|
|
}
|
2023-07-14 12:28:18 +02:00
|
|
|
ret = GROW_ARRAY(o->stream_maps, o->nb_stream_maps);
|
|
|
|
if (ret < 0)
|
2023-07-22 20:55:10 +02:00
|
|
|
goto fail;
|
2023-07-14 12:28:18 +02:00
|
|
|
|
2012-08-01 19:23:12 +03:00
|
|
|
m = &o->stream_maps[o->nb_stream_maps - 1];
|
|
|
|
|
|
|
|
m->file_index = file_idx;
|
|
|
|
m->stream_index = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m) {
|
2015-07-01 21:14:26 +02:00
|
|
|
if (allow_unused) {
|
|
|
|
av_log(NULL, AV_LOG_VERBOSE, "Stream map '%s' matches no streams; ignoring.\n", arg);
|
2018-12-29 12:47:05 +02:00
|
|
|
} else if (disabled) {
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches disabled streams.\n"
|
|
|
|
"To ignore this, add a trailing '?' to the map.\n", arg);
|
2023-07-22 20:55:10 +02:00
|
|
|
ret = AVERROR(EINVAL);
|
|
|
|
goto fail;
|
2015-07-01 21:14:26 +02:00
|
|
|
} else {
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n"
|
|
|
|
"To ignore this, add a trailing '?' to the map.\n", arg);
|
2023-07-22 20:55:10 +02:00
|
|
|
ret = AVERROR(EINVAL);
|
|
|
|
goto fail;
|
2015-07-01 21:14:26 +02:00
|
|
|
}
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
2023-07-22 20:55:10 +02:00
|
|
|
ret = 0;
|
|
|
|
fail:
|
2012-08-01 19:23:12 +03:00
|
|
|
av_freep(&map);
|
2023-07-22 20:55:10 +02:00
|
|
|
return ret;
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
2012-08-11 17:30:26 +03:00
|
|
|
static int opt_attach(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-11 17:30:26 +03:00
|
|
|
OptionsContext *o = optctx;
|
2023-07-14 12:28:18 +02:00
|
|
|
int ret = GROW_ARRAY(o->attachments, o->nb_attachments);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2012-08-01 19:23:12 +03:00
|
|
|
o->attachments[o->nb_attachments - 1] = arg;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-06-19 20:09:24 +02:00
|
|
|
#if FFMPEG_OPT_MAP_CHANNEL
|
2012-08-20 17:04:10 +03:00
|
|
|
static int opt_map_channel(void *optctx, const char *opt, const char *arg)
|
2012-08-09 01:26:38 +03:00
|
|
|
{
|
2012-08-20 17:04:10 +03:00
|
|
|
OptionsContext *o = optctx;
|
2023-07-14 12:28:18 +02:00
|
|
|
int n, ret;
|
2012-08-09 01:26:38 +03:00
|
|
|
AVStream *st;
|
|
|
|
AudioChannelMap *m;
|
2017-08-22 11:30:45 +02:00
|
|
|
char *allow_unused;
|
|
|
|
char *mapchan;
|
2022-06-19 20:09:24 +02:00
|
|
|
|
|
|
|
av_log(NULL, AV_LOG_WARNING,
|
|
|
|
"The -%s option is deprecated and will be removed. "
|
|
|
|
"It can be replaced by the 'pan' filter, or in some cases by "
|
|
|
|
"combinations of 'channelsplit', 'channelmap', 'amerge' filters.\n", opt);
|
|
|
|
|
2017-08-22 11:30:45 +02:00
|
|
|
mapchan = av_strdup(arg);
|
|
|
|
if (!mapchan)
|
|
|
|
return AVERROR(ENOMEM);
|
2012-08-09 01:26:38 +03:00
|
|
|
|
2023-07-14 12:28:18 +02:00
|
|
|
ret = GROW_ARRAY(o->audio_channel_maps, o->nb_audio_channel_maps);
|
|
|
|
if (ret < 0)
|
2023-07-22 20:34:18 +02:00
|
|
|
goto end;
|
2023-07-14 12:28:18 +02:00
|
|
|
|
2012-08-09 01:26:38 +03:00
|
|
|
m = &o->audio_channel_maps[o->nb_audio_channel_maps - 1];
|
|
|
|
|
|
|
|
/* muted channel syntax */
|
|
|
|
n = sscanf(arg, "%d:%d.%d", &m->channel_idx, &m->ofile_idx, &m->ostream_idx);
|
|
|
|
if ((n == 1 || n == 3) && m->channel_idx == -1) {
|
|
|
|
m->file_idx = m->stream_idx = -1;
|
|
|
|
if (n == 1)
|
|
|
|
m->ofile_idx = m->ostream_idx = -1;
|
2017-08-22 11:30:45 +02:00
|
|
|
av_free(mapchan);
|
2012-08-09 01:26:38 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* normal syntax */
|
|
|
|
n = sscanf(arg, "%d.%d.%d:%d.%d",
|
|
|
|
&m->file_idx, &m->stream_idx, &m->channel_idx,
|
|
|
|
&m->ofile_idx, &m->ostream_idx);
|
|
|
|
|
|
|
|
if (n != 3 && n != 5) {
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "Syntax error, mapchan usage: "
|
|
|
|
"[file.stream.channel|-1][:syncfile:syncstream]\n");
|
2023-07-14 13:49:49 +02:00
|
|
|
goto fail;
|
2012-08-09 01:26:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (n != 5) // only file.stream.channel specified
|
|
|
|
m->ofile_idx = m->ostream_idx = -1;
|
|
|
|
|
|
|
|
/* check input */
|
|
|
|
if (m->file_idx < 0 || m->file_idx >= nb_input_files) {
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "mapchan: invalid input file index: %d\n",
|
|
|
|
m->file_idx);
|
2023-07-14 13:49:49 +02:00
|
|
|
goto fail;
|
2012-08-09 01:26:38 +03:00
|
|
|
}
|
|
|
|
if (m->stream_idx < 0 ||
|
|
|
|
m->stream_idx >= input_files[m->file_idx]->nb_streams) {
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "mapchan: invalid input file stream index #%d.%d\n",
|
|
|
|
m->file_idx, m->stream_idx);
|
2023-07-14 13:49:49 +02:00
|
|
|
goto fail;
|
2012-08-09 01:26:38 +03:00
|
|
|
}
|
|
|
|
st = input_files[m->file_idx]->ctx->streams[m->stream_idx];
|
2016-09-01 16:48:45 +02:00
|
|
|
if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) {
|
2012-08-09 01:26:38 +03:00
|
|
|
av_log(NULL, AV_LOG_FATAL, "mapchan: stream #%d.%d is not an audio stream.\n",
|
|
|
|
m->file_idx, m->stream_idx);
|
2023-07-14 13:49:49 +02:00
|
|
|
goto fail;
|
2012-08-09 01:26:38 +03:00
|
|
|
}
|
2017-08-22 11:30:45 +02:00
|
|
|
/* allow trailing ? to map_channel */
|
|
|
|
if (allow_unused = strchr(mapchan, '?'))
|
|
|
|
*allow_unused = 0;
|
2021-09-03 02:04:30 +02:00
|
|
|
if (m->channel_idx < 0 || m->channel_idx >= st->codecpar->ch_layout.nb_channels ||
|
2022-11-17 10:49:27 +02:00
|
|
|
input_files[m->file_idx]->streams[m->stream_idx]->user_set_discard == AVDISCARD_ALL) {
|
2017-08-22 11:30:45 +02:00
|
|
|
if (allow_unused) {
|
|
|
|
av_log(NULL, AV_LOG_VERBOSE, "mapchan: invalid audio channel #%d.%d.%d\n",
|
|
|
|
m->file_idx, m->stream_idx, m->channel_idx);
|
|
|
|
} else {
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "mapchan: invalid audio channel #%d.%d.%d\n"
|
|
|
|
"To ignore this, add a trailing '?' to the map_channel.\n",
|
|
|
|
m->file_idx, m->stream_idx, m->channel_idx);
|
2023-07-14 13:49:49 +02:00
|
|
|
goto fail;
|
2017-08-22 11:30:45 +02:00
|
|
|
}
|
|
|
|
|
2012-08-09 01:26:38 +03:00
|
|
|
}
|
2023-07-22 20:34:18 +02:00
|
|
|
ret = 0;
|
|
|
|
end:
|
2017-08-22 11:30:45 +02:00
|
|
|
av_free(mapchan);
|
2023-07-22 20:34:18 +02:00
|
|
|
return ret;
|
2023-07-14 13:49:49 +02:00
|
|
|
fail:
|
2023-07-22 20:34:18 +02:00
|
|
|
ret = AVERROR(EINVAL);
|
|
|
|
goto end;
|
2012-08-09 01:26:38 +03:00
|
|
|
}
|
2022-06-19 20:09:24 +02:00
|
|
|
#endif
|
2012-08-09 01:26:38 +03:00
|
|
|
|
2014-12-25 23:56:06 +02:00
|
|
|
static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
|
|
|
|
{
|
2023-07-18 16:37:52 +02:00
|
|
|
Scheduler *sch = optctx;
|
|
|
|
return sch_sdp_filename(sch, arg);
|
2014-12-25 23:56:06 +02:00
|
|
|
}
|
|
|
|
|
2016-03-24 01:48:13 +02:00
|
|
|
#if CONFIG_VAAPI
|
|
|
|
static int opt_vaapi_device(void *optctx, const char *opt, const char *arg)
|
|
|
|
{
|
2017-03-05 01:57:31 +02:00
|
|
|
const char *prefix = "vaapi:";
|
|
|
|
char *tmp;
|
2016-03-24 01:48:13 +02:00
|
|
|
int err;
|
2017-03-05 01:57:31 +02:00
|
|
|
tmp = av_asprintf("%s%s", prefix, arg);
|
|
|
|
if (!tmp)
|
|
|
|
return AVERROR(ENOMEM);
|
2020-04-13 17:33:21 +02:00
|
|
|
err = hw_device_init_from_string(tmp, NULL);
|
2017-03-05 01:57:31 +02:00
|
|
|
av_free(tmp);
|
2020-04-13 17:33:21 +02:00
|
|
|
return err;
|
2016-03-24 01:48:13 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-08-11 08:01:54 +02:00
|
|
|
#if CONFIG_QSV
|
|
|
|
static int opt_qsv_device(void *optctx, const char *opt, const char *arg)
|
|
|
|
{
|
|
|
|
const char *prefix = "qsv=__qsv_device:hw_any,child_device=";
|
|
|
|
int err;
|
|
|
|
char *tmp = av_asprintf("%s%s", prefix, arg);
|
|
|
|
|
|
|
|
if (!tmp)
|
|
|
|
return AVERROR(ENOMEM);
|
|
|
|
|
|
|
|
err = hw_device_init_from_string(tmp, NULL);
|
|
|
|
av_free(tmp);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-03-05 01:57:30 +02:00
|
|
|
static int opt_init_hw_device(void *optctx, const char *opt, const char *arg)
|
|
|
|
{
|
|
|
|
if (!strcmp(arg, "list")) {
|
|
|
|
enum AVHWDeviceType type = AV_HWDEVICE_TYPE_NONE;
|
|
|
|
printf("Supported hardware device types:\n");
|
|
|
|
while ((type = av_hwdevice_iterate_types(type)) !=
|
|
|
|
AV_HWDEVICE_TYPE_NONE)
|
|
|
|
printf("%s\n", av_hwdevice_get_type_name(type));
|
|
|
|
printf("\n");
|
2023-07-14 13:49:49 +02:00
|
|
|
return AVERROR_EXIT;
|
2017-03-05 01:57:30 +02:00
|
|
|
} else {
|
|
|
|
return hw_device_init_from_string(arg, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 01:57:38 +02:00
|
|
|
static int opt_filter_hw_device(void *optctx, const char *opt, const char *arg)
|
|
|
|
{
|
|
|
|
if (filter_hw_device) {
|
|
|
|
av_log(NULL, AV_LOG_ERROR, "Only one filter device can be used.\n");
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
}
|
|
|
|
filter_hw_device = hw_device_get_by_name(arg);
|
|
|
|
if (!filter_hw_device) {
|
|
|
|
av_log(NULL, AV_LOG_ERROR, "Invalid filter device %s.\n", arg);
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-20 17:04:10 +03:00
|
|
|
static int opt_recording_timestamp(void *optctx, const char *opt, const char *arg)
|
2012-08-09 01:26:38 +03:00
|
|
|
{
|
2012-08-20 17:04:10 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-09 01:26:38 +03:00
|
|
|
char buf[128];
|
2023-07-14 16:37:19 +02:00
|
|
|
int64_t recording_timestamp;
|
|
|
|
int ret;
|
|
|
|
struct tm time;
|
|
|
|
|
|
|
|
ret = av_parse_time(&recording_timestamp, arg, 0);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
recording_timestamp /= 1e6;
|
|
|
|
time = *gmtime((time_t*)&recording_timestamp);
|
2015-01-20 23:33:00 +02:00
|
|
|
if (!strftime(buf, sizeof(buf), "creation_time=%Y-%m-%dT%H:%M:%S%z", &time))
|
2014-10-26 16:52:12 +02:00
|
|
|
return -1;
|
2012-08-09 01:26:38 +03:00
|
|
|
parse_option(o, "metadata", buf, options);
|
|
|
|
|
|
|
|
av_log(NULL, AV_LOG_WARNING, "%s is deprecated, set the 'creation_time' metadata "
|
|
|
|
"tag instead.\n", opt);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-07-14 13:47:23 +02:00
|
|
|
int find_codec(void *logctx, const char *name,
|
|
|
|
enum AVMediaType type, int encoder, const AVCodec **pcodec)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-11 16:40:12 +03:00
|
|
|
const AVCodecDescriptor *desc;
|
2012-08-01 19:23:12 +03:00
|
|
|
const char *codec_string = encoder ? "encoder" : "decoder";
|
2021-02-25 06:32:20 +02:00
|
|
|
const AVCodec *codec;
|
2012-08-01 19:23:12 +03:00
|
|
|
|
|
|
|
codec = encoder ?
|
|
|
|
avcodec_find_encoder_by_name(name) :
|
|
|
|
avcodec_find_decoder_by_name(name);
|
2012-08-11 16:40:12 +03:00
|
|
|
|
|
|
|
if (!codec && (desc = avcodec_descriptor_get_by_name(name))) {
|
|
|
|
codec = encoder ? avcodec_find_encoder(desc->id) :
|
|
|
|
avcodec_find_decoder(desc->id);
|
|
|
|
if (codec)
|
2023-01-28 11:06:20 +02:00
|
|
|
av_log(logctx, AV_LOG_VERBOSE, "Matched %s '%s' for codec '%s'.\n",
|
2012-08-11 16:40:12 +03:00
|
|
|
codec_string, codec->name, desc->name);
|
|
|
|
}
|
|
|
|
|
2012-08-01 19:23:12 +03:00
|
|
|
if (!codec) {
|
2023-01-28 11:06:20 +02:00
|
|
|
av_log(logctx, AV_LOG_FATAL, "Unknown %s '%s'\n", codec_string, name);
|
2023-07-14 13:47:23 +02:00
|
|
|
return encoder ? AVERROR_ENCODER_NOT_FOUND :
|
|
|
|
AVERROR_DECODER_NOT_FOUND;
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
2021-07-02 12:00:21 +02:00
|
|
|
if (codec->type != type && !recast_media) {
|
2023-01-28 11:06:20 +02:00
|
|
|
av_log(logctx, AV_LOG_FATAL, "Invalid %s type '%s'\n", codec_string, name);
|
2023-07-14 13:47:23 +02:00
|
|
|
return AVERROR(EINVAL);
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
2023-07-14 13:47:23 +02:00
|
|
|
|
|
|
|
*pcodec = codec;
|
|
|
|
return 0;;
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
2023-07-12 13:09:14 +02:00
|
|
|
int assert_file_overwrite(const char *filename)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2018-08-26 07:52:50 +02:00
|
|
|
const char *proto_name = avio_find_protocol_name(filename);
|
|
|
|
|
2013-08-01 14:16:56 +03:00
|
|
|
if (file_overwrite && no_file_overwrite) {
|
2013-07-31 15:48:49 +03:00
|
|
|
fprintf(stderr, "Error, both -y and -n supplied. Exiting.\n");
|
2023-07-12 13:09:14 +02:00
|
|
|
return AVERROR(EINVAL);
|
2013-07-31 15:48:49 +03:00
|
|
|
}
|
|
|
|
|
2014-01-05 05:06:20 +03:00
|
|
|
if (!file_overwrite) {
|
|
|
|
if (proto_name && !strcmp(proto_name, "file") && avio_check(filename, 0) == 0) {
|
2013-08-01 14:16:56 +03:00
|
|
|
if (stdin_interaction && !no_file_overwrite) {
|
2019-09-28 01:17:15 +02:00
|
|
|
fprintf(stderr,"File '%s' already exists. Overwrite? [y/N] ", filename);
|
2012-08-01 19:23:12 +03:00
|
|
|
fflush(stderr);
|
2012-08-09 01:26:38 +03:00
|
|
|
term_exit();
|
|
|
|
signal(SIGINT, SIG_DFL);
|
2012-08-01 19:23:12 +03:00
|
|
|
if (!read_yesno()) {
|
2012-08-09 01:26:38 +03:00
|
|
|
av_log(NULL, AV_LOG_FATAL, "Not overwriting - exiting\n");
|
2023-07-12 13:09:14 +02:00
|
|
|
return AVERROR_EXIT;
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
2012-08-09 01:26:38 +03:00
|
|
|
term_init();
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
else {
|
2012-08-09 01:26:38 +03:00
|
|
|
av_log(NULL, AV_LOG_FATAL, "File '%s' already exists. Exiting.\n", filename);
|
2023-07-12 13:09:14 +02:00
|
|
|
return AVERROR_EXIT;
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-08-26 07:52:50 +02:00
|
|
|
|
|
|
|
if (proto_name && !strcmp(proto_name, "file")) {
|
|
|
|
for (int i = 0; i < nb_input_files; i++) {
|
|
|
|
InputFile *file = input_files[i];
|
|
|
|
if (file->ctx->iformat->flags & AVFMT_NOFILE)
|
|
|
|
continue;
|
|
|
|
if (!strcmp(filename, file->ctx->url)) {
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "Output %s same as Input #%d - exiting\n", filename, i);
|
|
|
|
av_log(NULL, AV_LOG_WARNING, "FFmpeg cannot edit existing files in-place.\n");
|
2023-07-12 13:09:14 +02:00
|
|
|
return AVERROR(EINVAL);
|
2018-08-26 07:52:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-12 13:09:14 +02:00
|
|
|
|
|
|
|
return 0;
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
2013-03-13 16:24:45 +03:00
|
|
|
/* read file contents into a string */
|
2022-10-20 09:09:45 +02:00
|
|
|
char *file_read(const char *filename)
|
2013-03-13 16:24:45 +03:00
|
|
|
{
|
|
|
|
AVIOContext *pb = NULL;
|
|
|
|
int ret = avio_open(&pb, filename, AVIO_FLAG_READ);
|
2021-12-01 21:31:27 +02:00
|
|
|
AVBPrint bprint;
|
|
|
|
char *str;
|
2013-03-13 16:24:45 +03:00
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
av_log(NULL, AV_LOG_ERROR, "Error opening file %s.\n", filename);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-12-01 21:31:27 +02:00
|
|
|
av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED);
|
|
|
|
ret = avio_read_to_bprint(pb, &bprint, SIZE_MAX);
|
|
|
|
avio_closep(&pb);
|
2013-03-13 16:24:45 +03:00
|
|
|
if (ret < 0) {
|
2021-12-01 21:31:27 +02:00
|
|
|
av_bprint_finalize(&bprint, NULL);
|
2013-03-13 16:24:45 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
2021-12-01 21:31:27 +02:00
|
|
|
ret = av_bprint_finalize(&bprint, &str);
|
2013-03-13 16:24:45 +03:00
|
|
|
if (ret < 0)
|
|
|
|
return NULL;
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2022-10-13 12:24:43 +02:00
|
|
|
/* arg format is "output-stream-index:streamid-value". */
|
|
|
|
static int opt_streamid(void *optctx, const char *opt, const char *arg)
|
2013-03-13 16:24:45 +03:00
|
|
|
{
|
2022-10-13 12:24:43 +02:00
|
|
|
OptionsContext *o = optctx;
|
|
|
|
char *p;
|
|
|
|
char idx_str[16];
|
2013-03-13 16:24:45 +03:00
|
|
|
|
2022-10-13 12:24:43 +02:00
|
|
|
av_strlcpy(idx_str, arg, sizeof(idx_str));
|
|
|
|
p = strchr(idx_str, ':');
|
|
|
|
if (!p) {
|
|
|
|
av_log(NULL, AV_LOG_FATAL,
|
|
|
|
"Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
|
|
|
|
arg, opt);
|
2023-07-13 17:36:57 +02:00
|
|
|
return AVERROR(EINVAL);
|
2013-11-03 12:50:16 +03:00
|
|
|
}
|
2022-10-13 12:24:43 +02:00
|
|
|
*p++ = '\0';
|
2023-07-13 17:36:57 +02:00
|
|
|
|
|
|
|
return av_dict_set(&o->streamid, idx_str, p, 0);
|
2013-11-03 12:50:16 +03:00
|
|
|
}
|
|
|
|
|
2022-10-13 12:24:43 +02:00
|
|
|
static int init_complex_filters(void)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2022-10-13 12:24:43 +02:00
|
|
|
int i, ret = 0;
|
2012-08-09 01:26:38 +03:00
|
|
|
|
2022-10-13 12:24:43 +02:00
|
|
|
for (i = 0; i < nb_filtergraphs; i++) {
|
|
|
|
ret = init_complex_filtergraph(filtergraphs[i]);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2013-04-09 12:21:47 +03:00
|
|
|
}
|
2012-06-08 22:35:16 +03:00
|
|
|
return 0;
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
2012-08-11 17:30:26 +03:00
|
|
|
static int opt_target(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-11 17:30:26 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-01 19:23:12 +03:00
|
|
|
enum { PAL, NTSC, FILM, UNKNOWN } norm = UNKNOWN;
|
|
|
|
static const char *const frame_rates[] = { "25", "30000/1001", "24000/1001" };
|
|
|
|
|
|
|
|
if (!strncmp(arg, "pal-", 4)) {
|
|
|
|
norm = PAL;
|
|
|
|
arg += 4;
|
|
|
|
} else if (!strncmp(arg, "ntsc-", 5)) {
|
|
|
|
norm = NTSC;
|
|
|
|
arg += 5;
|
|
|
|
} else if (!strncmp(arg, "film-", 5)) {
|
|
|
|
norm = FILM;
|
|
|
|
arg += 5;
|
|
|
|
} else {
|
|
|
|
/* Try to determine PAL/NTSC by peeking in the input files */
|
|
|
|
if (nb_input_files) {
|
2019-09-16 17:55:01 +02:00
|
|
|
int i, j;
|
2012-08-01 19:23:12 +03:00
|
|
|
for (j = 0; j < nb_input_files; j++) {
|
|
|
|
for (i = 0; i < input_files[j]->nb_streams; i++) {
|
2016-09-01 16:48:45 +02:00
|
|
|
AVStream *st = input_files[j]->ctx->streams[i];
|
2019-09-16 17:55:01 +02:00
|
|
|
int64_t fr;
|
2016-09-01 16:48:45 +02:00
|
|
|
if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
|
2012-08-01 19:23:12 +03:00
|
|
|
continue;
|
2019-09-16 17:55:01 +02:00
|
|
|
fr = st->time_base.den * 1000LL / st->time_base.num;
|
2012-08-01 19:23:12 +03:00
|
|
|
if (fr == 25000) {
|
|
|
|
norm = PAL;
|
|
|
|
break;
|
|
|
|
} else if ((fr == 29970) || (fr == 23976)) {
|
|
|
|
norm = NTSC;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (norm != UNKNOWN)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (norm != UNKNOWN)
|
|
|
|
av_log(NULL, AV_LOG_INFO, "Assuming %s for target.\n", norm == PAL ? "PAL" : "NTSC");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (norm == UNKNOWN) {
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "or set a framerate with \"-r xxx\".\n");
|
2023-07-14 13:49:49 +02:00
|
|
|
return AVERROR(EINVAL);
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(arg, "vcd")) {
|
|
|
|
opt_video_codec(o, "c:v", "mpeg1video");
|
|
|
|
opt_audio_codec(o, "c:a", "mp2");
|
|
|
|
parse_option(o, "f", "vcd", options);
|
|
|
|
|
|
|
|
parse_option(o, "s", norm == PAL ? "352x288" : "352x240", options);
|
|
|
|
parse_option(o, "r", frame_rates[norm], options);
|
2014-08-27 14:13:51 +03:00
|
|
|
opt_default(NULL, "g", norm == PAL ? "15" : "18");
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2014-08-27 14:13:51 +03:00
|
|
|
opt_default(NULL, "b:v", "1150000");
|
2015-05-25 12:13:53 +02:00
|
|
|
opt_default(NULL, "maxrate:v", "1150000");
|
|
|
|
opt_default(NULL, "minrate:v", "1150000");
|
|
|
|
opt_default(NULL, "bufsize:v", "327680"); // 40*1024*8;
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2014-08-27 14:13:51 +03:00
|
|
|
opt_default(NULL, "b:a", "224000");
|
2012-08-01 19:23:12 +03:00
|
|
|
parse_option(o, "ar", "44100", options);
|
|
|
|
parse_option(o, "ac", "2", options);
|
|
|
|
|
2014-08-27 14:13:51 +03:00
|
|
|
opt_default(NULL, "packetsize", "2324");
|
|
|
|
opt_default(NULL, "muxrate", "1411200"); // 2352 * 75 * 8;
|
2012-08-01 19:23:12 +03:00
|
|
|
|
|
|
|
/* We have to offset the PTS, so that it is consistent with the SCR.
|
|
|
|
SCR starts at 36000, but the first two packs contain only padding
|
|
|
|
and the first pack from the other stream, respectively, may also have
|
|
|
|
been written before.
|
|
|
|
So the real data starts at SCR 36000+3*1200. */
|
|
|
|
o->mux_preload = (36000 + 3 * 1200) / 90000.0; // 0.44
|
|
|
|
} else if (!strcmp(arg, "svcd")) {
|
|
|
|
|
|
|
|
opt_video_codec(o, "c:v", "mpeg2video");
|
|
|
|
opt_audio_codec(o, "c:a", "mp2");
|
|
|
|
parse_option(o, "f", "svcd", options);
|
|
|
|
|
|
|
|
parse_option(o, "s", norm == PAL ? "480x576" : "480x480", options);
|
|
|
|
parse_option(o, "r", frame_rates[norm], options);
|
2012-08-09 01:26:38 +03:00
|
|
|
parse_option(o, "pix_fmt", "yuv420p", options);
|
2014-08-27 14:13:51 +03:00
|
|
|
opt_default(NULL, "g", norm == PAL ? "15" : "18");
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2014-08-27 14:13:51 +03:00
|
|
|
opt_default(NULL, "b:v", "2040000");
|
2015-05-25 12:13:53 +02:00
|
|
|
opt_default(NULL, "maxrate:v", "2516000");
|
|
|
|
opt_default(NULL, "minrate:v", "0"); // 1145000;
|
|
|
|
opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;
|
2014-08-27 14:13:51 +03:00
|
|
|
opt_default(NULL, "scan_offset", "1");
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2014-08-27 14:13:51 +03:00
|
|
|
opt_default(NULL, "b:a", "224000");
|
2012-08-01 19:23:12 +03:00
|
|
|
parse_option(o, "ar", "44100", options);
|
|
|
|
|
2014-08-27 14:13:51 +03:00
|
|
|
opt_default(NULL, "packetsize", "2324");
|
2012-08-01 19:23:12 +03:00
|
|
|
|
|
|
|
} else if (!strcmp(arg, "dvd")) {
|
|
|
|
|
|
|
|
opt_video_codec(o, "c:v", "mpeg2video");
|
|
|
|
opt_audio_codec(o, "c:a", "ac3");
|
|
|
|
parse_option(o, "f", "dvd", options);
|
|
|
|
|
|
|
|
parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
|
|
|
|
parse_option(o, "r", frame_rates[norm], options);
|
2012-08-09 01:26:38 +03:00
|
|
|
parse_option(o, "pix_fmt", "yuv420p", options);
|
2014-08-27 14:13:51 +03:00
|
|
|
opt_default(NULL, "g", norm == PAL ? "15" : "18");
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2014-08-27 14:13:51 +03:00
|
|
|
opt_default(NULL, "b:v", "6000000");
|
2015-05-25 12:13:53 +02:00
|
|
|
opt_default(NULL, "maxrate:v", "9000000");
|
|
|
|
opt_default(NULL, "minrate:v", "0"); // 1500000;
|
|
|
|
opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2014-08-27 14:13:51 +03:00
|
|
|
opt_default(NULL, "packetsize", "2048"); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
|
|
|
|
opt_default(NULL, "muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2014-08-27 14:13:51 +03:00
|
|
|
opt_default(NULL, "b:a", "448000");
|
2012-08-01 19:23:12 +03:00
|
|
|
parse_option(o, "ar", "48000", options);
|
|
|
|
|
|
|
|
} else if (!strncmp(arg, "dv", 2)) {
|
|
|
|
|
|
|
|
parse_option(o, "f", "dv", options);
|
|
|
|
|
|
|
|
parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
|
|
|
|
parse_option(o, "pix_fmt", !strncmp(arg, "dv50", 4) ? "yuv422p" :
|
|
|
|
norm == PAL ? "yuv420p" : "yuv411p", options);
|
|
|
|
parse_option(o, "r", frame_rates[norm], options);
|
|
|
|
|
|
|
|
parse_option(o, "ar", "48000", options);
|
|
|
|
parse_option(o, "ac", "2", options);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
av_log(NULL, AV_LOG_ERROR, "Unknown target: %s\n", arg);
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
}
|
2014-08-26 09:26:35 +03:00
|
|
|
|
2014-08-27 14:13:51 +03:00
|
|
|
av_dict_copy(&o->g->codec_opts, codec_opts, AV_DICT_DONT_OVERWRITE);
|
|
|
|
av_dict_copy(&o->g->format_opts, format_opts, AV_DICT_DONT_OVERWRITE);
|
2014-08-26 09:26:35 +03:00
|
|
|
|
2012-08-01 19:23:12 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-29 15:37:22 +03:00
|
|
|
static int opt_vstats_file(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
|
|
|
av_free (vstats_filename);
|
|
|
|
vstats_filename = av_strdup (arg);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-29 15:37:22 +03:00
|
|
|
static int opt_vstats(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
|
|
|
char filename[40];
|
|
|
|
time_t today2 = time(NULL);
|
|
|
|
struct tm *today = localtime(&today2);
|
|
|
|
|
2015-06-12 14:39:17 +02:00
|
|
|
if (!today) { // maybe tomorrow
|
2015-06-12 22:34:53 +02:00
|
|
|
av_log(NULL, AV_LOG_FATAL, "Unable to get current time: %s\n", strerror(errno));
|
2023-07-14 13:49:49 +02:00
|
|
|
return AVERROR(errno);
|
2015-06-12 14:39:17 +02:00
|
|
|
}
|
2015-06-12 15:36:20 +02:00
|
|
|
|
2012-08-01 19:23:12 +03:00
|
|
|
snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
|
|
|
|
today->tm_sec);
|
2012-08-29 15:37:22 +03:00
|
|
|
return opt_vstats_file(NULL, opt, filename);
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
2012-08-11 17:30:26 +03:00
|
|
|
static int opt_video_frames(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-11 17:30:26 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-01 19:23:12 +03:00
|
|
|
return parse_option(o, "frames:v", arg, options);
|
|
|
|
}
|
|
|
|
|
2012-08-11 17:30:26 +03:00
|
|
|
static int opt_audio_frames(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-11 17:30:26 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-01 19:23:12 +03:00
|
|
|
return parse_option(o, "frames:a", arg, options);
|
|
|
|
}
|
|
|
|
|
2012-08-11 17:30:26 +03:00
|
|
|
static int opt_data_frames(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-11 17:30:26 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-01 19:23:12 +03:00
|
|
|
return parse_option(o, "frames:d", arg, options);
|
|
|
|
}
|
|
|
|
|
2012-12-20 04:38:02 +03:00
|
|
|
static int opt_default_new(OptionsContext *o, const char *opt, const char *arg)
|
|
|
|
{
|
|
|
|
int ret;
|
2012-12-20 06:21:29 +03:00
|
|
|
AVDictionary *cbak = codec_opts;
|
|
|
|
AVDictionary *fbak = format_opts;
|
2012-12-20 04:38:02 +03:00
|
|
|
codec_opts = NULL;
|
|
|
|
format_opts = NULL;
|
|
|
|
|
|
|
|
ret = opt_default(NULL, opt, arg);
|
|
|
|
|
|
|
|
av_dict_copy(&o->g->codec_opts , codec_opts, 0);
|
|
|
|
av_dict_copy(&o->g->format_opts, format_opts, 0);
|
|
|
|
av_dict_free(&codec_opts);
|
|
|
|
av_dict_free(&format_opts);
|
|
|
|
codec_opts = cbak;
|
|
|
|
format_opts = fbak;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-08-20 17:04:10 +03:00
|
|
|
static int opt_preset(void *optctx, const char *opt, const char *arg)
|
2012-08-09 01:26:38 +03:00
|
|
|
{
|
2012-08-20 17:04:10 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-09 01:26:38 +03:00
|
|
|
FILE *f=NULL;
|
|
|
|
char filename[1000], line[1000], tmp_line[1000];
|
2012-09-22 19:16:49 +03:00
|
|
|
const char *codec_name = NULL;
|
2023-07-14 13:49:49 +02:00
|
|
|
int ret = 0;
|
2012-09-22 19:16:49 +03:00
|
|
|
|
2023-12-17 15:42:38 +02:00
|
|
|
codec_name = opt_match_per_type_str(&o->codec_names, *opt);
|
2012-08-09 01:26:38 +03:00
|
|
|
|
|
|
|
if (!(f = get_preset_file(filename, sizeof(filename), arg, *opt == 'f', codec_name))) {
|
|
|
|
if(!strncmp(arg, "libx264-lossless", strlen("libx264-lossless"))){
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "Please use -preset <speed> -qp 0\n");
|
|
|
|
}else
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "File for preset '%s' not found\n", arg);
|
2023-07-14 13:49:49 +02:00
|
|
|
return AVERROR(ENOENT);
|
2012-12-20 04:38:02 +03:00
|
|
|
}
|
2012-08-09 01:26:38 +03:00
|
|
|
|
|
|
|
while (fgets(line, sizeof(line), f)) {
|
|
|
|
char *key = tmp_line, *value, *endptr;
|
|
|
|
|
|
|
|
if (strcspn(line, "#\n\r") == 0)
|
|
|
|
continue;
|
2013-03-26 03:50:23 +03:00
|
|
|
av_strlcpy(tmp_line, line, sizeof(tmp_line));
|
2012-08-09 01:26:38 +03:00
|
|
|
if (!av_strtok(key, "=", &value) ||
|
|
|
|
!av_strtok(value, "\r\n", &endptr)) {
|
|
|
|
av_log(NULL, AV_LOG_FATAL, "%s: Invalid syntax: '%s'\n", filename, line);
|
2023-07-14 13:49:49 +02:00
|
|
|
ret = AVERROR(EINVAL);
|
|
|
|
goto fail;
|
2012-08-09 01:26:38 +03:00
|
|
|
}
|
|
|
|
av_log(NULL, AV_LOG_DEBUG, "ffpreset[%s]: set '%s' = '%s'\n", filename, key, value);
|
|
|
|
|
|
|
|
if (!strcmp(key, "acodec")) opt_audio_codec (o, key, value);
|
|
|
|
else if (!strcmp(key, "vcodec")) opt_video_codec (o, key, value);
|
|
|
|
else if (!strcmp(key, "scodec")) opt_subtitle_codec(o, key, value);
|
|
|
|
else if (!strcmp(key, "dcodec")) opt_data_codec (o, key, value);
|
2012-12-20 04:38:02 +03:00
|
|
|
else if (opt_default_new(o, key, value) < 0) {
|
2012-08-09 01:26:38 +03:00
|
|
|
av_log(NULL, AV_LOG_FATAL, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n",
|
|
|
|
filename, line, key, value);
|
2023-07-14 13:49:49 +02:00
|
|
|
ret = AVERROR(EINVAL);
|
|
|
|
goto fail;
|
2012-08-09 01:26:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-14 13:49:49 +02:00
|
|
|
fail:
|
2012-08-09 01:26:38 +03:00
|
|
|
fclose(f);
|
|
|
|
|
2023-07-14 13:49:49 +02:00
|
|
|
return ret;
|
2012-08-09 01:26:38 +03:00
|
|
|
}
|
|
|
|
|
2012-08-20 17:04:10 +03:00
|
|
|
static int opt_old2new(void *optctx, const char *opt, const char *arg)
|
2012-08-09 01:26:38 +03:00
|
|
|
{
|
2012-08-20 17:04:10 +03:00
|
|
|
OptionsContext *o = optctx;
|
2019-11-06 14:18:16 +02:00
|
|
|
int ret;
|
2012-08-09 01:26:38 +03:00
|
|
|
char *s = av_asprintf("%s:%c", opt + 1, *opt);
|
2019-10-11 18:46:05 +02:00
|
|
|
if (!s)
|
|
|
|
return AVERROR(ENOMEM);
|
2019-11-06 14:18:16 +02:00
|
|
|
ret = parse_option(o, s, arg, options);
|
2012-08-09 01:26:38 +03:00
|
|
|
av_free(s);
|
|
|
|
return ret;
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
2012-08-20 17:04:10 +03:00
|
|
|
static int opt_bitrate(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-20 17:04:10 +03:00
|
|
|
OptionsContext *o = optctx;
|
2014-06-29 03:47:49 +03:00
|
|
|
|
|
|
|
if(!strcmp(opt, "ab")){
|
|
|
|
av_dict_set(&o->g->codec_opts, "b:a", arg, 0);
|
|
|
|
return 0;
|
|
|
|
} else if(!strcmp(opt, "b")){
|
2012-08-09 01:26:38 +03:00
|
|
|
av_log(NULL, AV_LOG_WARNING, "Please use -b:a or -b:v, -b is ambiguous\n");
|
2012-12-20 04:38:02 +03:00
|
|
|
av_dict_set(&o->g->codec_opts, "b:v", arg, 0);
|
|
|
|
return 0;
|
2012-08-09 01:26:38 +03:00
|
|
|
}
|
2012-12-20 04:38:02 +03:00
|
|
|
av_dict_set(&o->g->codec_opts, opt, arg, 0);
|
|
|
|
return 0;
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
2012-08-20 17:04:10 +03:00
|
|
|
static int opt_qscale(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-20 17:04:10 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-09 01:26:38 +03:00
|
|
|
char *s;
|
|
|
|
int ret;
|
|
|
|
if(!strcmp(opt, "qscale")){
|
|
|
|
av_log(NULL, AV_LOG_WARNING, "Please use -q:a or -q:v, -qscale is ambiguous\n");
|
|
|
|
return parse_option(o, "q:v", arg, options);
|
|
|
|
}
|
|
|
|
s = av_asprintf("q%s", opt + 6);
|
2019-10-11 18:46:05 +02:00
|
|
|
if (!s)
|
|
|
|
return AVERROR(ENOMEM);
|
2012-08-09 01:26:38 +03:00
|
|
|
ret = parse_option(o, s, arg, options);
|
|
|
|
av_free(s);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-08-20 17:04:10 +03:00
|
|
|
static int opt_profile(void *optctx, const char *opt, const char *arg)
|
2012-08-09 01:26:38 +03:00
|
|
|
{
|
2012-08-20 17:04:10 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-09 01:26:38 +03:00
|
|
|
if(!strcmp(opt, "profile")){
|
|
|
|
av_log(NULL, AV_LOG_WARNING, "Please use -profile:a or -profile:v, -profile is ambiguous\n");
|
2012-12-20 04:38:02 +03:00
|
|
|
av_dict_set(&o->g->codec_opts, "profile:v", arg, 0);
|
|
|
|
return 0;
|
2012-08-09 01:26:38 +03:00
|
|
|
}
|
2012-12-20 04:38:02 +03:00
|
|
|
av_dict_set(&o->g->codec_opts, opt, arg, 0);
|
|
|
|
return 0;
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
2012-08-11 17:30:26 +03:00
|
|
|
static int opt_video_filters(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-11 17:30:26 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-01 19:23:12 +03:00
|
|
|
return parse_option(o, "filter:v", arg, options);
|
|
|
|
}
|
|
|
|
|
2012-08-11 17:30:26 +03:00
|
|
|
static int opt_audio_filters(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-11 17:30:26 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-01 19:23:12 +03:00
|
|
|
return parse_option(o, "filter:a", arg, options);
|
|
|
|
}
|
|
|
|
|
2012-08-29 15:37:22 +03:00
|
|
|
static int opt_vsync(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2022-06-07 14:06:54 +02:00
|
|
|
av_log(NULL, AV_LOG_WARNING, "-vsync is deprecated. Use -fps_mode\n");
|
2023-07-14 13:47:23 +02:00
|
|
|
return parse_and_set_vsync(arg, &video_sync_method, -1, -1, 1);
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
2012-08-20 17:04:10 +03:00
|
|
|
static int opt_timecode(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-20 17:04:10 +03:00
|
|
|
OptionsContext *o = optctx;
|
2019-11-06 14:18:16 +02:00
|
|
|
int ret;
|
2012-08-09 01:26:38 +03:00
|
|
|
char *tcr = av_asprintf("timecode=%s", arg);
|
2019-10-11 18:46:05 +02:00
|
|
|
if (!tcr)
|
|
|
|
return AVERROR(ENOMEM);
|
2019-11-06 14:18:16 +02:00
|
|
|
ret = parse_option(o, "metadata:g", tcr, options);
|
2012-08-09 01:26:38 +03:00
|
|
|
if (ret >= 0)
|
2012-12-20 04:38:02 +03:00
|
|
|
ret = av_dict_set(&o->g->codec_opts, "gop_timecode", arg, 0);
|
2012-08-09 01:26:38 +03:00
|
|
|
av_free(tcr);
|
2017-07-06 19:52:42 +02:00
|
|
|
return ret;
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
2012-08-11 17:30:26 +03:00
|
|
|
static int opt_audio_qscale(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-11 17:30:26 +03:00
|
|
|
OptionsContext *o = optctx;
|
2012-08-01 19:23:12 +03:00
|
|
|
return parse_option(o, "q:a", arg, options);
|
|
|
|
}
|
|
|
|
|
2012-08-29 15:37:22 +03:00
|
|
|
static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2023-05-18 16:56:15 +02:00
|
|
|
Scheduler *sch = optctx;
|
2023-04-18 14:11:03 +02:00
|
|
|
char *graph_desc = av_strdup(arg);
|
|
|
|
if (!graph_desc)
|
2013-03-13 16:24:45 +03:00
|
|
|
return AVERROR(ENOMEM);
|
2015-03-27 01:42:26 +02:00
|
|
|
|
2023-05-18 16:56:15 +02:00
|
|
|
return fg_create(NULL, graph_desc, sch);
|
2013-03-13 16:24:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
|
|
|
|
{
|
2023-05-18 16:56:15 +02:00
|
|
|
Scheduler *sch = optctx;
|
2022-10-20 09:09:45 +02:00
|
|
|
char *graph_desc = file_read(arg);
|
2013-03-13 16:24:45 +03:00
|
|
|
if (!graph_desc)
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
|
2023-05-18 16:56:15 +02:00
|
|
|
return fg_create(NULL, graph_desc, sch);
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
2012-08-13 21:06:25 +03:00
|
|
|
void show_help_default(const char *opt, const char *arg)
|
2012-08-01 19:23:12 +03:00
|
|
|
{
|
2012-08-14 09:56:32 +03:00
|
|
|
int show_advanced = 0, show_avoptions = 0;
|
|
|
|
|
2012-10-10 21:35:26 +03:00
|
|
|
if (opt && *opt) {
|
2012-08-14 09:56:32 +03:00
|
|
|
if (!strcmp(opt, "long"))
|
|
|
|
show_advanced = 1;
|
|
|
|
else if (!strcmp(opt, "full"))
|
|
|
|
show_advanced = show_avoptions = 1;
|
|
|
|
else
|
|
|
|
av_log(NULL, AV_LOG_ERROR, "Unknown help option '%s'.\n", opt);
|
|
|
|
}
|
2012-08-13 21:06:25 +03:00
|
|
|
|
2012-08-01 19:23:12 +03:00
|
|
|
show_usage();
|
2012-08-14 09:56:32 +03:00
|
|
|
|
|
|
|
printf("Getting help:\n"
|
|
|
|
" -h -- print basic options\n"
|
|
|
|
" -h long -- print more options\n"
|
|
|
|
" -h full -- print all options (including all format and codec specific options, very long)\n"
|
2019-11-27 07:57:02 +02:00
|
|
|
" -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf/protocol\n"
|
2012-08-14 09:56:32 +03:00
|
|
|
" See man %s for detailed description of the options.\n"
|
|
|
|
"\n", program_name);
|
|
|
|
|
2012-08-14 09:21:42 +03:00
|
|
|
show_help_options(options, "Print help / information / capabilities:",
|
2012-08-15 11:31:46 +03:00
|
|
|
OPT_EXIT, 0, 0);
|
|
|
|
|
|
|
|
show_help_options(options, "Global options (affect whole program "
|
2019-12-28 21:11:01 +02:00
|
|
|
"instead of just one file):",
|
2023-12-17 12:47:33 +02:00
|
|
|
0, OPT_PERFILE | OPT_EXIT | OPT_EXPERT, 0);
|
2012-08-15 11:31:46 +03:00
|
|
|
if (show_advanced)
|
|
|
|
show_help_options(options, "Advanced global options:", OPT_EXPERT,
|
2023-12-17 12:47:33 +02:00
|
|
|
OPT_PERFILE | OPT_EXIT, 0);
|
2012-08-15 11:31:46 +03:00
|
|
|
|
|
|
|
show_help_options(options, "Per-file main options:", 0,
|
2023-12-18 11:20:06 +02:00
|
|
|
OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE | OPT_DATA |
|
2023-12-17 12:47:33 +02:00
|
|
|
OPT_EXIT, OPT_PERFILE);
|
2012-08-14 09:56:32 +03:00
|
|
|
if (show_advanced)
|
2012-08-15 11:31:46 +03:00
|
|
|
show_help_options(options, "Advanced per-file options:",
|
2023-12-17 12:47:33 +02:00
|
|
|
OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, OPT_PERFILE);
|
2012-08-14 09:56:32 +03:00
|
|
|
|
2012-08-11 20:33:27 +03:00
|
|
|
show_help_options(options, "Video options:",
|
2023-12-18 11:20:06 +02:00
|
|
|
OPT_VIDEO, OPT_EXPERT | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA, 0);
|
2012-08-14 09:56:32 +03:00
|
|
|
if (show_advanced)
|
|
|
|
show_help_options(options, "Advanced Video options:",
|
2023-12-18 11:20:06 +02:00
|
|
|
OPT_EXPERT | OPT_VIDEO, OPT_AUDIO | OPT_SUBTITLE | OPT_DATA, 0);
|
2012-08-14 09:56:32 +03:00
|
|
|
|
2012-08-11 20:33:27 +03:00
|
|
|
show_help_options(options, "Audio options:",
|
2023-12-18 11:20:06 +02:00
|
|
|
OPT_AUDIO, OPT_EXPERT | OPT_VIDEO | OPT_SUBTITLE | OPT_DATA, 0);
|
2012-08-14 09:56:32 +03:00
|
|
|
if (show_advanced)
|
|
|
|
show_help_options(options, "Advanced Audio options:",
|
2023-12-18 11:20:06 +02:00
|
|
|
OPT_EXPERT | OPT_AUDIO, OPT_VIDEO | OPT_SUBTITLE | OPT_DATA, 0);
|
|
|
|
|
2012-08-11 20:33:27 +03:00
|
|
|
show_help_options(options, "Subtitle options:",
|
2023-12-18 11:20:06 +02:00
|
|
|
OPT_SUBTITLE, OPT_EXPERT | OPT_VIDEO | OPT_AUDIO | OPT_DATA, 0);
|
|
|
|
if (show_advanced)
|
|
|
|
show_help_options(options, "Advanced Subtitle options:",
|
|
|
|
OPT_EXPERT | OPT_SUBTITLE, OPT_VIDEO | OPT_AUDIO | OPT_DATA, 0);
|
2023-12-18 11:24:45 +02:00
|
|
|
|
|
|
|
if (show_advanced)
|
|
|
|
show_help_options(options, "Data stream options:",
|
|
|
|
OPT_DATA, OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE, 0);
|
2012-08-01 19:23:12 +03:00
|
|
|
printf("\n");
|
2012-08-14 09:56:32 +03:00
|
|
|
|
|
|
|
if (show_avoptions) {
|
|
|
|
int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;
|
|
|
|
show_help_children(avcodec_get_class(), flags);
|
|
|
|
show_help_children(avformat_get_class(), flags);
|
2013-10-08 17:48:52 +03:00
|
|
|
#if CONFIG_SWSCALE
|
2012-08-14 09:56:32 +03:00
|
|
|
show_help_children(sws_get_class(), flags);
|
2013-10-08 17:48:52 +03:00
|
|
|
#endif
|
2018-04-12 22:15:05 +02:00
|
|
|
#if CONFIG_SWRESAMPLE
|
2012-08-20 18:15:15 +03:00
|
|
|
show_help_children(swr_get_class(), AV_OPT_FLAG_AUDIO_PARAM);
|
2018-04-12 22:15:05 +02:00
|
|
|
#endif
|
2013-04-12 16:33:37 +03:00
|
|
|
show_help_children(avfilter_get_class(), AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM);
|
2018-03-08 07:50:31 +02:00
|
|
|
show_help_children(av_bsf_get_class(), AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_BSF_PARAM);
|
2012-08-14 09:56:32 +03:00
|
|
|
}
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void show_usage(void)
|
|
|
|
{
|
2023-12-18 10:11:44 +02:00
|
|
|
av_log(NULL, AV_LOG_INFO, "Universal media converter\n");
|
2012-08-09 01:26:38 +03:00
|
|
|
av_log(NULL, AV_LOG_INFO, "usage: %s [options] [[infile options] -i infile]... {[outfile options] outfile}...\n", program_name);
|
|
|
|
av_log(NULL, AV_LOG_INFO, "\n");
|
2012-08-01 19:23:12 +03:00
|
|
|
}
|
|
|
|
|
2012-06-08 22:35:16 +03:00
|
|
|
enum OptGroup {
|
|
|
|
GROUP_OUTFILE,
|
|
|
|
GROUP_INFILE,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const OptionGroupDef groups[] = {
|
2016-12-05 13:54:21 +02:00
|
|
|
[GROUP_OUTFILE] = { "output url", NULL, OPT_OUTPUT },
|
|
|
|
[GROUP_INFILE] = { "input url", "i", OPT_INPUT },
|
2012-06-08 22:35:16 +03:00
|
|
|
};
|
|
|
|
|
2023-05-18 16:56:15 +02:00
|
|
|
static int open_files(OptionGroupList *l, const char *inout, Scheduler *sch,
|
|
|
|
int (*open_file)(const OptionsContext*, const char*,
|
|
|
|
Scheduler*))
|
2012-06-08 22:35:16 +03:00
|
|
|
{
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
for (i = 0; i < l->nb_groups; i++) {
|
|
|
|
OptionGroup *g = &l->groups[i];
|
|
|
|
OptionsContext o;
|
|
|
|
|
2013-08-06 12:58:40 +03:00
|
|
|
init_options(&o);
|
2012-06-08 22:35:16 +03:00
|
|
|
o.g = g;
|
|
|
|
|
2023-12-17 19:10:17 +02:00
|
|
|
ret = parse_optgroup(&o, g, options);
|
2012-06-08 22:35:16 +03:00
|
|
|
if (ret < 0) {
|
|
|
|
av_log(NULL, AV_LOG_ERROR, "Error parsing options for %s file "
|
|
|
|
"%s.\n", inout, g->arg);
|
2020-02-28 23:06:29 +02:00
|
|
|
uninit_options(&o);
|
2012-06-08 22:35:16 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
av_log(NULL, AV_LOG_DEBUG, "Opening an %s file: %s.\n", inout, g->arg);
|
2023-05-18 16:56:15 +02:00
|
|
|
ret = open_file(&o, g->arg, sch);
|
2013-08-06 12:58:40 +03:00
|
|
|
uninit_options(&o);
|
2012-06-08 22:35:16 +03:00
|
|
|
if (ret < 0) {
|
|
|
|
av_log(NULL, AV_LOG_ERROR, "Error opening %s file %s.\n",
|
|
|
|
inout, g->arg);
|
|
|
|
return ret;
|
|
|
|
}
|
2013-01-25 02:44:28 +03:00
|
|
|
av_log(NULL, AV_LOG_DEBUG, "Successfully opened the file.\n");
|
2012-06-08 22:35:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-05-18 16:56:15 +02:00
|
|
|
int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
|
2012-06-08 22:35:16 +03:00
|
|
|
{
|
|
|
|
OptionParseContext octx;
|
2023-07-14 18:07:40 +02:00
|
|
|
const char *errmsg = NULL;
|
2012-06-08 22:35:16 +03:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(&octx, 0, sizeof(octx));
|
|
|
|
|
|
|
|
/* split the commandline into an internal representation */
|
2012-12-19 23:53:22 +03:00
|
|
|
ret = split_commandline(&octx, argc, argv, options, groups,
|
|
|
|
FF_ARRAY_ELEMS(groups));
|
2012-06-08 22:35:16 +03:00
|
|
|
if (ret < 0) {
|
2023-07-14 18:07:40 +02:00
|
|
|
errmsg = "splitting the argument list";
|
2012-06-08 22:35:16 +03:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* apply global options */
|
2023-12-17 19:10:17 +02:00
|
|
|
ret = parse_optgroup(sch, &octx.global_opts, options);
|
2012-06-08 22:35:16 +03:00
|
|
|
if (ret < 0) {
|
2023-07-14 18:07:40 +02:00
|
|
|
errmsg = "parsing global options";
|
2012-06-08 22:35:16 +03:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2016-09-08 02:16:27 +02:00
|
|
|
/* configure terminal and setup signal handlers */
|
|
|
|
term_init();
|
|
|
|
|
2012-06-08 22:35:16 +03:00
|
|
|
/* open input files */
|
2023-05-18 16:56:15 +02:00
|
|
|
ret = open_files(&octx.groups[GROUP_INFILE], "input", sch, ifile_open);
|
2012-06-08 22:35:16 +03:00
|
|
|
if (ret < 0) {
|
2023-07-14 18:07:40 +02:00
|
|
|
errmsg = "opening input files";
|
2012-06-08 22:35:16 +03:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2015-07-15 17:17:54 +02:00
|
|
|
/* create the complex filtergraphs */
|
2015-07-15 19:49:24 +02:00
|
|
|
ret = init_complex_filters();
|
2015-07-15 17:17:54 +02:00
|
|
|
if (ret < 0) {
|
2023-07-14 18:07:40 +02:00
|
|
|
errmsg = "initializing complex filters";
|
2015-07-15 17:17:54 +02:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2012-06-08 22:35:16 +03:00
|
|
|
/* open output files */
|
2023-05-18 16:56:15 +02:00
|
|
|
ret = open_files(&octx.groups[GROUP_OUTFILE], "output", sch, of_open);
|
2012-06-08 22:35:16 +03:00
|
|
|
if (ret < 0) {
|
2023-07-14 18:07:40 +02:00
|
|
|
errmsg = "opening output files";
|
2012-06-08 22:35:16 +03:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2022-10-21 15:07:37 +02:00
|
|
|
correct_input_start_times();
|
|
|
|
|
2023-07-14 13:49:49 +02:00
|
|
|
ret = apply_sync_offsets();
|
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
2022-10-21 15:59:25 +02:00
|
|
|
|
2023-07-13 15:11:07 +02:00
|
|
|
ret = check_filter_outputs();
|
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
2017-05-05 00:15:15 +02:00
|
|
|
|
2012-06-08 22:35:16 +03:00
|
|
|
fail:
|
|
|
|
uninit_parse_context(&octx);
|
2023-07-14 18:15:27 +02:00
|
|
|
if (ret < 0 && ret != AVERROR_EXIT) {
|
2023-07-14 18:07:40 +02:00
|
|
|
av_log(NULL, AV_LOG_FATAL, "Error %s: %s\n",
|
|
|
|
errmsg ? errmsg : "", av_err2str(ret));
|
2012-06-08 22:35:16 +03:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2012-08-31 13:04:17 +03:00
|
|
|
static int opt_progress(void *optctx, const char *opt, const char *arg)
|
2012-08-09 01:26:38 +03:00
|
|
|
{
|
|
|
|
AVIOContext *avio = NULL;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!strcmp(arg, "-"))
|
|
|
|
arg = "pipe:";
|
|
|
|
ret = avio_open2(&avio, arg, AVIO_FLAG_WRITE, &int_cb, NULL);
|
|
|
|
if (ret < 0) {
|
2012-11-23 20:10:02 +03:00
|
|
|
av_log(NULL, AV_LOG_ERROR, "Failed to open progress URL \"%s\": %s\n",
|
2012-08-09 01:26:38 +03:00
|
|
|
arg, av_err2str(ret));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
progress_avio = avio;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-03-09 13:16:16 +02:00
|
|
|
int opt_timelimit(void *optctx, const char *opt, const char *arg)
|
|
|
|
{
|
|
|
|
#if HAVE_SETRLIMIT
|
2023-07-14 13:47:23 +02:00
|
|
|
int ret;
|
|
|
|
double lim;
|
|
|
|
struct rlimit rl;
|
|
|
|
|
2023-12-15 09:50:26 +02:00
|
|
|
ret = parse_number(opt, arg, OPT_TYPE_INT64, 0, INT_MAX, &lim);
|
2023-07-14 13:47:23 +02:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
rl = (struct rlimit){ lim, lim + 1 };
|
2022-03-09 13:16:16 +02:00
|
|
|
if (setrlimit(RLIMIT_CPU, &rl))
|
|
|
|
perror("setrlimit");
|
|
|
|
#else
|
|
|
|
av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-03-28 11:48:50 +02:00
|
|
|
#if FFMPEG_OPT_QPHIST
|
|
|
|
static int opt_qphist(void *optctx, const char *opt, const char *arg)
|
|
|
|
{
|
|
|
|
av_log(NULL, AV_LOG_WARNING, "Option -%s is deprecated and has no effect\n", opt);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-04-18 20:03:23 +02:00
|
|
|
#if FFMPEG_OPT_ADRIFT_THRESHOLD
|
|
|
|
static int opt_adrift_threshold(void *optctx, const char *opt, const char *arg)
|
|
|
|
{
|
|
|
|
av_log(NULL, AV_LOG_WARNING, "Option -%s is deprecated and has no effect\n", opt);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-12-17 19:10:17 +02:00
|
|
|
static const char *const alt_bsf[] = { "absf", "vbsf", NULL };
|
|
|
|
static const char *const alt_channel_layout[] = { "ch_layout", NULL};
|
|
|
|
static const char *const alt_codec[] = { "c", "acodec", "vcodec", "scodec", "dcodec", NULL };
|
|
|
|
static const char *const alt_filter[] = { "af", "vf", NULL };
|
|
|
|
static const char *const alt_frames[] = { "aframes", "vframes", "dframes", NULL };
|
|
|
|
static const char *const alt_pre[] = { "apre", "vpre", "spre", NULL};
|
|
|
|
static const char *const alt_qscale[] = { "q", NULL};
|
|
|
|
static const char *const alt_tag[] = { "atag", "vtag", "stag", NULL };
|
|
|
|
|
2012-08-01 19:23:12 +03:00
|
|
|
#define OFFSET(x) offsetof(OptionsContext, x)
|
|
|
|
const OptionDef options[] = {
|
|
|
|
/* main options */
|
2011-05-17 18:06:57 +03:00
|
|
|
CMDUTILS_COMMON_OPTIONS
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "f", OPT_TYPE_STRING, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(format) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"force format", "fmt" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "y", OPT_TYPE_BOOL, 0,
|
|
|
|
{ &file_overwrite },
|
2012-08-11 18:00:30 +03:00
|
|
|
"overwrite output files" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "n", OPT_TYPE_BOOL, 0,
|
|
|
|
{ &no_file_overwrite },
|
2013-07-31 15:48:49 +03:00
|
|
|
"never overwrite output files" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "ignore_unknown", OPT_TYPE_BOOL, OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ &ignore_unknown_streams },
|
2015-05-21 00:49:18 +02:00
|
|
|
"Ignore unknown stream types" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "copy_unknown", OPT_TYPE_BOOL, OPT_EXPERT,
|
|
|
|
{ ©_unknown_streams },
|
2015-05-21 00:34:41 +02:00
|
|
|
"Copy unknown stream types" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "recast_media", OPT_TYPE_BOOL, OPT_EXPERT,
|
|
|
|
{ &recast_media },
|
2021-07-02 12:00:21 +02:00
|
|
|
"allow recasting stream type in order to force a decoder of different media type" },
|
2023-12-17 19:10:17 +02:00
|
|
|
{ "c", OPT_TYPE_STRING, OPT_SPEC | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(codec_names) },
|
2023-12-17 19:10:17 +02:00
|
|
|
"codec name", "codec",
|
|
|
|
.u1.name_canon = "codec", },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "codec", OPT_TYPE_STRING, OPT_SPEC | OPT_INPUT | OPT_OUTPUT | OPT_EXPERT | OPT_HAS_ALT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(codec_names) },
|
2023-12-17 19:10:17 +02:00
|
|
|
"codec name", "codec",
|
|
|
|
.u1.names_alt = alt_codec, },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "pre", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | OPT_EXPERT | OPT_HAS_ALT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(presets) },
|
2023-12-17 19:10:17 +02:00
|
|
|
"preset name", "preset",
|
|
|
|
.u1.names_alt = alt_pre, },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "map", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_map },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set input stream mapping",
|
|
|
|
"[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "map_metadata", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(metadata_map) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set metadata information of outfile from infile",
|
|
|
|
"outfile[,metadata]:infile[,metadata]" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "map_chapters", OPT_TYPE_INT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(chapters_input_file) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set chapters mapping", "input_file_index" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "t", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(recording_time) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"record or transcode \"duration\" seconds of audio/video",
|
|
|
|
"duration" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "to", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(stop_time) },
|
2013-02-27 02:18:41 +03:00
|
|
|
"record or transcode stop time", "time_stop" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "fs", OPT_TYPE_INT64, OPT_OFFSET | OPT_OUTPUT | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(limit_filesize) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set the limit file size in bytes", "limit_size" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "ss", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(start_time) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set the start time offset", "time_off" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "sseof", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(start_time_eof) },
|
2015-07-27 04:30:26 +02:00
|
|
|
"set the start time offset relative to EOF", "time_off" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "seek_timestamp", OPT_TYPE_INT, OPT_OFFSET | OPT_INPUT | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(seek_timestamp) },
|
2015-04-20 19:36:51 +02:00
|
|
|
"enable/disable seeking by timestamp with -ss" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "accurate_seek", OPT_TYPE_BOOL, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(accurate_seek) },
|
2013-06-15 10:59:40 +03:00
|
|
|
"enable/disable accurate seeking with -ss" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "isync", OPT_TYPE_INT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(input_sync_ref) },
|
2022-06-13 13:02:44 +02:00
|
|
|
"Indicate the input index for sync reference", "sync ref" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "itsoffset", OPT_TYPE_TIME, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(input_ts_offset) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set the input ts offset", "time_off" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "itsscale", OPT_TYPE_DOUBLE, OPT_SPEC | OPT_EXPERT | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(ts_scale) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set the input ts scale", "scale" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "timestamp", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_recording_timestamp },
|
2012-08-20 17:44:05 +03:00
|
|
|
"set the recording timestamp ('now' to set the current time)", "time" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "metadata", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(metadata) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"add metadata", "string=string" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "program", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(program) },
|
2015-12-10 22:01:19 +02:00
|
|
|
"add program with specified streams", "title=string:st=number..." },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "stream_group", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(stream_groups) },
|
2023-11-25 16:39:42 +02:00
|
|
|
"add stream group with specified streams and group type-specific arguments", "id=number:st=number..." },
|
2023-12-17 19:10:17 +02:00
|
|
|
{ "dframes", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_data_frames },
|
2023-12-17 19:10:17 +02:00
|
|
|
"set the number of data frames to output", "number",
|
|
|
|
.u1.name_canon = "frames" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "benchmark", OPT_TYPE_BOOL, OPT_EXPERT,
|
|
|
|
{ &do_benchmark },
|
2012-08-11 18:00:30 +03:00
|
|
|
"add timings for benchmarking" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "benchmark_all", OPT_TYPE_BOOL, OPT_EXPERT,
|
|
|
|
{ &do_benchmark_all },
|
2012-08-09 01:26:38 +03:00
|
|
|
"add timings for each task" },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "progress", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_progress },
|
2012-08-09 01:26:38 +03:00
|
|
|
"write program-readable progress information", "url" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "stdin", OPT_TYPE_BOOL, OPT_EXPERT,
|
|
|
|
{ &stdin_interaction },
|
2012-08-09 01:26:38 +03:00
|
|
|
"enable or disable interaction on standard input" },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "timelimit", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_timelimit },
|
2019-09-26 20:18:57 +02:00
|
|
|
"set max runtime in seconds in CPU user time", "limit" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "dump", OPT_TYPE_BOOL, OPT_EXPERT,
|
|
|
|
{ &do_pkt_dump },
|
2012-08-11 18:00:30 +03:00
|
|
|
"dump each input packet" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "hex", OPT_TYPE_BOOL, OPT_EXPERT,
|
|
|
|
{ &do_hex_dump },
|
2012-08-11 18:00:30 +03:00
|
|
|
"when dumping packets, also dump the payload" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "re", OPT_TYPE_BOOL, OPT_EXPERT | OPT_OFFSET | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(rate_emu) },
|
2021-07-16 14:29:39 +02:00
|
|
|
"read input at native frame rate; equivalent to -readrate 1", "" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "readrate", OPT_TYPE_FLOAT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(readrate) },
|
2021-07-16 14:29:39 +02:00
|
|
|
"read input at specified rate", "speed" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "readrate_initial_burst", OPT_TYPE_DOUBLE, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(readrate_initial_burst) },
|
2023-05-02 13:35:34 +02:00
|
|
|
"The initial amount of input to burst read before imposing any readrate", "seconds" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "target", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_target },
|
2015-09-02 14:32:06 +02:00
|
|
|
"specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\" or \"dv50\" "
|
|
|
|
"with optional prefixes \"pal-\", \"ntsc-\" or \"film-\")", "type" },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "vsync", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_vsync },
|
2022-06-07 14:06:54 +02:00
|
|
|
"set video sync method globally; deprecated, use -fps_mode", "" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "frame_drop_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
|
|
|
|
{ &frame_drop_threshold },
|
2015-01-17 05:38:32 +02:00
|
|
|
"frame drop threshold", "" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "copyts", OPT_TYPE_BOOL, OPT_EXPERT,
|
|
|
|
{ ©_ts },
|
2012-08-11 18:00:30 +03:00
|
|
|
"copy timestamps" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "start_at_zero", OPT_TYPE_BOOL, OPT_EXPERT,
|
|
|
|
{ &start_at_zero },
|
2014-10-21 02:50:12 +03:00
|
|
|
"shift input timestamps to start at 0 when using copyts" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "copytb", OPT_TYPE_INT, OPT_EXPERT,
|
|
|
|
{ ©_tb },
|
2012-08-20 17:44:05 +03:00
|
|
|
"copy input stream time base when stream copying", "mode" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "shortest", OPT_TYPE_BOOL, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(shortest) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"finish encoding within shortest input" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "shortest_buf_duration", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(shortest_buf_duration) },
|
2022-06-10 14:21:42 +02:00
|
|
|
"maximum buffering duration (in seconds) for the -shortest option" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "bitexact", OPT_TYPE_BOOL, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(bitexact) },
|
2017-10-22 01:41:57 +02:00
|
|
|
"bitexact mode" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "apad", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(apad) },
|
2013-05-09 00:43:19 +03:00
|
|
|
"audio pad", "" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "dts_delta_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
|
|
|
|
{ &dts_delta_threshold },
|
2012-08-11 18:00:30 +03:00
|
|
|
"timestamp discontinuity delta threshold", "threshold" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "dts_error_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
|
|
|
|
{ &dts_error_threshold },
|
2012-08-20 17:44:05 +03:00
|
|
|
"timestamp error delta threshold", "threshold" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "xerror", OPT_TYPE_BOOL, OPT_EXPERT,
|
|
|
|
{ &exit_on_error },
|
2012-08-11 18:00:30 +03:00
|
|
|
"exit on error", "error" },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "abort_on", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_abort_on },
|
2015-10-17 23:46:09 +02:00
|
|
|
"abort on the specified condition flags", "flags" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "copyinkf", OPT_TYPE_BOOL, OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(copy_initial_nonkeyframes) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"copy initial non-keyframes" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "copypriorss", OPT_TYPE_INT, OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(copy_prior_start) },
|
2012-09-27 04:37:27 +03:00
|
|
|
"copy or discard frames before start time" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "frames", OPT_TYPE_INT64, OPT_SPEC | OPT_OUTPUT | OPT_EXPERT | OPT_HAS_ALT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(max_frames) },
|
2023-12-17 19:10:17 +02:00
|
|
|
"set the number of frames to output", "number",
|
|
|
|
.u1.names_alt = alt_frames, },
|
|
|
|
{ "tag", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT | OPT_INPUT | OPT_HAS_ALT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(codec_tags) },
|
2023-12-17 19:10:17 +02:00
|
|
|
"force codec tag/fourcc", "fourcc/tag",
|
|
|
|
.u1.names_alt = alt_tag, },
|
|
|
|
{ "q", OPT_TYPE_DOUBLE, OPT_EXPERT | OPT_SPEC | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(qscale) },
|
2023-12-17 19:10:17 +02:00
|
|
|
"use fixed quality scale (VBR)", "q",
|
|
|
|
.u1.name_canon = "qscale", },
|
|
|
|
{ "qscale", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_ALT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_qscale },
|
2023-12-17 19:10:17 +02:00
|
|
|
"use fixed quality scale (VBR)", "q",
|
|
|
|
.u1.names_alt = alt_qscale, },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "profile", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_profile },
|
2012-08-20 17:44:05 +03:00
|
|
|
"set profile", "profile" },
|
2023-12-17 19:10:17 +02:00
|
|
|
{ "filter", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | OPT_HAS_ALT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(filters) },
|
2023-12-17 19:10:17 +02:00
|
|
|
"set stream filtergraph", "filter_graph",
|
|
|
|
.u1.names_alt = alt_filter, },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "filter_threads", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_filter_threads },
|
2016-10-30 15:25:39 +02:00
|
|
|
"number of non-complex filter threads" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "filter_script", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(filter_scripts) },
|
2013-03-13 16:24:45 +03:00
|
|
|
"read stream filtergraph description from a file", "filename" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "reinit_filter", OPT_TYPE_INT, OPT_SPEC | OPT_INPUT | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(reinit_filters) },
|
2012-10-17 00:50:06 +03:00
|
|
|
"reinit filtergraph on input parameter changes", "" },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "filter_complex", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_filter_complex },
|
2012-08-11 18:00:30 +03:00
|
|
|
"create a complex filtergraph", "graph_description" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "filter_complex_threads", OPT_TYPE_INT, OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ &filter_complex_nbthreads },
|
2016-10-30 15:25:39 +02:00
|
|
|
"number of threads for -filter_complex" },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "lavfi", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_filter_complex },
|
2013-03-16 19:08:33 +03:00
|
|
|
"create a complex filtergraph", "graph_description" },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "filter_complex_script", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_filter_complex_script },
|
2013-03-13 16:24:45 +03:00
|
|
|
"read complex filtergraph description from a file", "filename" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "auto_conversion_filters", OPT_TYPE_BOOL, OPT_EXPERT,
|
|
|
|
{ &auto_conversion_filters },
|
2020-08-14 13:06:34 +02:00
|
|
|
"enable automatic conversion filters globally" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "stats", OPT_TYPE_BOOL, 0,
|
|
|
|
{ &print_stats },
|
2012-08-11 18:00:30 +03:00
|
|
|
"print progress report during encoding", },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "stats_period", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_stats_period },
|
2020-12-21 10:46:49 +02:00
|
|
|
"set the period at which ffmpeg updates stats and -progress output", "time" },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "attach", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_attach },
|
2012-08-11 18:00:30 +03:00
|
|
|
"add an attachment to the output file", "filename" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "dump_attachment", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(dump_attachment) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"extract an attachment into a file", "filename" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "stream_loop", OPT_TYPE_INT, OPT_EXPERT | OPT_INPUT | OPT_OFFSET,
|
|
|
|
{ .off = OFFSET(loop) }, "set number of times input stream shall be looped", "loop count" },
|
|
|
|
{ "debug_ts", OPT_TYPE_BOOL, OPT_EXPERT,
|
|
|
|
{ &debug_ts },
|
2012-08-20 17:44:05 +03:00
|
|
|
"print timestamp debugging info" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "max_error_rate", OPT_TYPE_FLOAT, OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ &max_error_rate },
|
2021-01-10 15:44:37 +02:00
|
|
|
"ratio of decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.", "maximum error rate" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "discard", OPT_TYPE_STRING, OPT_SPEC | OPT_INPUT | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(discard) },
|
2014-05-31 06:53:06 +03:00
|
|
|
"discard", "" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "disposition", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(disposition) },
|
2015-01-08 23:51:25 +02:00
|
|
|
"disposition", "" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "thread_queue_size", OPT_TYPE_INT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(thread_queue_size) },
|
2015-02-25 12:50:44 +02:00
|
|
|
"set the maximum number of queued packets from the demuxer" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "find_stream_info", OPT_TYPE_BOOL, OPT_INPUT | OPT_EXPERT | OPT_OFFSET,
|
|
|
|
{ .off = OFFSET(find_stream_info) },
|
2017-07-12 11:06:52 +02:00
|
|
|
"read and decode the streams to fill missing information with heuristics" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "bits_per_raw_sample", OPT_TYPE_INT, OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
|
2021-11-23 11:18:01 +02:00
|
|
|
{ .off = OFFSET(bits_per_raw_sample) },
|
|
|
|
"set the number of bits per raw sample", "number" },
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "stats_enc_pre", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(enc_stats_pre) },
|
2022-11-25 15:00:48 +02:00
|
|
|
"write encoding stats before encoding" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "stats_enc_post", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(enc_stats_post) },
|
2022-11-25 15:00:48 +02:00
|
|
|
"write encoding stats after encoding" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "stats_mux_pre", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(mux_stats) },
|
2023-02-06 14:14:53 +02:00
|
|
|
"write packets stats before muxing" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "stats_enc_pre_fmt", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(enc_stats_pre_fmt) },
|
2023-02-09 16:12:03 +02:00
|
|
|
"format of the stats written with -stats_enc_pre" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "stats_enc_post_fmt", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(enc_stats_post_fmt) },
|
2023-02-09 16:12:03 +02:00
|
|
|
"format of the stats written with -stats_enc_post" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "stats_mux_pre_fmt", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(mux_stats_fmt) },
|
2023-02-06 14:14:53 +02:00
|
|
|
"format of the stats written with -stats_mux_pre" },
|
2022-11-25 15:00:48 +02:00
|
|
|
|
2012-08-01 19:23:12 +03:00
|
|
|
/* video options */
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "vframes", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_EXPERT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_video_frames },
|
2023-12-17 19:10:17 +02:00
|
|
|
"set the number of video frames to output", "number",
|
|
|
|
.u1.name_canon = "frames", },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "r", OPT_TYPE_STRING, OPT_VIDEO | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(frame_rates) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set frame rate (Hz value, fraction or abbreviation)", "rate" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "fpsmax", OPT_TYPE_STRING, OPT_VIDEO | OPT_SPEC | OPT_OUTPUT | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(max_frame_rates) },
|
2021-02-01 14:49:18 +02:00
|
|
|
"set max frame rate (Hz value, fraction or abbreviation)", "rate" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "s", OPT_TYPE_STRING, OPT_VIDEO | OPT_SUBTITLE | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(frame_sizes) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set frame size (WxH or abbreviation)", "size" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "aspect", OPT_TYPE_STRING, OPT_VIDEO | OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(frame_aspect_ratios) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "pix_fmt", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(frame_pix_fmts) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set pixel format", "format" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "display_rotation", OPT_TYPE_DOUBLE, OPT_VIDEO | OPT_SPEC | OPT_INPUT | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(display_rotations) },
|
2022-10-19 11:44:03 +02:00
|
|
|
"set pure counter-clockwise rotation in degrees for stream(s)",
|
|
|
|
"angle" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "display_hflip", OPT_TYPE_BOOL, OPT_VIDEO | OPT_SPEC | OPT_INPUT | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(display_hflips) },
|
2022-10-19 11:44:03 +02:00
|
|
|
"set display horizontal flip for stream(s) "
|
|
|
|
"(overrides any display rotation if it is not set)"},
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "display_vflip", OPT_TYPE_BOOL, OPT_VIDEO | OPT_SPEC | OPT_INPUT | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(display_vflips) },
|
2022-10-19 11:44:03 +02:00
|
|
|
"set display vertical flip for stream(s) "
|
|
|
|
"(overrides any display rotation if it is not set)"},
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "vn", OPT_TYPE_BOOL, OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(video_disable) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"disable video" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "rc_override", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(rc_overrides) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"rate control override for specific intervals", "override" },
|
2023-12-17 19:10:17 +02:00
|
|
|
{ "vcodec", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_video_codec },
|
2023-12-17 19:10:17 +02:00
|
|
|
"force video codec ('copy' to copy stream)", "codec",
|
|
|
|
.u1.name_canon = "codec", },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "timecode", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_timecode },
|
2012-08-20 17:44:05 +03:00
|
|
|
"set initial TimeCode value.", "hh:mm:ss[:;.]ff" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "pass", OPT_TYPE_INT, OPT_VIDEO | OPT_SPEC | OPT_OUTPUT | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(pass) },
|
2012-08-31 13:04:17 +03:00
|
|
|
"select the pass number (1 to 3)", "n" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "passlogfile", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(passlogfiles) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"select two pass log file name prefix", "prefix" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "vstats", OPT_TYPE_FUNC, OPT_VIDEO | OPT_EXPERT,
|
|
|
|
{ .func_arg = opt_vstats },
|
2012-08-11 18:00:30 +03:00
|
|
|
"dump video coding statistics to file" },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "vstats_file", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_vstats_file },
|
2012-08-11 18:00:30 +03:00
|
|
|
"dump video coding statistics to file", "file" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "vstats_version", OPT_TYPE_INT, OPT_VIDEO | OPT_EXPERT,
|
|
|
|
{ &vstats_version },
|
2017-01-24 18:23:54 +02:00
|
|
|
"Version of the vstats format to use."},
|
2023-12-17 19:10:17 +02:00
|
|
|
{ "vf", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_video_filters },
|
2023-12-17 19:10:17 +02:00
|
|
|
"set video filters", "filter_graph",
|
|
|
|
.u1.name_canon = "filter", },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "intra_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(intra_matrices) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"specify intra matrix coeffs", "matrix" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "inter_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(inter_matrices) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"specify inter matrix coeffs", "matrix" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "chroma_intra_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(chroma_intra_matrices) },
|
2014-02-10 21:02:01 +03:00
|
|
|
"specify intra matrix coeffs", "matrix" },
|
2023-12-17 19:10:17 +02:00
|
|
|
{ "vtag", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_old2new },
|
2023-12-17 19:10:17 +02:00
|
|
|
"force video tag/fourcc", "fourcc/tag",
|
|
|
|
.u1.name_canon = "tag", },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "fps_mode", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(fps_mode) },
|
2022-06-07 14:06:54 +02:00
|
|
|
"set framerate mode for matching video streams; overrides vsync" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "force_fps", OPT_TYPE_BOOL, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(force_fps) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"force the selected framerate, disable the best supported framerate selection" },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "streamid", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_streamid },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set the value of an outfile streamid", "streamIndex:value" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "force_key_frames", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(forced_key_frames) },
|
2012-08-20 17:44:05 +03:00
|
|
|
"force key frames at specified timestamps", "timestamps" },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "b", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_bitrate },
|
2012-08-20 17:44:05 +03:00
|
|
|
"video bitrate (please use -b:v)", "bitrate" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "hwaccel", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(hwaccels) },
|
2013-11-03 00:06:36 +03:00
|
|
|
"use HW accelerated decoding", "hwaccel name" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "hwaccel_device", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(hwaccel_devices) },
|
2015-08-26 01:48:52 +02:00
|
|
|
"select a device for HW acceleration", "devicename" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "hwaccel_output_format", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(hwaccel_output_formats) },
|
2016-05-08 23:39:20 +02:00
|
|
|
"select output format used with HW accelerated decoding", "format" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "hwaccels", OPT_TYPE_FUNC, OPT_EXIT,
|
|
|
|
{ .func_arg = show_hwaccels },
|
2015-08-26 01:43:53 +02:00
|
|
|
"show available HW acceleration methods" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "autorotate", OPT_TYPE_BOOL, OPT_SPEC | OPT_EXPERT | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(autorotate) },
|
2015-04-29 16:59:01 +02:00
|
|
|
"automatically insert correct rotate filters" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "autoscale", OPT_TYPE_BOOL, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(autoscale) },
|
2020-06-08 10:58:05 +02:00
|
|
|
"automatically insert a scale filter at the end of the filter graph" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "fix_sub_duration_heartbeat", OPT_TYPE_BOOL, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(fix_sub_duration_heartbeat) },
|
2022-07-22 12:57:54 +02:00
|
|
|
"set this video output stream to be a heartbeat stream for "
|
|
|
|
"fix_sub_duration, according to which subtitles should be split at "
|
|
|
|
"random access points" },
|
2012-08-01 19:23:12 +03:00
|
|
|
|
|
|
|
/* audio options */
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "aframes", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_EXPERT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_audio_frames },
|
2023-12-17 19:10:17 +02:00
|
|
|
"set the number of audio frames to output", "number",
|
|
|
|
.u1.name_canon = "frames", },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "aq", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_audio_qscale },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set audio quality (codec-specific)", "quality", },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "ar", OPT_TYPE_INT, OPT_AUDIO | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(audio_sample_rate) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set audio sampling rate (in Hz)", "rate" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "ac", OPT_TYPE_INT, OPT_AUDIO | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(audio_channels) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set number of audio channels", "channels" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "an", OPT_TYPE_BOOL, OPT_AUDIO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(audio_disable) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"disable audio" },
|
2023-12-17 19:10:17 +02:00
|
|
|
{ "acodec", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_audio_codec },
|
2023-12-17 19:10:17 +02:00
|
|
|
"force audio codec ('copy' to copy stream)", "codec",
|
|
|
|
.u1.name_canon = "codec", },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "ab", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_bitrate },
|
2023-02-06 20:12:15 +02:00
|
|
|
"audio bitrate (please use -b:a)", "bitrate" },
|
2023-12-17 19:10:17 +02:00
|
|
|
{ "atag", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_old2new },
|
2023-12-17 19:10:17 +02:00
|
|
|
"force audio tag/fourcc", "fourcc/tag",
|
|
|
|
.u1.name_canon = "tag", },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "sample_fmt", OPT_TYPE_STRING, OPT_AUDIO | OPT_EXPERT | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(sample_fmts) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set sample format", "format" },
|
2023-12-17 19:10:17 +02:00
|
|
|
{ "channel_layout", OPT_TYPE_STRING, OPT_AUDIO | OPT_EXPERT | OPT_SPEC | OPT_INPUT | OPT_OUTPUT | OPT_HAS_ALT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(audio_ch_layouts) },
|
2023-12-17 19:10:17 +02:00
|
|
|
"set channel layout", "layout",
|
|
|
|
.u1.names_alt = alt_channel_layout, },
|
|
|
|
{ "ch_layout", OPT_TYPE_STRING, OPT_AUDIO | OPT_EXPERT | OPT_SPEC | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(audio_ch_layouts) },
|
2023-12-17 19:10:17 +02:00
|
|
|
"set channel layout", "layout",
|
|
|
|
.u1.name_canon = "channel_layout", },
|
|
|
|
{ "af", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_audio_filters },
|
2023-12-17 19:10:17 +02:00
|
|
|
"set audio filters", "filter_graph",
|
|
|
|
.u1.name_canon = "filter", },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "guess_layout_max", OPT_TYPE_INT, OPT_AUDIO | OPT_SPEC | OPT_EXPERT | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(guess_layout_max) },
|
2012-12-31 17:20:25 +03:00
|
|
|
"set the maximum number of channels to try to guess the channel layout" },
|
2012-08-01 19:23:12 +03:00
|
|
|
|
|
|
|
/* subtitle options */
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "sn", OPT_TYPE_BOOL, OPT_SUBTITLE | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(subtitle_disable) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"disable subtitle" },
|
2023-12-17 19:10:17 +02:00
|
|
|
{ "scodec", OPT_TYPE_FUNC, OPT_SUBTITLE | OPT_FUNC_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_subtitle_codec },
|
2023-12-17 19:10:17 +02:00
|
|
|
"force subtitle codec ('copy' to copy stream)", "codec",
|
|
|
|
.u1.name_canon = "codec", },
|
|
|
|
{ "stag", OPT_TYPE_FUNC, OPT_SUBTITLE | OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_old2new }
|
2023-12-17 19:10:17 +02:00
|
|
|
, "force subtitle tag/fourcc", "fourcc/tag",
|
|
|
|
.u1.name_canon = "tag" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "fix_sub_duration", OPT_TYPE_BOOL, OPT_EXPERT | OPT_SUBTITLE | OPT_SPEC | OPT_INPUT,
|
|
|
|
{ .off = OFFSET(fix_sub_duration) },
|
2012-08-20 17:44:05 +03:00
|
|
|
"fix subtitles duration" },
|
2023-12-18 10:19:25 +02:00
|
|
|
{ "canvas_size", OPT_TYPE_STRING, OPT_SUBTITLE | OPT_SPEC | OPT_INPUT | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(canvas_sizes) },
|
2013-02-27 23:14:48 +03:00
|
|
|
"set canvas size (WxH or abbreviation)", "size" },
|
2012-08-01 19:23:12 +03:00
|
|
|
|
|
|
|
/* muxer options */
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "muxdelay", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(mux_max_delay) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set the maximum demux-decode delay", "seconds" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "muxpreload", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(mux_preload) },
|
2012-08-11 18:00:30 +03:00
|
|
|
"set the initial demux-decode delay", "seconds" },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "sdp_file", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_sdp_file },
|
2014-12-25 23:56:06 +02:00
|
|
|
"specify a file in which to print sdp information", "file" },
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "time_base", OPT_TYPE_STRING, OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(time_bases) },
|
2016-12-28 08:05:35 +02:00
|
|
|
"set the desired time base hint for output stream (1:24, 1:48000 or 0.04166, 2.0833e-5)", "ratio" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "enc_time_base", OPT_TYPE_STRING, OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(enc_time_bases) },
|
2017-05-03 10:50:15 +02:00
|
|
|
"set the desired time base for the encoder (1:24, 1:48000 or 0.04166, 2.0833e-5). "
|
|
|
|
"two special values are defined - "
|
|
|
|
"0 = use frame rate (video) or sample rate (audio),"
|
|
|
|
"-1 = match source time base", "ratio" },
|
2016-12-28 08:05:35 +02:00
|
|
|
|
2023-12-17 19:10:17 +02:00
|
|
|
{ "bsf", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT | OPT_HAS_ALT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(bitstream_filters) },
|
2023-12-17 19:10:17 +02:00
|
|
|
"A comma-separated list of bitstream filters", "bitstream_filters",
|
|
|
|
.u1.names_alt = alt_bsf, },
|
|
|
|
{ "absf", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_old2new },
|
2023-12-17 19:10:17 +02:00
|
|
|
"deprecated", "audio bitstream_filters",
|
|
|
|
.u1.name_canon = "bsf", },
|
|
|
|
{ "vbsf", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_old2new },
|
2023-12-17 19:10:17 +02:00
|
|
|
"deprecated", "video bitstream_filters",
|
|
|
|
.u1.name_canon = "bsf", },
|
2012-08-20 17:44:05 +03:00
|
|
|
|
2023-12-17 19:10:17 +02:00
|
|
|
{ "apre", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_preset },
|
2023-12-17 19:10:17 +02:00
|
|
|
"set the audio options to the indicated preset", "preset",
|
|
|
|
.u1.name_canon = "pre", },
|
|
|
|
{ "vpre", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_preset },
|
2023-12-17 19:10:17 +02:00
|
|
|
"set the video options to the indicated preset", "preset",
|
|
|
|
.u1.name_canon = "pre", },
|
|
|
|
{ "spre", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_SUBTITLE | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_preset },
|
2023-12-17 19:10:17 +02:00
|
|
|
"set the subtitle options to the indicated preset", "preset",
|
|
|
|
.u1.name_canon = "pre", },
|
|
|
|
{ "fpre", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_preset },
|
2023-12-17 19:10:17 +02:00
|
|
|
"set options from indicated preset file", "filename",
|
|
|
|
.u1.name_canon = "pre", },
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "max_muxing_queue_size", OPT_TYPE_INT, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(max_muxing_queue_size) },
|
2016-05-23 10:48:26 +02:00
|
|
|
"maximum number of packets that can be buffered while waiting for all streams to initialize", "packets" },
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "muxing_queue_data_threshold", OPT_TYPE_INT, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(muxing_queue_data_threshold) },
|
2020-10-15 20:21:05 +02:00
|
|
|
"set the threshold after which max_muxing_queue_size is taken into account", "bytes" },
|
2016-05-23 10:48:26 +02:00
|
|
|
|
2012-08-01 19:23:12 +03:00
|
|
|
/* data codec support */
|
2023-12-17 19:10:17 +02:00
|
|
|
{ "dcodec", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_DATA | OPT_PERFILE | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_data_codec },
|
2023-12-17 19:10:17 +02:00
|
|
|
"force data codec ('copy' to copy stream)", "codec",
|
|
|
|
.u1.name_canon = "codec", },
|
2023-12-18 11:24:45 +02:00
|
|
|
{ "dn", OPT_TYPE_BOOL, OPT_DATA | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .off = OFFSET(data_disable) }, "disable data" },
|
2012-08-01 19:23:12 +03:00
|
|
|
|
2016-03-24 01:48:13 +02:00
|
|
|
#if CONFIG_VAAPI
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "vaapi_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_vaapi_device },
|
2023-04-14 16:39:05 +02:00
|
|
|
"set VAAPI hardware device (DirectX adapter index, DRM path or X11 display name)", "device" },
|
2016-03-24 01:48:13 +02:00
|
|
|
#endif
|
|
|
|
|
2017-01-05 08:48:06 +02:00
|
|
|
#if CONFIG_QSV
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "qsv_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_qsv_device },
|
2017-01-05 08:48:06 +02:00
|
|
|
"set QSV hardware device (DirectX adapter index, DRM path or X11 display name)", "device"},
|
|
|
|
#endif
|
|
|
|
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "init_hw_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_init_hw_device },
|
2017-03-05 01:57:30 +02:00
|
|
|
"initialise hardware device", "args" },
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "filter_hw_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_filter_hw_device },
|
2017-03-05 01:57:38 +02:00
|
|
|
"set hardware device used when filtering", "device" },
|
2017-03-05 01:57:30 +02:00
|
|
|
|
2023-12-15 10:21:09 +02:00
|
|
|
// deprecated options
|
|
|
|
#if FFMPEG_OPT_MAP_CHANNEL
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "map_channel", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_map_channel },
|
2023-12-15 10:21:09 +02:00
|
|
|
"map an audio channel from one stream to another (deprecated)", "file.stream.channel[:syncfile.syncstream]" },
|
|
|
|
#endif
|
|
|
|
#if FFMPEG_OPT_ADRIFT_THRESHOLD
|
2023-12-17 11:45:45 +02:00
|
|
|
{ "adrift_threshold", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
|
2023-12-15 09:50:26 +02:00
|
|
|
{ .func_arg = opt_adrift_threshold },
|
2023-12-15 10:21:09 +02:00
|
|
|
"deprecated, does nothing", "threshold" },
|
|
|
|
#endif
|
|
|
|
#if FFMPEG_OPT_PSNR
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "psnr", OPT_TYPE_BOOL, OPT_VIDEO | OPT_EXPERT,
|
|
|
|
{ &do_psnr },
|
2023-12-15 10:21:09 +02:00
|
|
|
"calculate PSNR of compressed frames (deprecated, use -flags +psnr)" },
|
|
|
|
#endif
|
|
|
|
#if FFMPEG_OPT_TOP
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "top", OPT_TYPE_INT, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
|
|
|
|
{ .off = OFFSET(top_field_first) },
|
2023-12-15 10:21:09 +02:00
|
|
|
"deprecated, use the setfield video filter", "" },
|
|
|
|
#endif
|
|
|
|
#if FFMPEG_OPT_QPHIST
|
2023-12-15 09:50:26 +02:00
|
|
|
{ "qphist", OPT_TYPE_FUNC, OPT_VIDEO | OPT_EXPERT,
|
|
|
|
{ .func_arg = opt_qphist },
|
2023-12-15 10:21:09 +02:00
|
|
|
"deprecated, does nothing" },
|
|
|
|
#endif
|
|
|
|
|
2012-08-01 19:23:12 +03:00
|
|
|
{ NULL, },
|
|
|
|
};
|