History

vf_vapoursynth: add parameter to pass arbitrary string to script

Currently the vapoursynth video filter does not accept any argument for passing arbitrary user data. This limits what the VS script can do. Ideally, the vapoursynth filter has an user-data parameter that contain string value. mpv passes that value to the VS script just like container_fps and others. Once the VS script gets the data, it can do all sorts of data extraction and transformation. Another benefit is that instead of mpv always have to catch up to user needs for this filter, with this users can just pass whatever needed themselves, thus becomes more future-proof. Fixes #14214

Crend King committed 2 years ago

Commit fe709c91 parent dc998562 files · +12 −1Browse files

Unified · Split

2 files
  1. DOCS/man/vf.rst +9 −1
  2. video/filter/vf_vapoursynth.c +3 −0
DOCS/man/vf.rst+9−1
@@ -433,7 +433,7 @@ Available mpv-only filters are: · 432 unmodified lines
433 subtitle colors and video under the influence of the video equalizer433 subtitle colors and video under the influence of the video equalizer
434 settings.434 settings.
435 435
436``vapoursynth=file:buffered-frames:concurrent-frames``436``vapoursynth=file:buffered-frames:concurrent-frames:user-data``
437 Loads a VapourSynth filter script. This is intended for streamed437 Loads a VapourSynth filter script. This is intended for streamed
438 processing: mpv actually provides a source filter, instead of using a438 processing: mpv actually provides a source filter, instead of using a
439 native VapourSynth video source. The mpv source will answer frame439 native VapourSynth video source. The mpv source will answer frame
@@ -559,6 +559,10 @@ Available mpv-only filters are: · 119 unmodified lines
559 By default, this uses the special value ``auto``, which sets the option559 By default, this uses the special value ``auto``, which sets the option
560 to the number of detected logical CPU cores.560 to the number of detected logical CPU cores.
561 561
562 ``user-data``
563 Optional arbitrary string that is passed to the script. Default to empty
564 string if not set.
565
562 The following ``.vpy`` script variables are defined by mpv:566 The following ``.vpy`` script variables are defined by mpv:
563 567
564 ``video_in``568 ``video_in``
@@ -589,6 +593,10 @@ Available mpv-only filters are: · 24 unmodified lines
589 to the height. These values can be 0. Note that this will not respond to593 to the height. These values can be 0. Note that this will not respond to
590 monitor changes and may not work on all platforms.594 monitor changes and may not work on all platforms.
591 595
596 ``user_data``
597 User data passed from the filter. This variable always exists, and defaults
598 to empty string.
599
592``vavpp``600``vavpp``
593 VA-API video post processing. Requires the system to support VA-API,601 VA-API video post processing. Requires the system to support VA-API,
594 i.e. Linux/BSD only. Works with ``--vo=vaapi`` and ``--vo=gpu`` only.602 i.e. Linux/BSD only. Works with ``--vo=vaapi`` and ``--vo=gpu`` only.
video/filter/vf_vapoursynth.c+3−0
@@ -46,6 +46,7 @@ struct vapoursynth_opts { · 45 unmodified lines
46 char *file;46 char *file;
47 int maxbuffer;47 int maxbuffer;
48 int maxrequests;48 int maxrequests;
49 char *user_data;
49 50
50 const struct script_driver *drv;51 const struct script_driver *drv;
51};52};
@@ -699,6 +700,7 @@ static int reinit_vs(struct priv *p, struct mp_image *input) · 647 unmodified lines
699 p->vsapi->propSetFloat(vars, "container_fps", container_fps, 0);700 p->vsapi->propSetFloat(vars, "container_fps", container_fps, 0);
700 p->vsapi->propSetFloat(vars, "display_fps", display_fps, 0);701 p->vsapi->propSetFloat(vars, "display_fps", display_fps, 0);
701 p->vsapi->propSetIntArray(vars, "display_res", display_res, 2);702 p->vsapi->propSetIntArray(vars, "display_res", display_res, 2);
703 p->vsapi->propSetData(vars, "user_data", p->opts->user_data, -1, 0);
702 704
703 if (p->drv->load(p, vars) < 0)705 if (p->drv->load(p, vars) < 0)
704 goto error;706 goto error;
@@ -830,6 +832,7 @@ static const m_option_t vf_opts_fields[] = { · 125 unmodified lines
830 OPTDEF_INT(4)},832 OPTDEF_INT(4)},
831 {"concurrent-frames", OPT_CHOICE(maxrequests, {"auto", -1}),833 {"concurrent-frames", OPT_CHOICE(maxrequests, {"auto", -1}),
832 M_RANGE(1, 99), OPTDEF_INT(-1)},834 M_RANGE(1, 99), OPTDEF_INT(-1)},
835 {"user-data", OPT_STRING(user_data), OPTDEF_STR("")},
833 {0}836 {0}
834};837};
835 838

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t