diff --git a/DOCS/man/af.rst b/DOCS/man/af.rst index bc25a9f7b3..b56fc919a1 100644 --- a/DOCS/man/af.rst +++ b/DOCS/man/af.rst @@ -15,6 +15,9 @@ syntax is: wrapper, which gives you access to most of libavfilter's filters. This includes all filters that have been ported from MPlayer to libavfilter. + The ``--vf`` description describes how libavfilter can be used and how to + workaround deprecated mpv filters. + See ``--vf`` group of options for info on how ``--af-defaults``, ``--af-add``, ``--af-pre``, ``--af-del``, ``--af-clr``, and possibly others work. diff --git a/DOCS/man/vf.rst b/DOCS/man/vf.rst index 2d53fc4ce2..64e5c0c0cd 100644 --- a/DOCS/man/vf.rst +++ b/DOCS/man/vf.rst @@ -49,13 +49,14 @@ normal filter parameters. .. note:: - To get a full list of available video filters, see ``--vf=help``. + To get a full list of available video filters, see ``--vf=help`` and + http://ffmpeg.org/ffmpeg-filters.html . Also, keep in mind that most actual filters are available via the ``lavfi`` wrapper, which gives you access to most of libavfilter's filters. This includes all filters that have been ported from MPlayer to libavfilter. - Most filters are deprecated in some ways, unless they're only available + Most builtin filters are deprecated in some ways, unless they're only available in mpv (such as filters which deal with mpv specifics, or which are implemented in mpv only). @@ -66,6 +67,11 @@ normal filter parameters. everything accepted by vf_lavfi's ``graph`` option will be accepted by ``--vf``.) + You can also prefix the filter name with ``lavfi-`` to force the wrapper. + This is helpful if the filter name collides with a deprecated mpv builtin + filter. For example ``--vf=lavfi-scale=args`` would use libavfilter's + ``scale`` filter over mpv's deprecated builtin one. + Video filters are managed in lists. There are a few commands to manage the filter list. @@ -92,7 +98,7 @@ With filters that support it, you can access parameters by their name. Sets a named parameter to the given value. Use on and off or yes and no to set flag parameters. -Available filters are: +Available mpv-only filters are: ``crop[=w:h:x:y]`` Crops the given part of the image and discards the rest. Useful to remove diff --git a/audio/filter/af.c b/audio/filter/af.c index 189c12b875..0df0f28bb6 100644 --- a/audio/filter/af.c +++ b/audio/filter/af.c @@ -163,11 +163,14 @@ static struct af_instance *af_create(struct af_stream *s, char *name, lavfi_name = name; lavfi_args = args; args = NULL; + if (strncmp(lavfi_name, "lavfi-", 6) == 0) + lavfi_name += 6; } MP_VERBOSE(s, "Adding filter %s \n", name); struct af_instance *af = talloc_zero(NULL, struct af_instance); *af = (struct af_instance) { + .full_name = talloc_strdup(af, name), .info = desc.p, .data = talloc_zero(af, struct mp_audio), .log = mp_log_new(af, s->log, name), @@ -192,6 +195,7 @@ static struct af_instance *af_create(struct af_stream *s, char *name, assert(opts->opt->type == &m_option_type_keyvalue_list); if (m_config_set_option_raw(config, opts, &lavfi_args, 0) < 0) goto error; + af->full_name = talloc_asprintf(af, "%s (lavfi)", af->full_name); } af->priv = config->optstruct; @@ -271,7 +275,7 @@ static void af_print_filter_chain(struct af_stream *s, struct af_instance *at, struct af_instance *af = s->first; while (af) { char b[128] = {0}; - mp_snprintf_cat(b, sizeof(b), " [%s] ", af->info->name); + mp_snprintf_cat(b, sizeof(b), " [%s] ", af->full_name); if (af->label) mp_snprintf_cat(b, sizeof(b), "\"%s\" ", af->label); if (af->data) @@ -518,6 +522,7 @@ struct af_stream *af_new(struct mpv_global *global) static const struct af_info in = { .name = "in" }; s->first = talloc(s, struct af_instance); *s->first = (struct af_instance) { + .full_name = "in", .info = &in, .log = s->log, .control = input_control, @@ -529,6 +534,7 @@ struct af_stream *af_new(struct mpv_global *global) static const struct af_info out = { .name = "out" }; s->last = talloc(s, struct af_instance); *s->last = (struct af_instance) { + .full_name = "out", .info = &out, .log = s->log, .control = output_control, diff --git a/audio/filter/af.h b/audio/filter/af.h index 9c7b1fbfa5..553fc03e32 100644 --- a/audio/filter/af.h +++ b/audio/filter/af.h @@ -52,6 +52,7 @@ struct af_info { // Linked list of audio filters struct af_instance { const struct af_info *info; + char *full_name; struct mp_log *log; struct MPOpts *opts; struct replaygain_data *replaygain_data; diff --git a/video/filter/vf.c b/video/filter/vf.c index ad427992d7..f86bf99e7a 100644 --- a/video/filter/vf.c +++ b/video/filter/vf.c @@ -229,7 +229,7 @@ void vf_print_filter_chain(struct vf_chain *c, int msglevel, for (vf_instance_t *f = c->first; f; f = f->next) { char b[128] = {0}; - mp_snprintf_cat(b, sizeof(b), " [%s] ", f->info->name); + mp_snprintf_cat(b, sizeof(b), " [%s] ", f->full_name); if (f->label) mp_snprintf_cat(b, sizeof(b), "\"%s\" ", f->label); mp_snprintf_cat(b, sizeof(b), "%s", mp_image_params_to_str(&f->fmt_out)); @@ -255,9 +255,12 @@ static struct vf_instance *vf_open(struct vf_chain *c, const char *name, lavfi_name = name; lavfi_args = args; args = NULL; + if (strncmp(lavfi_name, "lavfi-", 6) == 0) + lavfi_name += 6; } vf_instance_t *vf = talloc_zero(NULL, struct vf_instance); *vf = (vf_instance_t) { + .full_name = talloc_strdup(vf, name), .info = desc.p, .log = mp_log_new(vf, c->log, name), .hwdec_devs = c->hwdec_devs, @@ -282,6 +285,7 @@ static struct vf_instance *vf_open(struct vf_chain *c, const char *name, assert(opts->opt->type == &m_option_type_keyvalue_list); if (m_config_set_option_raw(config, opts, &lavfi_args, 0) < 0) goto error; + vf->full_name = talloc_asprintf(vf, "%s (lavfi)", vf->full_name); } vf->priv = config->optstruct; int retcode = vf->info->open(vf); @@ -792,6 +796,7 @@ struct vf_chain *vf_new(struct mpv_global *global) static const struct vf_info in = { .name = "in" }; c->first = talloc(c, struct vf_instance); *c->first = (struct vf_instance) { + .full_name = "in", .log = c->log, .info = &in, .query_format = input_query_format, @@ -799,6 +804,7 @@ struct vf_chain *vf_new(struct mpv_global *global) static const struct vf_info out = { .name = "out" }; c->last = talloc(c, struct vf_instance); *c->last = (struct vf_instance) { + .full_name = "out", .log = c->log, .info = &out, .query_format = output_query_format, diff --git a/video/filter/vf.h b/video/filter/vf.h index 4cb7b4c1c6..546fd823ad 100644 --- a/video/filter/vf.h +++ b/video/filter/vf.h @@ -46,6 +46,7 @@ typedef struct vf_info { typedef struct vf_instance { const vf_info_t *info; + char *full_name; // Initialize the filter. The filter must set *out to the same image // params as the images the filter functions will return for the given