View Full Version : Vapoursynth
lansing
30th September 2017, 18:27
I need a sample to debug this. It should be doing the right thing already.
http://www.mediafire.com/file/r7lrydac2f6u8b4/rgb24.avi
DJATOM
4th October 2017, 12:54
I have hard times compiling r38 (as well as master) on Debian 8: https://pastebin.com/X8YZ7bEm
Is gcc 4.9 too old for it?
Myrsloik
4th October 2017, 13:07
I have hard times compiling r38 (as well as master) on Debian 8: https://pastebin.com/X8YZ7bEm
Is gcc 4.9 too old for it?
Too old ffmpeg probably
DJATOM
4th October 2017, 15:13
Managed to build and install VS using ffmpeg from git, thanks for suggestion.
Myrsloik
7th October 2017, 22:48
R39 released. Important changes listed here (http://www.vapoursynth.com/2017/10/r39-fixing-bugs-and-undoing-bad-ideas/).
hydra3333
8th October 2017, 04:13
thank you.
hydra3333
8th October 2017, 07:29
Glorious changes:
r39:
...
switched to nasm as the assembler
...
OK, thank you.
Having previously rebuilt avisynth_compat.cpp a few times, I thought I'd give it a go again (the solution relied on yasm) . The updated build instructions say
Needs Visual Studio 2017 and vsnasm (https://github.com/ShiftMediaProject/VSNASM) So I downloaded VSNASM. Following instructions, in it's readme,
The project provides a basic installer script that can automatically detect any installed Visual Studio 2013, 2015 or 2017 installation and then install the required components. To use this script simply run 'install_script.bat' from an elevated command prompt. the 'install_script.bat' failed - it couldn't find vs2017 - so I will give the manual nasm install a go, unless you have other suggestions ?
Myrsloik
8th October 2017, 12:36
I think the trick is to run it from a vs2017 command prompt to make it find the proper install path
hydra3333
8th October 2017, 14:09
I think the trick is to run it from a vs2017 command prompt to make it find the proper install path
Updated VS2017, rebooted, did it -
c:\temp\VSNASM-master\install_script.bat"
Detected 64 bit system running 32 bit shell...
Existing Visual Studio environment detected...
Access is denied.
The system cannot find the file specified.
The system cannot find the path specified.
Installing build customisations...
Error: Failed to copy build customisations
Ensure that this script is run in a shell with the necessary write privileges
Press any key to continue . . .
:) if it's not one thing it's another ....
So, tried under a standard admin cmd box again and it nearly worked.
Detected 64 bit system...
Visual Studio 2015 environment detected...
Error: Failed to get location of msbuild
Press any key to continue . . .
FFS.
Myrsloik
8th October 2017, 14:18
Admin vs2017 prompt obviously
hydra3333
8th October 2017, 15:19
OK thank you, looked for that and it worked.
For posterity and other under-educated people like me who do this rarely, a quick web searched indicated this was how to do it.
"To use this script simply run 'install_script.bat' from a VS2017 elevated command prompt."
In Windows 10
Open the Start menu, by pressing the Windows logo key Windows logo on your keyboard for example.
On the Start menu, enter dev.
This will bring a list of installed apps that match your search pattern.
If you're looking for a different command prompt, try entering a different search term such as prompt.
Choose the Developer Command Prompt (or the command prompt you want to use) and right click and run as admin.
In Windows 8.1
Go to the Start screen, by pressing the Windows logo key Windows logo on your keyboard for example.
On the Start screen, press CTRL + TAB to open the Apps list and then enter V.
This will bring a list that includes all installed Visual Studio command prompts.
Choose the x64 vs2017 Developer Command Prompt (or the command prompt you want to use) and right click and run as admin.
edit 1: no, that only appeared to work but didn't. This did though from inside an admin cmd box
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\BuildCustomizations>copy C:\Users\u\Desktop\Vapoursynth\VSNASM\VSNASM-master\na*.* .\
C:\Users\u\Desktop\Vapoursynth\VSNASM\VSNASM-master\nasm.props
C:\Users\u\Desktop\Vapoursynth\VSNASM\VSNASM-master\nasm.targets
C:\Users\u\Desktop\Vapoursynth\VSNASM\VSNASM-master\nasm.xml
3 file(s) copied.And also remembering to set a system environment variable (right click on "This PC", properties, "environment variables") named NASMPATH equal to the folder (with trailing slash) where you placed the downloaded nasm.exe.
Myrsloik
8th October 2017, 15:21
This is something you have to tell the vsnasm people about. I don't write their installation instructions
hydra3333
8th October 2017, 15:41
This is something you have to tell the vsnasm åeople about. I don't write their installation instructions
Yes, and thank you for the info anyway, it led to a way to get it done !
Boulder
14th October 2017, 12:14
I finally upgraded to R39 from R36 I think. I'm using this kind of a part in my cleanup script to compare the changes in the luma plane between the cleaned video and the original one. With R39, I'm only getting a black screen for the frame showing the differences. What am I doing wrong? I couldn't find anything in the "possibly breaking" parts.
planes = [0]
expr = ('{median} x + y -').format(median=1<<(src.format.bits_per_sample-1))
expr = [(i in planes) * expr for i in range(1)]
result = core.std.Expr([src, finalclip], expr)
result = core.std.Levels(result, min_in=127, max_in=132,min_out=0, max_out=255, planes=0)
finalclip = core.std.Interleave(clips=[finalclip, result])
gonca
16th October 2017, 23:44
I already support all the avs+ formats. This is something else. I also have no intention of paying (I mean compulsory donation hahahahaha) to debug this. Or buying an nvidia graphics card for that matter.
Let the butthurt commence!
code in avisynth_compat.cpp
static void VS_CC avisynthFilterInit(VSMap *in, VSMap *out, void **instanceData, VSNode *node, VSCore *core, const VSAPI *vsapi) {
WrappedClip *clip = (WrappedClip *) * instanceData;
if (!clip->preFetchClips.empty())
clip->fakeEnv->uglyNode = clip->preFetchClips.front();
const VideoInfo &viAvs = clip->clip->GetVideoInfo();
::VSVideoInfo vi;
vi.height = viAvs.height;
vi.width = viAvs.width;
vi.numFrames = viAvs.num_frames;
vi.fpsNum = viAvs.fps_numerator;
vi.fpsDen = viAvs.fps_denominator;
vs_normalizeRational(&vi.fpsNum, &vi.fpsDen);
if (viAvs.IsYV12())
vi.format = vsapi->getFormatPreset(pfYUV420P8, core);
else if (viAvs.IsYV24())
vi.format = vsapi->getFormatPreset(pfYUV444P8, core);
else if (viAvs.IsYV16())
vi.format = vsapi->getFormatPreset(pfYUV422P8, core);
else if (viAvs.IsYV411())
vi.format = vsapi->getFormatPreset(pfYUV411P8, core);
else if (viAvs.IsColorSpace(VideoInfo::CS_YUV9))
vi.format = vsapi->getFormatPreset(pfYUV410P8, core);
else if (viAvs.IsY8())
vi.format = vsapi->getFormatPreset(pfGray8, core);
else if (viAvs.IsYUY2())
vi.format = vsapi->getFormatPreset(pfCompatYUY2, core);
else if (viAvs.IsRGB32())
vi.format = vsapi->getFormatPreset(pfCompatBGR32, core);
else
vsapi->setError(out, "Avisynth Compat: Only YV12, YUY2 and RGB32 supported");
vi.flags = 0;
vsapi->setVideoInfo(&vi, 1, node);
}
add two lines to the if-else
else if (viAvs.IsColorSpace(VideoInfo::CS_YUV420P16))
vi.format = vsapi->getFormatPreset(pfYUV420P16, core);
Myrsloik
17th October 2017, 13:17
code in avisynth_compat.cpp
static void VS_CC avisynthFilterInit(VSMap *in, VSMap *out, void **instanceData, VSNode *node, VSCore *core, const VSAPI *vsapi) {
WrappedClip *clip = (WrappedClip *) * instanceData;
if (!clip->preFetchClips.empty())
clip->fakeEnv->uglyNode = clip->preFetchClips.front();
const VideoInfo &viAvs = clip->clip->GetVideoInfo();
::VSVideoInfo vi;
vi.height = viAvs.height;
vi.width = viAvs.width;
vi.numFrames = viAvs.num_frames;
vi.fpsNum = viAvs.fps_numerator;
vi.fpsDen = viAvs.fps_denominator;
vs_normalizeRational(&vi.fpsNum, &vi.fpsDen);
if (viAvs.IsYV12())
vi.format = vsapi->getFormatPreset(pfYUV420P8, core);
else if (viAvs.IsYV24())
vi.format = vsapi->getFormatPreset(pfYUV444P8, core);
else if (viAvs.IsYV16())
vi.format = vsapi->getFormatPreset(pfYUV422P8, core);
else if (viAvs.IsYV411())
vi.format = vsapi->getFormatPreset(pfYUV411P8, core);
else if (viAvs.IsColorSpace(VideoInfo::CS_YUV9))
vi.format = vsapi->getFormatPreset(pfYUV410P8, core);
else if (viAvs.IsY8())
vi.format = vsapi->getFormatPreset(pfGray8, core);
else if (viAvs.IsYUY2())
vi.format = vsapi->getFormatPreset(pfCompatYUY2, core);
else if (viAvs.IsRGB32())
vi.format = vsapi->getFormatPreset(pfCompatBGR32, core);
else
vsapi->setError(out, "Avisynth Compat: Only YV12, YUY2 and RGB32 supported");
vi.flags = 0;
vsapi->setVideoInfo(&vi, 1, node);
}
add two lines to the if-else
else if (viAvs.IsColorSpace(VideoInfo::CS_YUV420P16))
vi.format = vsapi->getFormatPreset(pfYUV420P16, core);
I meant avs 2.6 since avs+ keeps changing the api. Screw that.
TheFluff
18th October 2017, 09:47
Last time an implementation of the Avs+-specific high bitdepth stuff was attempted, the VideoInfo API in Avs+ was kinda immature. See here (https://forum.doom9.org/showthread.php?p=1782135#post1782135) and the following posts. I think the suggestions were merged into pinterf's avs+ but it's been mucked around with again after that and I think there are still some outstanding weird edge cases and other oddities. Hence VS pretends to be vanilla 2.6 when loading plugins.
Myrsloik
18th October 2017, 10:33
The reason I confused myself is that I added avs+ support to avfs. That was a bit of a mistake due to its extreme pre-alpha state. And can you even name a single avisynth plugin that doesn't already have a port you need it for? I can't think of any...
videoh
18th October 2017, 12:45
Here are some changes I made to AvsCompat to support CS_YUV420P16 from an Avisynth+ filter.
http://rationalqm.us/misc/Vapoursynth Usage.zip
hydra3333
18th October 2017, 14:50
+1 :)
Myrsloik
18th October 2017, 19:44
Since the avs+ api is apparently quite stable now (nobody seems to have stated this before I asked) I'll put proper support on my todo list. Your hack is rejected since it causes a pile of interesting issues because no plugin ever handles a partial avs+ feature level properly.
2.5 compatibility may or may not disappear (it's exclusive to 32bit anyway) to make the process simpler.
Myrsloik
19th October 2017, 10:46
I finally upgraded to R39 from R36 I think. I'm using this kind of a part in my cleanup script to compare the changes in the luma plane between the cleaned video and the original one. With R39, I'm only getting a black screen for the frame showing the differences. What am I doing wrong? I couldn't find anything in the "possibly breaking" parts.
planes = [0]
expr = ('{median} x + y -').format(median=1<<(src.format.bits_per_sample-1))
expr = [(i in planes) * expr for i in range(1)]
result = core.std.Expr([src, finalclip], expr)
result = core.std.Levels(result, min_in=127, max_in=132,min_out=0, max_out=255, planes=0)
finalclip = core.std.Interleave(clips=[finalclip, result])
Definitely an unintended change. Will fix.
pinterf
19th October 2017, 13:41
A question:
In the Expr filter source a load-type enum appears instead of a store-type. Is it a typo? It perhaps does not matter because the condition is never true, just asking.
See here: https://github.com/vapoursynth/vapoursynth/blob/master/src/core/exprfilter.cpp#L799
And a comment for Expr filter documentation: the maximum number of clips is 26 instead of 3.
Now it says: "Expr evaluates an expression per pixel for up to 3 input *clips*."
Myrsloik
19th October 2017, 13:51
A question:
In the Expr filter source a load-type enum appears instead of a store-type. Is it a typo? It perhaps does not matter because the condition is never true, just asking.
See here: https://github.com/vapoursynth/vapoursynth/blob/master/src/core/exprfilter.cpp#L799
And a comment for Expr filter documentation: the maximum number of clips is 26 instead of 3.
Now it says: "Expr evaluates an expression per pixel for up to 3 input *clips*."
That code should never be reached and is probably just a leftover. It's possible some path passes a null vi but throws an error later and this makes the check easier.
Myrsloik
22nd October 2017, 22:56
Proper avs+ support is mostly finished, expect test builds in a day or two. The only removed feature is mvtools compatibility since that hack was exceptionally ugly and a superior native version exists.
hydra3333
23rd October 2017, 12:47
Proper avs+ support is mostly finished, expect test builds in a day or two. Thank you.
Boulder
23rd October 2017, 12:51
The Vapoursynth version of QTGMC (in havsfunc) works with the VS-native MVTools. Both have their own sticky threads in this forum section.
Myrsloik
23rd October 2017, 21:57
R40-test1 (https://www.dropbox.com/s/jrwvxu3caq3tc2b/VapourSynth-R40-test1.exe?dl=1)
It should be release quality so if you reported one of the issues go test it.
Changes:
r40:
fixed rgb output sometimes being flipped in avisource
added alpha output settings to avisource, the default is no alpha output
fixed gamma being infinite if not set in levels, bug introduced in r39
removed the hack needed to support avisynth mvtools, the native mvtools has been superior for several years now and removing the hack makes avisynth filter creation much faster
added avisynth+ compatibility
only do prefetching in avfs with vs script when linear access is detected, fixes excessive prefetching that could make opening scripts very slow
ChaosKing
24th October 2017, 09:56
Why is there a restart computer option at the end of the installer? Is it really necessary? Bad User Experience :D
Myrsloik
24th October 2017, 10:11
Why is there a restart computer option at the end of the installer? Is it really necessary? Bad User Experience :D
Because a file was in use when you installed. Bad User.
feisty2
24th October 2017, 16:23
I wanna slice all images in a folder into small patches to train my neural net
I'm currently doing
import vapoursynth as vs
import os
core = vs.get_core()
def load(addr):
clp = core.imwrif.Read(addr)
clp = core.fmtc.matrix(clp, "709", fulls=True, fulld=True)
clp = core.std.ShufflePlanes(clp, 0, vs.GRAY)
clp = core.fmtc.resample(clp, clp.width//2, clp.height//2, kernel="cubic", a1=-0.5, a2=0, fulls=True, fulld=True)
clp = core.std.CropAbs(clp, 159, 159, (clp.width-159)//2+100, (clp.height-159)//2-50)
return clp
clps = []
addrs = os.listdir("img/")
for x in addrs:
clps += [load("img/"+x)]
clp = clps.pop(0)
for x in clps:
clp += x
clp.set_output()
but this simple operation takes TREMENDOUS amount of ram, I'm talking like ~20GB and also runs pretty slow (~2fps)....
something aint right,,,, how do I fix it?
Myrsloik
24th October 2017, 17:18
You've hit one of the edge cases. Each imwri instance caches the last output frame so by doing what you're doing it will have an insane memory usage.
You shouldn't even do it that way. Simply pass a list of all the filenames to one instance and set mismatch=true. Put your cropabs trick after. Probably done and running at reasonable speed after it.
DJATOM
24th October 2017, 19:42
Is there any TCPDeliver-like alternative for VapourSynth?
Myrsloik
24th October 2017, 19:47
Is there any TCPDeliver-like alternative for VapourSynth?
No, why would you even need that in <current year>?
We've got piles of cores locally...
DJATOM
24th October 2017, 20:07
Just wanted encode (or split filtering chain) using 2 PCs (that should speed things up).
Myrsloik
24th October 2017, 20:32
Just wanted encode (or split filtering chain) using 2 PCs (that should speed things up).
Did you try using the avisynth plugin? It may even work
DJATOM
25th October 2017, 16:59
It doesn't work. Host application just crashing on connection attempt.
Myrsloik
25th October 2017, 18:55
It doesn't work. Host application just crashing on connection attempt.
Here's another idea I don't even know if it works. Mount a script with avfs and then open that file over the network on the second computer.
Then report your findings...
DJATOM
26th October 2017, 14:22
Well, not a top priority, I will try it later.
djb01
29th October 2017, 08:52
Recently updated to r39 and I'm trying to figure out why my vspipe output is now lacking so much information.
https://i.imgur.com/vbwIfll.png
This is with vspipe.exe test.vpy - --y4m --progress | x264_x64_10bit_2851.exe --demuxer y4m -o out.mkv -
(The x264 binary is 2851 tmod, but I also tried kmod)
It used to have % complete, eta, estimated size, bitrate (you can see in the above image it says kb/s but doesn't actually show the bitrate -- well, it flickers between fps and bitrate but it's so fast you can't see it), and would update after every frame. I don't have this problem when using avisynth/avs4x26x-x64, so I think vspipe must be the cause, right? Is it possible to get the "old" style of progress output back?
Myrsloik
29th October 2017, 09:24
. I don't have this problem when using avisynth/avs4x26x-x64, so I think vspipe must be the cause, right? Is it possible to get the "old" style of progress output back?
Vspipe never had that information to begin with. It's most likely an x264 change.
djb01
29th October 2017, 10:08
It's most likely an x264 change.
Hmm. Well, this is weird. Turns out I needed to hardcode a --frames length for the progress to show correctly when using vspipe.
DJATOM
29th October 2017, 10:29
Recently updated to r39 and I'm trying to figure out why my vspipe output is now lacking so much information.
https://i.imgur.com/vbwIfll.png
This is with vspipe.exe test.vpy - --y4m --progress | x264_x64_10bit_2851.exe --demuxer y4m -o out.mkv -
(The x264 binary is 2851 tmod, but I also tried kmod)
It used to have % complete, eta, estimated size, bitrate (you can see in the above image it says kb/s but doesn't actually show the bitrate -- well, it flickers between fps and bitrate but it's so fast you can't see it), and would update after every frame. I don't have this problem when using avisynth/avs4x26x-x64, so I think vspipe must be the cause, right? Is it possible to get the "old" style of progress output back?
You can apply my XLENGTH support patch and recompile x264 on your own: https://pastebin.com/sZLD6vyg
Myrsloik
29th October 2017, 11:35
It'd be great if you could verify if the avs+ compatibility works and if the other fixed issues really are fixed.
Boulder
29th October 2017, 12:41
It'd be great if you could verify if the avs+ compatibility works and if the other fixed issues really are fixed.Sorry, forgot to test "fixed gamma being infinite if not set in levels, bug introduced in r39". I assume that's for my issue.
With an 8-bit video, it works, with 16-bit video it doesn't (still a black frame output).
Myrsloik
29th October 2017, 16:30
Sorry, forgot to test "fixed gamma being infinite if not set in levels, bug introduced in r39". I assume that's for my issue.
With an 8-bit video, it works, with 16-bit video it doesn't (still a black frame output).
I tried it again and it works here. Are you certain you didn't just forget to scale min/max_in or something?
Boulder
29th October 2017, 16:54
I tried it again and it works here. Are you certain you didn't just forget to scale min/max_in or something?
Ah, now I got it. Was it automatically scaled in the earlier versions? So for 16-bit video the comparison part should be like this:
clp = whatever_clip_thats_16bit_video
finalclip = core.rgvs.RemoveGrain(clp, mode=17)
planes = [0]
expr = ('{median} x + y -').format(median=1<<(clp.format.bits_per_sample-1))
expr = [(i in planes) * expr for i in range(1)]
result = core.std.Expr([clp, finalclip], expr)
result = core.std.Levels(result, min_in=127*256, max_in=132*256, min_out=0*256, max_out=255*256, planes=0)
finalclip = core.std.Interleave(clips=[finalclip, result])
Myrsloik
29th October 2017, 17:01
Ah, now I got it. Was it automatically scaled in the earlier versions? So for 16-bit video the comparison part should be like this:
clp = whatever_clip_thats_16bit_video
finalclip = core.rgvs.RemoveGrain(clp, mode=17)
planes = [0]
expr = ('{median} x + y -').format(median=1<<(clp.format.bits_per_sample-1))
expr = [(i in planes) * expr for i in range(1)]
result = core.std.Expr([clp, finalclip], expr)
result = core.std.Levels(result, min_in=127*256, max_in=132*256, min_out=0*256, max_out=255*256, planes=0)
finalclip = core.std.Interleave(clips=[finalclip, result])
No, it was never scaled at all. I don't do that in any of my VS stuff, especially not where you may want to have exact values.
Boulder
29th October 2017, 17:07
So how was it working properly despite me not scaling it? Sorry, I'm not entirely aware where the actual problem was, and I'm not entirely sure if I ran R36 or R37 earlier. Nevertheless, it's working fine now after the scaling is added to the values.
Myrsloik
29th October 2017, 17:37
Now I just need someone to test to see if the DG stuff works.
Btw, avisource in test1 has a regression that makes raw 24 and 32bit rgb avi files flipped. It does however no longer flip files that decode to raw rgb. This will be corrected in the next version so no need to report it.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.