Log in

View Full Version : VapourSynth - AUDIO SUPPORT AND NEW API BETA


Pages : 1 [2] 3

ChaosKing
18th August 2021, 10:44
But that only applies to plugins which uses nfMakeLinear. That's only a hand full.

Myrsloik
18th August 2021, 10:50
The gross performance degradation for API3 source filters with the beta API4 Vapoursynth effectively means you have abandoned backward compatibility for your API. That is a terrible thing. I strongly suggest you find a way to solve that.

Was this not a clear enough statement for you?

https://forum.doom9.org/showpost.php?p=1949996&postcount=2672

videoh
18th August 2021, 10:53
You said "probably". That is far from clear. I am trying to convince you to make it a certainty.

Myrsloik
21st August 2021, 19:53
UYVY will for sure - "Uncompressed video" to a NLE generally means UYVY for 8bit422 and v210 for 10bit422.

(Many do not handle uncompressed 8bit 4:2:0, but for the ones that do, the "magic" key is IYUV)

Most other variants/fourcc's are mishandled and converted to RGB (if they import at all)


(MOV support would increase compatibility too)

Implemented. Accessed by using vs.set_option('alt_output', x). Where 1 gives you I420, YUY2 or v210 and 2 gives you IYUV or UYVU depending on input. Will be in the next build.

poisondeathray
21st August 2021, 20:06
Implemented. Accessed by using vs.set_option('alt_output', x). Where 1 gives you I420, YUY2 or v210 and 2 gives you IYUV or UYVU depending on input. Will be in the next build.

Thanks,

Was UYVU a typo ? UYVY is the desired one

Myrsloik
21st August 2021, 20:07
Thanks,

Was UYVU a typo ? UYVY is the desired one

Yes, a typo.

feisty2
23rd August 2021, 18:49
is there a way to query the cache mode of a specific node in api v4? this is possible in api v3 by reading the "flags" field of the struct returned by getvideoinfo

Myrsloik
23rd August 2021, 19:36
is there a way to query the cache mode of a specific node in api v4? this is possible in api v3 by reading the "flags" field of the struct returned by getvideoinfo

getNodeDependencies is the closest you get. The cache mode is then determined from the number of consumers and a the request pattern specified.

Why do you need to know it anyway?

feisty2
24th August 2021, 03:20
well I never had a use case that requires the knowledge of the cache mode. I'm just cross-checking the API v3 functionalities and the corresponding API v4 ones.

lansing
25th August 2021, 16:37
The test installer didn't include the api4 headers in the sdk folder

Myrsloik
25th August 2021, 17:04
The test installer didn't include the api4 headers in the sdk folder

Will be fixed in the next build.

Myrsloik
25th August 2021, 20:40
It's RC1 time!

Notable changes from test3:

nfMakeLinear source filters now perform well again (FFMS2 was 50% faster than in the R54 API3 release in my very unscientific test)
It's now possible to select additional fourccs for output. Use vs.set_option('alt_output', x). Where 1 gives you I420, YUY2 or v210 and 2 gives you IYUV or UYVY depending on input. Invalid alt_output modes are simply ignored.
In Python you now access frame data with "plane = frame[0]" and then that's a 2d array, get_read/write_array() functions have been removed since they were broken in many subtle ways
The API4 headers are included in the installer
Lots of small bug fixes


Note that non-source filters that use nfMakeLinear (very few) still work poorly and will need to be manually updated.

videoh
25th August 2021, 21:31
nfMakeLinear source filters now perform well again Thank you.

Is there a way to install and test this without affecting my API3 install?

Myrsloik
25th August 2021, 21:49
Thank you.

Is there a way to install and test this without affecting my API3 install?

Use the portable version if you're fine with vspipe for output. Simply grab the python 3.9.x embedded version (https://www.python.org/ftp/python/3.9.6/python-3.9.6-embed-amd64.zip) and extract the portable VS version on top. Done!

Extracting vsedit in the same dir used to work too.

_Al_
25th August 2021, 23:42
Using that latest API4 R 55 portable RC1 version with latest portable python 3.9 on windows 7, running VSPipe.exe I get:
The program can't start because api-ms-win-core-path-|1-1-0.dll is missing from computer. Try reinstalling the program to fix this problem.
What do i have outdated? Older R51 portable is working.
Do I need Visual Studio 2019 for portable setup?

videoh
26th August 2021, 00:08
Use the portable version if you're fine with vspipe for output. Simply grab the python 3.9.x embedded version (https://www.python.org/ftp/python/3.9.6/python-3.9.6-embed-amd64.zip) and extract the portable VS version on top. Done! I don't know what this means. Any chance of a step-by-step? Thank you.

