View Full Version : Vapoursynth
lansing
27th October 2021, 06:16
Thanks, worked.
Now I ran into another problem trying to build the filter. The build succeeded, but the function didn't get register. Here is the xxxCreate function.
void VS_CC levelsCreate(const VSMap *in, VSMap *out, void *userData, VSCore *core, const VSAPI *vsapi) {
LevelsData d;
LevelsData *data;
int err;
d.node = vsapi->mapGetNode(in, "clip", 0, 0);
d.vi = *vsapi->getVideoInfo(d.node);
d.factor = vsapi->mapGetFloat(in, "factor", 0, &err);
if (err) {
d.factor = 100.0;
}
// Comparing them directly?
if (d.factor < 0.0 || d.factor > 100.0) {
vsapi->mapSetError(out, "Levels: factor must be between 0 and 100 (inclusive)");
vsapi->freeNode(d.node);
return;
}
if (!vsh_isConstantVideoFormat(&d.vi) || d.vi.format.sampleType != stInteger || d.vi.format.bitsPerSample != 8) {
vsapi->mapSetError(out, "Levels: only constant format 8bit integer input supported");
vsapi->freeNode(d.node);
return;
}
if (d.vi.width)
d.vi.width += 256;
if (d.vi.height)
d.vi.height = MAX(256, d.vi.height);
data = (LevelsData *)malloc(sizeof(d));
*data = d;
VSFilterDependency deps[] = { {d.node, rpStrictSpatial} };
vsapi->createVideoFilter(out, "Levels", &d.vi, levelsGetFrame, levelsFree, fmParallel, deps, 1, data, core);
}
########################################
void VS_CC levelsCreate(const VSMap *in, VSMap *out, void *userData, VSCore *core, const VSAPI *vsapi);
VS_EXTERNAL_API(void) VapourSynthPluginInit2(VSPlugin* plugin, const VSPLUGINAPI* vspapi) {
vspapi->configPlugin("com.nodame.histogram", "hist", "VapourSynth Histogram Plugin", VS_MAKE_VERSION(1, 0), VAPOURSYNTH_API_VERSION, 1, plugin);
vspapi->registerFunction("Levels", "clip:clip;factor:float:opt;", "clip:vnode;", levelsCreate, NULL, plugin);
}
vsedit2 was able to read the plugin "hist", but not the function "Levels". What am I doing wrong?
Yomiko
27th October 2021, 07:05
Maybe clip:vnode in the signature.
But if the filter is only for vsedit2, I think having createVideoFilter(2) called in the filter chain should be sufficient.
lansing
27th October 2021, 07:44
Maybe clip:vnode in the signature.
Thank you, that is the problem. I was looking at the codes for hours and couldn't figure it out.
Myrsloik
27th October 2021, 11:37
Protip: if you misuse the api you'll get warnings for things like invalid argument strings if you run things from the commandline
lansing
28th October 2021, 08:31
Protip: if you misuse the api you'll get warnings for things like invalid argument strings if you run things from the commandline
What about debugging crashes. My test filter tested okay on vspipe --info but crashes on preview, what do I do?
Myrsloik
28th October 2021, 12:23
What about debugging crashes. My test filter tested okay on vspipe --info but crashes on preview, what do I do?
Attach a debugger, duh. If there's no error message then your own code crashed inside the getframe function.
lansing
28th October 2021, 17:26
I want to rotate the frame inside the filter, can I call like std.Transpose and std.FlipHorizontal in the filter?
Myrsloik
28th October 2021, 17:49
I want to rotate the frame inside the filter, can I call like std.Transpose and std.FlipHorizontal in the filter?
Yes, use invoke. You can look at the code of SCDetect on how to do it here:
https://github.com/vapoursynth/vs-miscfilters-obsolete/blob/master/src/miscfilters.cpp#L132
lansing
28th October 2021, 21:58
Yes, use invoke. You can look at the code of SCDetect on how to do it here:
https://github.com/vapoursynth/vs-miscfilters-obsolete/blob/master/src/miscfilters.cpp#L132
What if I want to do rotate right -> process the frame -> rotate left? It feels like doing the last rotate in the xxxFree function is too late in the process?
Myrsloik
28th October 2021, 22:54
What if I want to do rotate right -> process the frame -> rotate left? It feels like doing the last rotate in the xxxFree function is too late in the process?
Use createVideoFilter2() and then simply call invoke on the node returned from there. Same idea.
Not the best example but few places do this in the VS code (see unpackRGB32Create):
https://github.com/vapoursynth/vapoursynth/blob/master/src/avisynth/avisynth_compat.cpp#L897
lansing
29th October 2021, 00:07
Use createVideoFilter2() and then simply call invoke on the node returned from there. Same idea.
Not the best example but few places do this in the VS code (see unpackRGB32Create):
https://github.com/vapoursynth/vapoursynth/blob/master/src/avisynth/avisynth_compat.cpp#L897
So the structure would be like this?
static const VSFrame *VS_CC firstGetFrame() {}
static const VSFrame *VS_CC finalGetFrame() {
return frame;
}
void VS_CC filterCreate() {
d.node = vsapi->mapGetNode(in, "clip", 0, 0);
// call invoke on node
VSNode * node2 = vsapi->createVideoFilter2(firstGetFrame, freeFunc1, data);
// call invoke on node2
d.node = node2;
vsapi->createVideoFilter(finalGetFrame, freeFunc2, data);
}
Yomiko
29th October 2021, 00:20
from boxblur
https://github.com/vapoursynth/vapoursynth/blob/master/src/core/boxblurfilter.cpp#L294-L307
lansing
29th October 2021, 04:44
I'm seeing two patterns from the examples above about chaining invoke, it got me confused:
#1:
invmap2 = vsapi->invoke(stdplugin, "Trim", invmap);
...
vsapi->mapConsumeNode(invmap, "clipb", vsapi->mapGetNode(invmap2, "clip", 0, nullptr), maAppend);
...
invmap2 = vsapi->invoke(stdplugin, "PlaneStats", invmap);
#2
vsapi->createVideoFilter(vtmp2, "BoxBlur", xxx);
vtmp1 = vsapi->invoke(stdplugin, "Transpose", vtmp2);
In the first example, after the first invoke, the resulting node has to be consumed into a new map before pluging it into another invoke.
But in the second example, the resulting map just go straight to an invoke without the node consume?
Myrsloik
29th October 2021, 09:41
Sometimes thebmap returned from invoke has the right contents and then it can be passed to invoke immediately. If it doesn't you have have to do more map manipulation.
lansing
30th October 2021, 05:17
ShufflePlanes should automatically strip the "_Matrix" property if the target color family is vs.GRAY. otherwise an error message pops up bitchin' about "no _Matrix stuff allowed for GRAY" or whatever and you have to manually remove the "_Matrix" thingy before ShufflePlanes which is very annoying.
I just encountered this annoyance, is there a better solution now?
lansing
30th October 2021, 06:40
Format conversion from a Shuffleplanes causes a shift in chroma?
clip = yuv_clip
clip = core.std.ShufflePlanes(clip, 0, colorfamily=vs.YUV)
#clip = core.resize.Point(clip, format=vs.YUV444P8) // no shift
clip = core.resize.Point(clip, format=vs.YUV420P8) // chroma shift
Yomiko
30th October 2021, 14:51
Point (nearest neighbor) is supposed to be like that. It never blends neighboring pixels.
lansing
30th October 2021, 15:32
Point (nearest neighbor) is supposed to be like that. It never blends neighboring pixels.
There's a shift with all other resizers too. And I thought for format conversion purpose, all the resizers should be the same?
Selur
30th October 2021, 17:20
An option to disable auto loading is probably coming soon. With more exciting things as well.
Any news in this regard?
Cu Selur
lansing
30th October 2021, 23:04
When extracting RGB planes from a RGB clip, Shuffleplanes is outputting the wrong clip if I set the "colorfamily" to YUV
rgb_clip = core.resize.Point(clip, matrix_in_s="709", format=vs.RGB24)
clip = core.std.ShufflePlanes(rgb_clip, 0, colorfamily=vs.YUV)
I was expecting to get a yuv clip of a grayscale, but this output a yuv clip of green and pink.
ChaosKing
31st October 2021, 12:27
Is there a replacement for https://github.com/AmusementClub/VapourSynth-EEDI2CUDA ? ( repo was deleted)
If not then I will remove it from vsrepo.
sl1pkn07
31st October 2021, 12:39
https://github.com/kedaitinh12/VapourSynth-EEDI2CUDA
but i'm not sure if is updated
ChaosKing
31st October 2021, 13:10
No releases :(
kedautinh12
31st October 2021, 13:46
Here: https://github.com/kedaitinh12/VapourSynth-EEDI2CUDA/releases
And i ain't a developer, if anyone have attention that project can folk them :D
LigH
1st November 2021, 10:08
I guess that means: If anyone wants to maintain this project, please fork it.
kedautinh12
1st November 2021, 11:43
I guess that means: If anyone wants to maintain this project, please fork it.
Yes, sr for my bad English :D
Selur
1st November 2021, 20:46
Did something change with vs-imwri?
I'm using R1 from https://github.com/vapoursynth/vs-imwri/releases/tag/R1 with Vapoursynth R57 and this code:
[logo, alpha] = core.imwri.Read(filename="C:/Users/Selur/smallLogo.png", alpha=True)
but get "Python exception: not enough values to unpack (expected 2, got 1)" same code worked fine (with the same logo) with R54 and the old plugin.
Tested on MacOS and Windows 10.
Cu Selur
Myrsloik
1st November 2021, 22:00
Did something change with vs-imwri?
I'm using R1 from https://github.com/vapoursynth/vs-imwri/releases/tag/R1 with Vapoursynth R57 and this code:
[logo, alpha] = core.imwri.Read(filename="C:/Users/Selur/smallLogo.png", alpha=True)
but get "Python exception: not enough values to unpack (expected 2, got 1)" same code worked fine (with the same logo) with R54 and the old plugin.
Tested on MacOS and Windows 10.
Cu Selur
logo = core.imwri.Read(filename="C:/Users/Selur/smallLogo.png", alpha=True)
alpha = core.std.PropToClip(logo)
Selur
3rd November 2021, 05:46
Thanks that works!
Any news on an option to disable auto loading ?
ChaosKing
3rd November 2021, 08:15
Thanks that works!
Any news on an option to disable auto loading ?
I'm also waiting for it since 2018 now :D
Myrsloik
3rd November 2021, 22:48
I'm also waiting for it since 2018 now :D
Why U no autoload? There are no plugins that ruin your day like that other unnamed competing application does.
ChaosKing
3rd November 2021, 23:09
I autoload !!!!1111
But for software where I want to use a specific version of let's say ffms2, autoloading is preventing me of loading my version (or you need to use VS portable version). This is one example https://forum.doom9.org/showthread.php?t=176231
Selur
4th November 2021, 05:48
@Myrsloik: because I want to be sure that:
a. no libary gets loaded twice
b. the libaries I need are loaded
c. when hunting for problems switching libaries to check whether the problem was caused by a libary update is easier when I just have to change the script.
this is a pain when users start to mix the plugins that I provide with Hybrid with some they installed from other sources. Being able to disable autoload simple allows to keep control.
Cu Selur
Ps.: libimwri filter is not autoloaded on MacOS, which is why l33tmeatwad included the old version with its installer (see: https://forum.doom9.org/showthread.php?p=1956162#post1956162)
poisondeathray
5th November 2021, 23:50
Another alpha channel question for r57; A prores video with alpha channel , loading with LibavSMASHSource.
setVideoInfo: Video filter LibavSMASHSource has more than one output node but only the first one will be returned
In old R5x versions you could specify clip[1].set_output() for the alpha node, but it looks like it's not even loaded by the source filter
poisondeathray
6th November 2021, 00:02
What is the setup for portable python/vapoursynth setup for accessing "site-packages" folder ?
ChaosKing
6th November 2021, 09:12
For python portable you can control which site-packages to use / access via a path file "python39._pth"
Here's the file I use for my portable fatpack
https://github.com/theChaosCoder/vapoursynth-portable-FATPACK/blob/master/python39._pth
this way I can put all vs scripts into Scripts and the python stuff are Lib\site-packages. You can add as many folders as you want I think.
Yomiko
6th November 2021, 10:02
2. It's an array where you list all the nodes and in which order you will request frames from them to generate the output.
A stupid question:
To what extent does the order matter? For example, if I had vnodes v1 and v2 in the dep list, but v2 was derived by invoking a plugin with v1. What might happen if v1 and v2 were declared in the wrong order?
Selur
6th November 2021, 13:52
In old R5x versions you could specify clip[1].set_output() for the alpha node, but it looks like it's not even loaded by the source filter
I like to know that too how to get the alpha channel.
poisondeathray
7th November 2021, 04:22
For python portable you can control which site-packages to use / access via a path file "python39._pth"
Here's the file I use for my portable fatpack
https://github.com/theChaosCoder/vapoursynth-portable-FATPACK/blob/master/python39._pth
this way I can put all vs scripts into Scripts and the python stuff are Lib\site-packages. You can add as many folders as you want I think.
Works, thanks
What I wanted to do is keep an installed version ,and portable version, but use the portable version for testing purposes and not have to double up on everything . (I was able to edit the path to a custom one)
DTL
7th November 2021, 20:54
pinterf suggest to ask Vapoursynth developers about largepages usage and skipping in the last builds. What was the reason of skipping use of large pages in the last builds ?
As I see it is hard to allocate on running windows enough number of large pages after system and applications running because of memory fragmentation. So for general use in user-ring frequently start and end application for the large allocations it possibly not applicable. And to set ring-0 driver for allocation most of RAM as large pages at boot time mean to lost this memory from all other system and may be not user-friendly for desktop PC.
Or may be special helper process of defragment memory at windows runtime required and immediate gathering defragmented physical parts for application as large pages.
I tried to make avisynth mod with allocating large pages for frame buffers and for unknown reason the performance of MDegrain was lower. But for small vectors buffer of about 1 2 MB LP size it looks like help to reduce TLB reload and runs a bit faster at large frame size.
So may be at current time the use of small amount of large pages for highly loaded random access small buffers is good but for most of RAM for large processing simply not possible or slower ? I hope there is not performance penalty on mixing use of 4 kB and large pages in one process.
Myrsloik
8th November 2021, 07:40
A stupid question:
To what extent does the order matter? For example, if I had vnodes v1 and v2 in the dep list, but v2 was derived by invoking a plugin with v1. What might happen if v1 and v2 were declared in the wrong order?
Order doesn't matter in the list.
Myrsloik
8th November 2021, 07:43
I like to know that too how to get the alpha channel.
Use PropToClip on the output. But at the moment alpha simply gets stored as the _Alpha property. Maybe I should actually do that internally in these filters.
Myrsloik
8th November 2021, 07:45
pinterf suggest to ask Vapoursynth developers about largepages usage and skipping in the last builds. What was the reason of skipping use of large pages in the last builds ?
As I see it is hard to allocate on running windows enough number of large pages after system and applications running because of memory fragmentation. So for general use in user-ring frequently start and end application for the large allocations it possibly not applicable. And to set ring-0 driver for allocation most of RAM as large pages at boot time mean to lost this memory from all other system and may be not user-friendly for desktop PC.
Or may be special helper process of defragment memory at windows runtime required and immediate gathering defragmented physical parts for application as large pages.
I tried to make avisynth mod with allocating large pages for frame buffers and for unknown reason the performance of MDegrain was lower. But for small vectors buffer of about 1 2 MB LP size it looks like help to reduce TLB reload and runs a bit faster at large frame size.
So may be at current time the use of small amount of large pages for highly loaded random access small buffers is good but for most of RAM for large processing simply not possible or slower ? I hope there is not performance penalty on mixing use of 4 kB and large pages in one process.
No measurable performance benefit. At all. So when things were reworked the feature got cut. You can still play around with it in the API3 builds if you don't believe me.
poisondeathray
8th November 2021, 16:54
Use PropToClip on the output. But at the moment alpha simply gets stored as the _Alpha property. Maybe I should actually do that internally in these filters.
_Alpha is apparently not loaded by LSmash ; and there is no "alpha=True" switch.
setVideoInfo: Video filter LibavSMASHSource has more than one output node but only the first one will be returned
The same .dll loads the alpha in vapoursynth R54, and is accessible with clip[1].set_output()
clip = core.lsmas.LibavSMASHSource(r'prores4444.mov')
alpha = core.std.PropToClip(clip)
alpha.set_output()
vapoursynth.Error: PropToClip: no frame stored in property: _Alpha
PropToClip works ok with imwri as source for images, alpha=True
Selur
8th November 2021, 18:35
vapoursynth.Error: PropToClip: no frame stored in property: _Alpha
Yup, same here works fine with imwri, doesn't work with lsmas.LibavSMASHSource.
Myrsloik
8th November 2021, 21:52
Yup, same here works fine with imwri, doesn't work with lsmas.LibavSMASHSource.
Needs to be updated for API4 then. Poke the author.
poisondeathray
8th November 2021, 23:05
Needs to be updated for API4 then. Poke the author.
It works with vA.3g , (vapoursynth only release) by AkarinVS
https://github.com/AkarinVS/L-SMASH-Works/releases
Selur
9th November 2021, 19:05
good find:
https://github.com/VFR-maniac/L-SMASH-Works no updates the last 2 years
https://github.com/enccc/L-SMASH-Works no updates the last 4 years
https://github.com/HolyWu/L-SMASH-Works no updates the last 6 month and is read only
seem like https://github.com/AkarinVS/L-SMASH-Works is the only repository that is seems active,...
Yomiko
11th November 2021, 02:59
How can I get a list of available output indices via vsscript api?
Myrsloik
11th November 2021, 13:52
How can I get a list of available output indices via vsscript api?
You can't. Trial and error is the only way. Note that I only ever use index 0 for video/audio and 1 for audio (when both are present).
Realistically you can test the first 100 outputs in no time and call it good enough if you want to allow fast switching for comparisons and stuff.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.