X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg_opt.c;h=131dd89b52bb7a35631c283fc68534db1a3a96bd;hb=1f36b43c280d36a403874e54a017472a3b2f472a;hp=4edd1186c7408c26f1efc848dd1d27709610d1d7;hpb=029aa8ff140784405533cd4be5051f8733dc5acb;p=ffmpeg diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 4edd1186c74..131dd89b52b 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -78,6 +78,9 @@ const HWAccel hwaccels[] = { #endif #if CONFIG_VIDEOTOOLBOX { "videotoolbox", videotoolbox_init, HWACCEL_VIDEOTOOLBOX, AV_PIX_FMT_VIDEOTOOLBOX }, +#endif +#if CONFIG_LIBMFX + { "qsv", qsv_init, HWACCEL_QSV, AV_PIX_FMT_QSV }, #endif { 0 }, }; @@ -103,6 +106,7 @@ int start_at_zero = 0; int copy_tb = -1; int debug_ts = 0; int exit_on_error = 0; +int abort_on_flags = 0; int print_stats = -1; int qp_hist = 0; int stdin_interaction = 1; @@ -196,6 +200,24 @@ static AVDictionary *strip_specifiers(AVDictionary *dict) return ret; } +static int opt_abort_on(void *optctx, const char *opt, const char *arg) +{ + static const AVOption opts[] = { + { "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" }, + { 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); +} + static int opt_sameq(void *optctx, const char *opt, const char *arg) { av_log(NULL, AV_LOG_ERROR, "Option '%s' was removed. " @@ -627,6 +649,9 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) ist->file_index = nb_input_files; ist->discard = 1; st->discard = AVDISCARD_ALL; + ist->nb_samples = 0; + ist->min_pts = INT64_MAX; + ist->max_pts = INT64_MIN; ist->ts_scale = 1.0; MATCH_PER_STREAM_OPT(ts_scale, dbl, ist->ts_scale, ic, st); @@ -1005,6 +1030,9 @@ static int open_input_file(OptionsContext *o, const char *filename) f->nb_streams = ic->nb_streams; f->rate_emu = o->rate_emu; f->accurate_seek = o->accurate_seek; + f->loop = o->loop; + f->duration = 0; + f->time_base = (AVRational){ 1, 1 }; #if HAVE_PTHREADS f->thread_queue_size = o->thread_queue_size > 0 ? o->thread_queue_size : 8; #endif @@ -2802,63 +2830,6 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char * return 0; } -/* Search a class from a codec, format, or filter, named 'opt', in order - * to extract its private options. If the class type is specified, only - * the associated options are printed, otherwise all the ones matching - * the input name are shown. */ -static int show_help_specific(const char *opt) -{ - AVCodec *codec = NULL; - AVFilter *filter = NULL; - AVInputFormat *iformat = NULL; - AVOutputFormat *oformat = NULL; - int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM | - AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM; - - char *kind = av_get_token(&opt, ":"); - if (!kind) - return 0; - if (*opt) - opt = &opt[1]; // skip ':' - - show_usage(); - - if (!strcmp(kind, "decoder") && - (codec = avcodec_find_decoder_by_name(opt)) && codec->priv_class) - show_help_children(codec->priv_class, flags); - else if (!strcmp(kind, "encoder") && - (codec = avcodec_find_encoder_by_name(opt)) && codec->priv_class) - show_help_children(codec->priv_class, flags); - else if (!strcmp(kind, "demuxer") && - (iformat = av_find_input_format(opt)) && iformat->priv_class) - show_help_children(iformat->priv_class, flags); - else if (!strcmp(kind, "muxer") && - (oformat = av_guess_format(opt, NULL, NULL)) && oformat->priv_class) - show_help_children(oformat->priv_class, flags); - else if (!strcmp(kind, "filter") && - (filter = avfilter_get_by_name(opt)) && filter->priv_class) - show_help_children(filter->priv_class, flags); - else if (*opt) - av_log(NULL, AV_LOG_ERROR, - "Unknown class '%s', only 'decoder', 'encoder', 'demuxer', " - "'muxer', or 'filter' are valid specifiers.\n", kind); - else { - if ((codec = avcodec_find_decoder_by_name(kind)) && codec->priv_class) - show_help_children(codec->priv_class, flags); - if ((codec = avcodec_find_encoder_by_name(kind)) && codec->priv_class) - show_help_children(codec->priv_class, flags); - if ((iformat = av_find_input_format(kind)) && iformat->priv_class) - show_help_children(iformat->priv_class, flags); - if ((oformat = av_guess_format(kind, NULL, NULL)) && oformat->priv_class) - show_help_children(oformat->priv_class, flags); - if ((filter = avfilter_get_by_name(kind)) && filter->priv_class) - show_help_children(filter->priv_class, flags); - } - av_freep(&kind); - - return codec || iformat || oformat || filter; -} - void show_help_default(const char *opt, const char *arg) { /* per-file options have at least one of those set */ @@ -2870,8 +2841,6 @@ void show_help_default(const char *opt, const char *arg) show_advanced = 1; else if (!strcmp(opt, "full")) show_advanced = show_avoptions = 1; - else if (show_help_specific(opt)) - return; else av_log(NULL, AV_LOG_ERROR, "Unknown help option '%s'.\n", opt); } @@ -2882,7 +2851,7 @@ void show_help_default(const char *opt, const char *arg) " -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" - " -h [type:]name -- print private options from a codec, format or filter named 'name' (set 'type' to print options from a single class)\n" + " -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter\n" " See man %s for detailed description of the options.\n" "\n", program_name); @@ -3147,7 +3116,7 @@ const OptionDef options[] = { { "target", HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_target }, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\" or \"dv50\" " "with optional prefixes \"pal-\", \"ntsc-\" or \"film-\")", "type" }, - { "vsync", HAS_ARG | OPT_EXPERT, { opt_vsync }, + { "vsync", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vsync }, "video sync method", "" }, { "frame_drop_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &frame_drop_threshold }, "frame drop threshold", "" }, @@ -3173,6 +3142,8 @@ const OptionDef options[] = { "timestamp error delta threshold", "threshold" }, { "xerror", OPT_BOOL | OPT_EXPERT, { &exit_on_error }, "exit on error", "error" }, + { "abort_on", HAS_ARG | OPT_EXPERT, { .func_arg = opt_abort_on }, + "abort on the specified condition flags", "flags" }, { "copyinkf", OPT_BOOL | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(copy_initial_nonkeyframes) }, "copy initial non-keyframes" }, @@ -3211,6 +3182,8 @@ const OptionDef options[] = { { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(dump_attachment) }, "extract an attachment into a file", "filename" }, + { "stream_loop", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_INPUT | + OPT_OFFSET, { .off = OFFSET(loop) }, "set number of times input stream shall be looped", "loop count" }, { "debug_ts", OPT_BOOL | OPT_EXPERT, { &debug_ts }, "print timestamp debugging info" }, { "max_error_rate", HAS_ARG | OPT_FLOAT, { &max_error_rate }, @@ -3267,9 +3240,9 @@ const OptionDef options[] = { "this option is deprecated, use the yadif filter instead" }, { "psnr", OPT_VIDEO | OPT_BOOL | OPT_EXPERT, { &do_psnr }, "calculate PSNR of compressed frames" }, - { "vstats", OPT_VIDEO | OPT_EXPERT , { &opt_vstats }, + { "vstats", OPT_VIDEO | OPT_EXPERT , { .func_arg = opt_vstats }, "dump video coding statistics to file" }, - { "vstats_file", OPT_VIDEO | HAS_ARG | OPT_EXPERT , { opt_vstats_file }, + { "vstats_file", OPT_VIDEO | HAS_ARG | OPT_EXPERT , { .func_arg = opt_vstats_file }, "dump video coding statistics to file", "file" }, { "vf", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_video_filters }, "set video filters", "filter_graph" }, @@ -3379,7 +3352,7 @@ const OptionDef options[] = { "set the initial demux-decode delay", "seconds" }, { "override_ffserver", OPT_BOOL | OPT_EXPERT | OPT_OUTPUT, { &override_ffserver }, "override the options from ffserver", "" }, - { "sdp_file", HAS_ARG | OPT_EXPERT | OPT_OUTPUT, { opt_sdp_file }, + { "sdp_file", HAS_ARG | OPT_EXPERT | OPT_OUTPUT, { .func_arg = opt_sdp_file }, "specify a file in which to print sdp information", "file" }, { "bsf", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(bitstream_filters) },