mpv icon indicating copy to clipboard operation
mpv copied to clipboard

A way to pass arbitrary user data to VapourSynth script

Open CrendKing opened this issue 1 year ago • 0 comments

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

CrendKing avatar May 22 '24 21:05 CrendKing