DJATOM
26th August 2021, 00:19
1) download https://www.python.org/ftp/python/3.9.6/python-3.9.6-embed-amd64.zip
2) extract it to for example VS-R55-API4
3) download https://github.com/vapoursynth/vapoursynth/releases/download/R55-API4-RC1/VapourSynth64-Portable-R55-API4-RC1.7z
4) extract contents of that archive into VS-R55-API4 (confirm overwrite of some files)
5) copy plugins into VS-R55-API4\vapoursynth64\plugins
6) if you want to add some importable scripts, copy them into VS-R55-API4 or edit python39._pth and add extra line with your scripts location (I'm using ./vs-scripts)
7) if you willing to use some preview application (VapourSynth Editor), there's https://github.com/YomikoR/VapourSynth-Editor/releases/download/r19-mod-1/VapourSynth-Editor-r19-mod-1-x86_64.7z which works with APIv4 Vapoursynth (extract contents into VS-R55-API4)

I believe that's enough to get things working.

poisondeathray
26th August 2021, 00:24
embedded + portable vapoursynth seems to work for me on simple scripts so far (using similar procedure as DJATOM) , but I have same installed python version as the embedded version and it doesn't work with the installed version - "Failed to initialize VSScript"

Is there anyway I can use installed python version with the portable vapoursynth version?

poisondeathray
26th August 2021, 02:23
It's now possible to select additional fourccs for output. Use vs.set_option('alt_output', x). Where 1 gives you I420, YUY2 or v210 and 2

gives you IYUV or UYVY depending on input. Invalid alt_output modes are simply ignored.

Does not seem to work correctly - I tried different combinations like putting it before/after set_output(),

VapourSynth-Editor-r19-mod-1 shows no error, preview ok


import vapoursynth as vs
core = vs.core
clip = core.std.BlankClip(width=1920,height=1080,format=vs.YUV422P8, length=300, color=[16, 128, 128])
#clip = core.std.BlankClip(width=1920,height=1080,format=vs.YUV422P10, length=300, color=[64, 512, 512])
clip = core.std.AssumeFPS(clip, fpsnum=30000, fpsden=1001)
clip = core.text.FrameNum(clip)
#vs.set_option('alt_output', 1)
#vs.set_option('alt_output', 2)
clip.set_output()
#vs.set_option('alt_output', 1)
vs.set_option('alt_output', 2)


bundled vspipe -v says
Core R54
API R4.0
API R3.6

using avfs
"PATH\python-3.9.6-embed-amd64\avfs" yuv422_alt1.vpy gives yv16 according to mediainfo (should be YUY2)
"PATH\python-3.9.6-embed-amd64\avfs" yuv422_alt2.vpy gives yv16 according to mediainfo (should be UYVY)

"PATH\python-3.9.6-embed-amd64\avfs" yuv422p10_alt1.vpy gives p210 according to mediainfo (should be v210)

using vspipe to ffmpeg
"PATH\python-3.9.6-embed-amd64\vspipe" --y4m yuv422_alt2.vpy - | ffmpeg -f yuv4mpegpipe -i - -an -f null NUL

ffmpeg reports Y42B, yuv422p . Normally it should say UYVY , uyvy422

videoh
26th August 2021, 02:50
1) download https://www.python.org/ftp/python/3.9.6/python-3.9.6-embed-amd64.zip
2) extract it to for example VS-R55-API4
...
I believe that's enough to get things working.

Thank you, DJ!

lansing
26th August 2021, 03:16
In VSScript.h there's a vsscript_finalize() to free the runtime, what do I do for this with VSScript4.h?

Myrsloik
26th August 2021, 03:32
In VSScript.h there's a vsscript_finalize() to free the runtime, what do I do for this with VSScript4.h?

You don't have to do anything when done now

lansing
26th August 2021, 09:20
This change in video format id comparison is getting too long?

// api3
if(cpVideoFormat.id == pfRGB24) {}

// api4
uint32_t formatId = m_cpVSAPI->queryVideoFormatID(cpVideoFormat.colorFamily,
cpVideoFormat.sampleType, cpVideoFormat.bitsPerSample, cpVideoFormat.subSamplingW,
cpVideoFormat.subSamplingH, m_pCore);

if(formatId == pfRGB24){}


Or, is this the correct way to use it?

int formatIdFound = m_cpVSAPI->getVideoFormatByID(&cpVideoFormat, pfRGB24, m_pCore);

if (formatIdFound != 0) {}

lansing
26th August 2021, 09:51
The field base enum in the VSConstants4.h is wrong


