Skip to content

vf_vapoursynth: update for VapourSynth R74#17731

Open
CrendKing wants to merge 4 commits intompv-player:masterfrom
CrendKing:vapoursynth
Open

vf_vapoursynth: update for VapourSynth R74#17731
CrendKing wants to merge 4 commits intompv-player:masterfrom
CrendKing:vapoursynth

Conversation

@CrendKing
Copy link
Copy Markdown
Contributor

@CrendKing CrendKing commented Apr 10, 2026

VapourSynth R74 changed two things relevant to mpv build process:

  1. VSScript no longer has static library to link to, and only support runtime loading. This is reflected on the new VSScript example in VapourSynth SDK.
  2. The VSScript library name is changed from libvapoursynth-script to libvsscript for Linux and MacOS.

The new VSScript initialization code is slightly modified from their SDK example to fit in the mpv logic. Build dependency version is also update.

Previously, the VapourSynth directory (which contains VapourSynth and VSScript DLLs) must be in PATH (which VapourSynth installer should takes care). After R74, there is new installation instructions which sets VSSCRIPT_PATH environment variable instead. Change to PATH is no longer needed.

VapourSynth R74 changed two things relevant to mpv build process:

1) VSScript no longer has static library to link to, and only support runtime loading.
This is reflected on the new VSScript example in VapourSynth SDK.
2) The VSScript library name is changed from libvapoursynth-script to libvsscript for Linux
and MacOS.

The new VSScript initialization code is slightly modified from their SDK example to fit
in the mpv logic. Build dependency version is also update.
@hooke007
Copy link
Copy Markdown
Contributor

Not good at all. It should be implemented in a backward-compatible way instead.

@hooke007

This comment was marked as outdated.

@CrendKing
Copy link
Copy Markdown
Contributor Author

This approach should be backward compatible. I removed the dependency related changes. Will squash all commits later.

Comment thread meson.build

vapoursynth = dependency('vapoursynth', version: '>= 74', required: get_option('vapoursynth'))
vapoursynth_script = dependency('vapoursynth-script', version: '>= 74',
vapoursynth = dependency('vapoursynth', version: '>= 56', required: get_option('vapoursynth'))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to load Vapoursynth on runtime why is this meson feature necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need the header files, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this will also link library. It should be header only. I don't know if meson already support header only dependencies, it was long standing limitation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread video/filter/vf_vapoursynth.c Outdated

#ifdef _WIN32
const wchar_t *vsscript_path = _wgetenv(L"VSSCRIPT_PATH");
const HMODULE lib = LoadLibraryExW(vsscript_path ? vsscript_path : L"VSScript.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use our dlopen and getenv helpers from io.h

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure? First, I see io.h only support getenv() with char version, no wchar_t. Doesn't that potentially have UTF-8 problem? Second, the mp_dlopen() always resolve relative path to full path, so a VSScript.dll becomes <mpv_exe_dir>\VSScript.dll, which pretty much never exists. Previous behavior was effectively LoadLibrary(), which will search the standard paths including the directories in PATH.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mp_dlopen is not correct in this case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I think we should keep the original _wgetenv + LoadLibrary pattern. Also, do you guys prefer LoadLibrary or LoadLibraryEx? Do you care about DLL hijacking, so no LOAD_WITH_ALTERED_SEARCH_PATH?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer _wgetenv + LoadLibraryExW(..., LOAD_WITH_ALTERED_SEARCH_PATH) pattern. LOAD_WITH_ALTERED_SEARCH_PATH also helps locate dependent DLLs (e.g. vapoursynth.dll alongside VSScript.dll, making it preferable over plain LoadLibraryW.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR

Since I only use portable ver before r74. From my view...

  1. IF users add VS DLLs in the same dir of mpv.exe → APPLICATION_DIR could find.
  2. IF users put VS in the another dir which has been added into PATH. It cannot work, right?

Copy link
Copy Markdown
Contributor Author

@CrendKing CrendKing Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was wrong. LOAD_WITH_ALTERED_SEARCH_PATH is the way to go.

Comment thread video/filter/vf_vapoursynth.c Outdated
#else
const char *lib_name_r74 = "libvsscript.so.4";
const char *lib_name_old = "libvapoursynth-script.so.4";
#endif
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can define it at the top and assign as VSSCRIPT_PATH or something.

Copy link
Copy Markdown
Contributor Author

@CrendKing CrendKing Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate? Are you suggesting to first put these in the VSSCRIPT_PATH environment variable if that variable wasn't exist?

@CrendKing
Copy link
Copy Markdown
Contributor Author

Here is a version using the io.h, but it is backward incompatible to previous behavior.

Comment thread meson.build
vapoursynth = dependency('vapoursynth', version: '>= 56', required: get_option('vapoursynth'))
vapoursynth_script = dependency('vapoursynth-script', version: '>= 56',
required: get_option('vapoursynth'))
vapoursynth_script = dependency('vapoursynth-script', version: '>= 56', required: get_option('vapoursynth'))
Copy link
Copy Markdown
Contributor

@hooke007 hooke007 Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may break r74 compat too.
There is no vapoursynth_script in r74 right? Does it disable mpv's vs filter feature when compling with r74 already installed in system?

Copy link
Copy Markdown
Contributor Author

@CrendKing CrendKing Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vapoursynth script (VSScript) still exists in R74. The only change is that they renamed the dynamic library name in Linux and MacOS. The header file name is still VSScript4.h. Since we are requiring less from the dependency, from compile point of view there is no change at all. Should work on all VapourSynth versions (after R56).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants