-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
vf_vapoursynth: upgrade to VapourSynth API v4 #14326
Conversation
d7efa86
to
ab99b86
Compare
Don't forget to update version check in meson.build |
Download the artifacts for this pull request: |
I will. Thanks for reminding me. |
It is a breaking change to existing scripts. I suggest mentioning it in docs. |
Of course. Let me lay down what I think are user impacting:
Let me know if I missed any. |
I am too busy to test. I just wonder did it improve the terrible seeking performance especially when you use the heavy vs filter? |
It's already mentioned. vpy script API is incompatible and some deprecated functions are removed. |
Well, it heavily depends on the logic of the script and plugin it uses. But I think it must came from the |
I understand. You mean the incompatibility from VapourSynth itself, as they mentioned in http://www.vapoursynth.com/2021/09/r55-audio-support-and-improved-performance/. Maybe I could just link the URL in our doc? |
Sounds good. |
I'm trying to test the PR with build from the Actions. As kasper93 mentioned, only the MSYS2 build enables VapourSynth. Unfortunately, the MSYS2 build doesn't upload artifact. Is there particular reason why it's disabled, other than of course the Actions storage limitation? I do hope the MSYS2 artifacts are available. |
af50271
to
82a681f
Compare
MSYS2 built binaries require sysroot to work, unless linked fully statically. We don't want to pack it. Those jobs are only build test, not meant to be shipped. We have MSVC and mingw cross build already. |
OK. Thanks for info. |
6fde816
to
2cbe150
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I've not tested it excessively. But should be fine.
VapourSynth introduced their version 4 API in R55, 3 years ago. mpv is still using the deprecated version 3. I think it is good to migrate before VapourSynth completely removes it. The most impacted area is the video format. Previously we have a fixed table of supported formats, each represented by an integer. In v4, the integer is replaced by pointer to the full struct of the format. Second, the way to create video filter is changed. Previously caller needs to supply a "initialization" callback to `createFilter()`, which sets up video info etc. In v4, video info is prepared first, passed to the `createVideoFilter2()` and we get back the node. Also, previously mpv was using the `fmSerial` filter mode, which means VapourSynth 1) can only request one frame from mpv at a time, and 2) the order of frames requested must be sequential. I propose to change it to the parallel request mode, which requests multiple frames at a time in semi random order. The reasons are, for 1), the get frame function, `infiltGetFrame()`, unlocks the mutex during output image generation, thus can benefit from parallel requests. For 2) thanks to the frame buffer, unordered frame requests are acceptable. Just make sure the buffer is large enough. Third, the way VapourSynth scripting environment works change. In v4, the scripting API is operated through struct pointer, much like the exist `vsapi` pointer. The "finalize" function is also no longer needed.
Thank you! I wish one more people can test before we commit, especially on the filter mode change (serial -> parallel). I probably don't use enough variety of VS plugins to cover all cases. |
Real testing will be after we merge, nobody really goes into PRs and test them. Especially for more niche features. |
Gotcha. Let's merge then. I'll try to monitor Issues see anyone report related. If I miss any, feel free to assign me. |
VapourSynth introduced their version 4 API in R55, 3 years ago. mpv is still using the deprecated version 3. I think it is good to migrate before VapourSynth completely removes it.
The gist of the change is documented in https://github.com/vapoursynth/vapoursynth/blob/master/APIV4%20changes.txt. The most impacted area is the video format. Previously we have a fixed table of supported formats, each represented by an integer. In v4, the integer is replaced by pointer to the full struct of the format. More details below.
Second, the way to create video filter is changed. Previously caller needs to supply a "initialization" callback to
createFilter()
, which sets up video info etc. In v4, video info is prepared first, passed to thecreateVideoFilter2()
and we get back the node.Also, previously mpv was using the
fmSerial
filter mode, which means VapourSynth 1) can only request one frame from mpv at a time, and 2) the order of frames requested must be sequential. I propose to change it to the parallel mode, which requests multiple frames at a time in semi random order. The reasons are, for 1), the get frame function,infiltGetFrame()
, unlocks the mutex during output image generation, thus can benefit from parallel get. For 2) thanks to the frame buffer, unordered frame requests are acceptable. Just make sure the buffer is large enough.Third, the way VapourSynth scripting environment works change. In v4, the scripting API is operated through struct pointer, much like the exist
vsapi
pointer. The "finalize" function is also no longer needed.More on video formats
I took liberty to change how we handle input and output formats. Previously,
mp_autoconvert
to convert input format into one of the supported VapourSynth formats, defined in thempvs_fmt_table
table.mp_image
for downstream.What I did are:
mpvs_fmt_table
table to determine if a format is valid. Instead rely on whether a format can be handled both by mpv and VapourSynth.List of currently supported formats for VapourSynth
False positive input formats (all deprecated in AVPixelFormat), indistinguishable from their non-jpeg counterpart due to difference only in color range