typedef enum VSFieldBased {
VSC_FIELD_PROGRESSIVE = 0,
VSC_FIELD_TOP = 1,
VSC_FIELD_BOTTOM = 2
} VSFieldBased;


The documentation (http://www.vapoursynth.com/doc/apireference.html) said that bff is 1 and tff is 2.

Myrsloik
26th August 2021, 12:08
The field base enum in the VSConstants4.h is wrong


typedef enum VSFieldBased {
VSC_FIELD_PROGRESSIVE = 0,
VSC_FIELD_TOP = 1,
VSC_FIELD_BOTTOM = 2
} VSFieldBased;


The documentation (http://www.vapoursynth.com/doc/apireference.html) said that bff is 1 and tff is 2.

Will fix. There are some comparison helper functions in https://github.com/vapoursynth/vapoursynth/blob/doodle1/include/VSHelper4.h#L93. I'll probably add some more to cover VideoFormat and pfConstant later.

Myrsloik
26th August 2021, 12:12
Does not seem to work correctly - I tried different combinations like putting it before/after set_output(),

VapourSynth-Editor-r19-mod-1 shows no error, preview ok


import vapoursynth as vs
core = vs.core
clip = core.std.BlankClip(width=1920,height=1080,format=vs.YUV422P8, length=300, color=[16, 128, 128])
#clip = core.std.BlankClip(width=1920,height=1080,format=vs.YUV422P10, length=300, color=[64, 512, 512])
clip = core.std.AssumeFPS(clip, fpsnum=30000, fpsden=1001)
clip = core.text.FrameNum(clip)
#vs.set_option('alt_output', 1)
#vs.set_option('alt_output', 2)
clip.set_output()
#vs.set_option('alt_output', 1)
vs.set_option('alt_output', 2)


bundled vspipe -v says
Core R54
API R4.0
API R3.6

using avfs
"PATH\python-3.9.6-embed-amd64\avfs" yuv422_alt1.vpy gives yv16 according to mediainfo (should be YUY2)
"PATH\python-3.9.6-embed-amd64\avfs" yuv422_alt2.vpy gives yv16 according to mediainfo (should be UYVY)

"PATH\python-3.9.6-embed-amd64\avfs" yuv422p10_alt1.vpy gives p210 according to mediainfo (should be v210)

using vspipe to ffmpeg
"PATH\python-3.9.6-embed-amd64\vspipe" --y4m yuv422_alt2.vpy - | ffmpeg -f yuv4mpegpipe -i - -an -f null NUL

ffmpeg reports Y42B, yuv422p . Normally it should say UYVY , uyvy422

Core R54 <= you've accidentally used an older version somehow

poisondeathray
26th August 2021, 14:16
Core R54 <= you've accidentally used an older version somehow


You're right :o

Core R55
API R4.0
API R3.6


But with Core R55, ffmpeg still reports Y42B, yuv422p for the yuv422 alt2 script .

Also, avfs now crashes when file is accessed, even a plain BlankClip script (without alt_output options) . It "mounts", but as soon as you touch or access the fake avi, it crashes no helpful error message

Calling old avfs with same plain BlankClip script does not crash

Myrsloik
26th August 2021, 18:42
In case anyone's wondering the part of the API in vsscript4.h is not considered stable. I predict that it will be rolled back closer to something along the lines of the old api.

feisty2
26th August 2021, 20:58
is there a functionality in API v3 that corresponds to setCacheOptions in API v4?

Myrsloik
26th August 2021, 21:21
is there a functionality in API v3 that corresponds to setCacheOptions in API v4?

The closest thing is if you manually insert a cache and pass a bunch of arguments to it. But the arguments are quite different in api3 so even that's questionable.

lansing
26th August 2021, 23:13
How do I get a map of functions from a plugin in api4?


VSMap * FunctionsMap = VSAPI->getFunctions(Plugin);

Myrsloik
26th August 2021, 23:51
How do I get a map of functions from a plugin in api4?


VSMap * FunctionsMap = VSAPI->getFunctions(Plugin);


Use getNextPluginFunction(plugin, nullptr)
Then pass the returned pointer to the function until it returns null. That means you've enumerated all plugins.

lansing
27th August 2021, 00:22
Use getNextPluginFunction(plugin, nullptr)
Then pass the returned pointer to the function until it returns null. That means you've enumerated all plugins.

Like this? Do I need to free the function every loop before getting a new one?


VSPluginFunction * function = VSAPI->getNextPluginFunction(nullptr, Plugin);

while (function != nullptr) {
# do stuff with function
function = VSAPI->getNextPluginFunction(nullptr, Plugin);
}

Myrsloik
27th August 2021, 00:51
Correct, you don't have to free anything.

lansing
27th August 2021, 07:17
What does the argument string returned by "vsapi->getPluginFunctionArguments(function)" look like? I didn't see any example in the api

lansing
27th August 2021, 20:27
How do I get the videoFormat name and uses it in one line like in api3?


myFunction(videoInfo->format.name);

Myrsloik
27th August 2021, 20:55
How do I get the videoFormat name and uses it in one line like in api3?


myFunction(videoInfo->format.name);


One line?
char name[32]; vsapi->getVideoFormatName(&videoInfo.format, name); myFunction(name);

But more seriously, use a lambda or something if you need it many times in the same function.

Myrsloik
27th August 2021, 21:21
Using that latest API4 R 55 portable RC1 version with latest portable python 3.9 on windows 7, running VSPipe.exe I get:
The program can't start because api-ms-win-core-path-|1-1-0.dll is missing from computer. Try reinstalling the program to fix this problem.
What do i have outdated? Older R51 portable is working.
Do I need Visual Studio 2019 for portable setup?

Install the most recent vs2019 runtime manually.

lansing
27th August 2021, 22:03
One line?
But more seriously, use a lambda or something if you need it many times in the same function.

This is another use case in api3:

infoString.replace("%format%", videoInfo->format.name);

Yomiko
28th August 2021, 05:05
core.add_cache is removed (although remains in the doc). May I know about a replacement for it?

Myrsloik
28th August 2021, 10:26
core.add_cache is removed (although remains in the doc). May I know about a replacement for it?

Cache insertion is now handled by the core so there's no direct replacement. If you want to change the automatic decision to add a lot of caching on your output simply use the SeVideoCache/SetAudioCache functions.

Yomiko
28th August 2021, 11:47
Thanks. Also I see all the arguments are required in these functions. Is it as intended?

Myrsloik
28th August 2021, 12:02
Thanks. Also I see all the arguments are required in these functions. Is it as intended?

No, they should obviously be optional

Yomiko
30th August 2021, 03:40
>>> import vapoursynth as vs
>>> core = vs.core
>>> clip = core.std.BlankClip(width=1921, height=1081, format=vs.RGB48)
>>> frame = clip.get_frame(2)
>>> frame[0] == frame[2]
True
>>> frame[0] == frame[1]
True
>>> frame = clip.get_frame(22)
>>> frame[0]
<memory at 0x0000021EE196B930>
>>> frame[1]
<memory at 0x0000021EE196B860>
>>> frame[2]
<memory at 0x0000021EE196B930>
>>>
Is it as intended in R55-RC1?

Myrsloik
30th August 2021, 07:19
>>> import vapoursynth as vs
>>> core = vs.core
>>> clip = core.std.BlankClip(width=1921, height=1081, format=vs.RGB48)
>>> frame = clip.get_frame(2)
>>> frame[0] == frame[2]
True
>>> frame[0] == frame[1]
True
>>> frame = clip.get_frame(22)
>>> frame[0]
<memory at 0x0000021EE196B930>
>>> frame[1]
<memory at 0x0000021EE196B860>
>>> frame[2]
<memory at 0x0000021EE196B930>
>>>
Is it as intended in R55-RC1?

Yes, it's how you access plane data now

Myrsloik
2nd September 2021, 10:09
RC2 posted. Changes:

Reworked vsscript api to restore api3 functionality
AVFS fixes (packed RGB in Avisynth scripts)
Uses new and faster libp2p for packing
Removed lots of Python functions that have been deprecated since at least R51
API4 headers actually included in installer


Things you can do to help:

Update the __all__ tag in vapoursynth.pyx with all relevant symbols
Create vsscript4.h.rst and vshelper4.h.rst (these are simple and work 99% like the api3 counterparts)
Review pythonreference.rst (mostly updated by me already but probably missing some functions)
Review all other documentation.

lansing
2nd September 2021, 15:57
The VSVideoFormat argument of isSameVideoPresetFormat() is missing the "constant" declaration?

Myrsloik
2nd September 2021, 17:50
The VSVideoFormat argument of isSameVideoPresetFormat() is missing the "constant" declaration?

Correct. Will be fixed.

poisondeathray
2nd September 2021, 20:45
was the vs.set_option('alt_output', X) removed from RC2 ?

Myrsloik
2nd September 2021, 21:05
was the vs.set_option('alt_output', X) removed from RC2 ?

Yes, now alt_output is an optional argument to set_output(). Makes more sense that way.