Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to pass arbitrary user data to VapourSynth script #14214

Closed
CrendKing opened this issue May 22, 2024 · 4 comments · Fixed by #14312 or #14315
Closed

A way to pass arbitrary user data to VapourSynth script #14214

CrendKing opened this issue May 22, 2024 · 4 comments · Fixed by #14312 or #14315
Labels
meta:feature-request meta:help-wanted Anyone is invited to help with this. Suitable for new developers with no experience with mpv code.

Comments

@CrendKing
Copy link
Contributor

Expected behavior of the wanted feature

Currently the vapoursynth video filter does not accept any argument for passing arbitrary user data. This still limits what the VS script can do.

Ideally, vapoursynth can have an user-data option that contains string value. mpv passes that value to the VS script just like container_fps and others. There could be a reasonable cap of the data size like 100. 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 future requests to add more properties can reduce.

Alternative behavior of the wanted feature

Main reason I'm asking this that the current alternatives are lacking. I've tried

  1. Install a Lua extension that can call OS API (e.g. winapi for Windows), set environment variable from Lua side, then mp.commandv('set', 'vf', 'vapoursynth=mpv.vpy'). Then in mpv.vpy, try to retrieve that data with os.environ. I noticed that even the variable is correctly present in Process Explorer, os.environ doesn't have that variable. I guess even though os.environ says it captured the mapping first time the osmodule is imported, mpv probably loads VapourSynth and thus the os module before my Lua script, so changing the process environment variables in Lua doesn't work.
  2. In Lua, write to a file (e.g. C:\test), then load file in VS script. This works, but then 1) someone has to cleanup that file; 2) what happens if multiple mpv instances with my scripts concurrently access that file? Ideally the file name should have the current process ID in it to avoid collision, but then that further complicates the task.
  3. Any other usual IPC mechanism such as mailslots require deep integration with the OS API, which Lua lacks.

Log File

No response

Sample Files

No response

@kasper93 kasper93 added the meta:help-wanted Anyone is invited to help with this. Suitable for new developers with no experience with mpv code. label May 22, 2024
CrendKing added a commit to CrendKing/mpv that referenced this issue Jun 6, 2024
CrendKing added a commit to CrendKing/mpv that referenced this issue Jun 6, 2024
CrendKing added a commit to CrendKing/mpv that referenced this issue Jun 6, 2024
…ry data 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 contains 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](mpv-player#11510), with this users can just pass whatever needed themselves, thus becomes more future-proof.

Fixes mpv-player#14214
CrendKing added a commit to CrendKing/mpv that referenced this issue Jun 6, 2024
…ry data 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 contains 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 mpv-player#14214
CrendKing added a commit to CrendKing/mpv that referenced this issue Jun 6, 2024
…ry data 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 contains 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 mpv-player#14214
@CrendKing
Copy link
Contributor Author

@kasper93 Thanks to your recent contributions about building mpv on Windows (e.g. 112fa54), I can now contribute myself with ease.

If interested, I created PR at #14312.

CrendKing added a commit to CrendKing/mpv that referenced this issue Jun 6, 2024
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 contains 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 mpv-player#14214
@CrendKing
Copy link
Contributor Author

For documentation purpose, I still encounter some issues when I try to build mpv on Windows after following the up-to-date instructions, specifically the "Native Compilation with Clang (Windows SDK Build)" route:

  1. There is no mentioning of activating the Visual Studio developer environment. It is included in the CI. I know this step is obvious, but I don't think it hurts to mention.
  2. Since the build script heavily relies on the Meson subprojects, the "Update Meson WrapDB" step from CI is actually crucial. Without it, my build was originally pulling harfbuzz 5.2 from some upstream, which doesn't compile due to old issue long fixed. I think we should either mention in the instruction or update the build script.
  3. CMake is required for shaderc (which is enabled by default), but not mentioned.
  4. pkg-config might be required if certain components are enabled. For instance, VapourSynth is not in Meson WrapDB, and the easiest way to fulfill the dependency is a pkg-config file like this:
prefix=D:/vapoursynth/current/sdk
includedir=${prefix}/include/vapoursynth
libdir=${prefix}/lib64

Name: vapoursynth
Description: VapourSynth
Version: 68
Libs: -L${libdir} -lVapourSynth.lib
Cflags: -I${includedir}
  1. LuaJIT requires sed to configure, which is not available on Windows by default. Since Git on Windows includes it, maybe a brief mention to change $env:PATH like $env:PATH += ';<git_directory>/usr/bin'?

@kasper93
Copy link
Contributor

kasper93 commented Jun 6, 2024

I agree with you on those points.

  1. I didn't mention it, because I have it directly integrated in terminal, but we can mention to open Developer PowerShell for VS or something. Windows Terminal automatically adds detected VS installations to its selection.
  2. This is unfortunate, because freetype have committed wraps in the repo, which are outdated. Indeed this step should be explicitly mentioned same as in cross-compilation section
    # Update the subprojects database from Meson's WrapDB.
    meson wrap update-db
    # Explicitly download wraps as nested projects may have older versions of them.
    meson wrap install expat
    meson wrap install harfbuzz
    meson wrap install libpng
    meson wrap install zlib
  3. Correct.
  4. and 5. We could mention about luajit, because it is enabled in the script, but for vapoursynth and all other possible dependencies, we have to stop somewhere, it is exercise for the reader to resolve remaining issues and build things they may need.

Feel free to send PR with your suggestions, it is good to have someone else to validate the workflow and identify issues like you did.

CrendKing added a commit to CrendKing/mpv that referenced this issue Jun 7, 2024
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 contains 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 mpv-player#14214
CrendKing added a commit to CrendKing/mpv that referenced this issue Jun 7, 2024
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 contains 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 mpv-player#14214
CrendKing added a commit to CrendKing/mpv that referenced this issue Jun 7, 2024
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 mpv-player#14214
CrendKing added a commit to CrendKing/mpv that referenced this issue Jun 7, 2024
Currently the documentation for building on Windows, specifically the
"Native Compilation with Clang (Windows SDK Build)" route, could use a
few minor improvement to make the development onboarding experience more
smoothly.

Fixes mpv-player#14214
@CrendKing
Copy link
Contributor Author

Feel free to send PR with your suggestions, it is good to have someone else to validate the workflow and identify issues like you did.

Here you are: #14315

CrendKing added a commit to CrendKing/mpv that referenced this issue Jun 7, 2024
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 mpv-player#14214
CrendKing added a commit to CrendKing/mpv that referenced this issue Jun 7, 2024
Currently the documentation for building on Windows, specifically the
"Native Compilation with Clang (Windows SDK Build)" route, could use a
few minor improvement to make the development onboarding experience more
smoothly.

Fixes mpv-player#14214
kasper93 pushed a commit that referenced this issue Jun 7, 2024
Currently the documentation for building on Windows, specifically the
"Native Compilation with Clang (Windows SDK Build)" route, could use a
few minor improvement to make the development onboarding experience more
smoothly.

Fixes #14214
CrendKing added a commit to CrendKing/mpv that referenced this issue Jun 8, 2024
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 mpv-player#14214
kasper93 pushed a commit that referenced this issue Jun 8, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta:feature-request meta:help-wanted Anyone is invited to help with this. Suitable for new developers with no experience with mpv code.
Projects
None yet
2 participants