Log in

View Full Version : Vapoursynth


Pages : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 [95] 96 97 98 99 100

ChaosKing
27th April 2022, 21:28
You could also try to set a high max_cache_size and see if it helps http://www.vapoursynth.com/doc/pythonreference.html?#Core.max_cache_size

Selur
6th May 2022, 13:44
Can someone compile https://github.com/Setsugennoao/VapourSynth-removedirt for Win 64bit?
I'd like to know whether the fixes and changes Setsugennoa made to the source fix the crashes I encountered (https://forum.doom9.org/showthread.php?p=1964324#post1964324).

kedautinh12
6th May 2022, 13:57
So simple if you ask author :D

Selur
6th May 2022, 14:31
no issue tracker -> no clue how to contact the author :)

kedautinh12
6th May 2022, 14:47
Ask in another issues tab project and say sorry cause don't have issues tab in removedirt :D
https://github.com/Setsugennoao/vs-parsedvd/issues

Selur
6th May 2022, 16:56
Got in touch with Setsugennoao, sadly his build also crashed the same way :( as https://github.com/handaimaoh/removedirtvs and https://github.com/pinterf/removedirtvs do.

stax76
25th May 2022, 16:19
A guide showing how to use VapourSynth in mpv.net:

https://github.com/stax76/mpv.net/wiki/Using-VapourSynth-in-mpv.net

stax76
25th May 2022, 16:19
A guide showing how to use VapourSynth in mpv.net:

https://github.com/stax76/mpv.net/wiki/Using-VapourSynth-in-mpv.net

Myrsloik
25th May 2022, 19:07
https://github.com/vapoursynth/vapoursynth/releases/tag/R59-RC1 (R59-RC1)
r59:
fixed several convolution crashes
fixed averageframes weights with float input
fixed rare cython memory leak on error

Selur
26th May 2022, 15:10
Thanks. (still hoping an option to disable 'auto loading' will come some time)

Myrsloik
5th June 2022, 11:50
R59 is out (https://github.com/vapoursynth/vapoursynth/releases/tag/R59)

Pure bug fix release.

ChaosKing
16th June 2022, 07:00
The link “Plugins and Scripts“ is still linked to the old page (which does not exist anymore) on vapoursynth.com

Yomiko
21st June 2022, 14:17
Any chance for an official audio visualization plugin?

Selur
25th June 2022, 07:10
How would one port Avisynth: "mt_expand(y=3,u=-128,v=-128)" to Vapoursynth using core.std.Maximum ?

Greenhorn
25th June 2022, 19:26
How would one port Avisynth: "mt_expand(y=3,u=-128,v=-128)" to Vapoursynth using core.std.Maximum ?

If I read that correctly, that call just processes the y plane normally and sets u and v to 128. (According to http://avisynth.nl/index.php/MaskTools2/mt_expand)

So I think you could do:

y, u, v = your_clip.std.SplitPlanes()
y = y.std.Maximum()
u = core.std.BlankClip(u, color=128)
v = core.std.BlankClip(v, color=128)
your_choice_of_name = core.std.ShufflePlanes([y,u,v], [0,0,0], vs.YUV)

Does that work? (If your clip isn't actually 8bpc, I suppose you'll need to scale 128 to an appropriate value with either simple algebra or one of the various helper functions out there.)

Selur
25th June 2022, 20:50
I get:
ry, ru, rv = core.std.SplitPlanes(rainbow)
ValueError: too many values to unpack (expected 3))

Here's where I use this:
from vapoursynth import core
import vapoursynth as vs

# requires:
# * BiFrost: https://github.com/dubhater/vapoursynth-bifrost
# * TemporalSoften: https://github.com/dubhater/vapoursynth-temporalsoften
# I think this could be replaced by TemporalSoften2 https://github.com/dubhater/vapoursynth-temporalsoften2

# raidus = temporal radius
# th = threshold
def ChubbyRain2(clip: vs.VideoNode, th: int= 0, radius: int=3, show: bool=False, interlaced: bool=False):
if interlaced:
es = core.std.SeparateFields(clip=clip)
else:
res = clip

y = core.std.ShufflePlanes(res, planes=0, colorfamily=vs.GRAY)
u = core.std.ShufflePlanes(res, planes=1, colorfamily=vs.GRAY)
v = core.std.ShufflePlanes(res, planes=2, colorfamily=vs.GRAY)

uc = core.std.Convolution(u, [1,-2,1], mode = "v")
vc = core.std.Convolution(v, [1,-2,1], mode = "v")


ucc = core.std.Convolution(u, [1,2,1], planes=0, mode = "v")
vcc = core.std.Convolution(v, [1,2,1], planes=0, mode = "v")

cc = core.std.ShufflePlanes([y,ucc,vcc], planes=[0, 0, 0], colorfamily=vs.YUV)
cc = core.bifrost.Bifrost(cc)
cc = core.focus.TemporalSoften(cc, radius=radius,luma_threshold=0, chroma_threshold=255,scenechange=2 , mode=2)

expr = "x y + " + str(th) + " > " + str(256 << (clip.format.bits_per_sample - 8)) + " 0 ?"
rainbow = core.std.Expr([uc,vc],expr)
rainbow = core.resize.Point(rainbow, res.width, res.height)

ry, ru, rv = core.std.SplitPlanes(rainbow)
ry = std.Maximum(ry)
ru = core.std.BlankClip(ru, color=128 << (clip.format.bits_per_sample - 8))
rv = core.std.BlankClip(rv, color=128 << (clip.format.bits_per_sample - 8) )
rainbow = core.std.ShufflePlanes([ry,ru,rv], [0,0,0], vs.YUV)

resfinal = core.std.MaskedMerge(res, cc, rainbow)

if show:
output = rainbow
else:
if interlaced:
output = core.std.DoubleWeave(resfinal)
output = core.std.SelectEvery(output, 2, 0)
else:
output = resfinal

return output
Original AviSynth version: http://avisynth.nl/images/ChubbyRain2.avsi

mastrboy
25th June 2022, 22:28
While I don't have a solution to your current issue, are you not missing the cnr2() function call? (http://avisynth.nl/index.php/Cnr2)

I doubt it would function the same without it?

Selur
26th June 2022, 05:13
@mastrboy: yes, you are right I missed the cnr2 call.

---
Okay, I see why the ValueError happens rainbow is Gray8

def ChubbyRain2(clip: vs.VideoNode, th: int=10, radius: int=3, show: bool=False, sft: int=10, interlaced: bool=False):
if interlaced:
res = core.std.SeparateFields(clip=clip)
else:
res = clip

y = core.std.ShufflePlanes(res, planes=0, colorfamily=vs.GRAY)
u = core.std.ShufflePlanes(res, planes=1, colorfamily=vs.GRAY)
v = core.std.ShufflePlanes(res, planes=2, colorfamily=vs.GRAY)

uc = core.std.Convolution(u, [1,-2,1], mode = "v")
vc = core.std.Convolution(v, [1,-2,1], mode = "v")


ucc = core.std.Convolution(u, [1,2,1], planes=0, mode = "v")
vcc = core.std.Convolution(v, [1,2,1], planes=0, mode = "v")

cc = core.std.ShufflePlanes([y,ucc,vcc], planes=[0, 0, 0], colorfamily=vs.YUV)
cc = core.bifrost.Bifrost(cc)
cc = core.cnr2.Cnr2(cc)
cc = core.focus.TemporalSoften(cc, radius=radius, luma_threshold=0, chroma_threshold=sft, scenechange=2 , mode=2)
#cc = core.focus2.TemporalSoften2(cc, radius=radius, luma_threshold=0, chroma_threshold=sft, scenechange=2 , mode=2)

shift = (clip.format.bits_per_sample - 8)
expr = "x y + " + str(th) + " > " + str(256 << shift) + " 0 ?"
rainbowMask = core.std.Expr([uc,vc],expr)
rainbowMask = core.resize.Point(rainbowMask, res.width, res.height)
rainbowMask = core.std.Maximum(rainbowMask)

resfinal = core.std.MaskedMerge(res, cc, rainbowMask)

if show:
output = rainbowMask
else:
if interlaced:
output = core.std.DoubleWeave(resfinal)
output = core.std.SelectEvery(output, 2, 0)
else:
output = resfinal

return output

doesn't crash, but the output is kind of broken. :/ doh "th: int=0" -> "th: int=10"

ChaosKing
26th June 2022, 06:57
es = core.std.SeparateFields(clip=clip) should be res = ...

Selur
26th June 2022, 07:02
thanks, fixed.

Selur
30th June 2022, 19:30
btw. does someone know an alternative to ExBlend for Vapoursynth, something that tries to fix blends and not 'just' try to drop the fields like sRestore, Cdeblend?

Julek
30th June 2022, 23:08
btw. does someone know an alternative to ExBlend for Vapoursynth, something that tries to fix blends and not 'just' try to drop the fields like sRestore, Cdeblend?

https://github.com/dnjulek/jvsfunc/blob/main/jvsfunc/deblend.py#L16-L40

Selur
1st July 2022, 15:45
Will try thanks. :)(sadly unlike exblend in Avisynth it doesn't seem to do anything for the clip, see exblend thread)

ChaosKing
3rd July 2022, 21:25
Will there be a binary for the R2 imwri release?

Myrsloik
4th July 2022, 15:26
Will there be a binary for the R2 imwri release?

Done. Forgot to check back for the artifacts to grab binaries.

Selur
7th July 2022, 17:20
Using BlankClip (http://www.vapoursynth.com/doc/functions/video/blankclip.html) there is a color parameter,
float[] color=<black>
is there some documentation about this? What range are these floats? I guess one should use three or four, right? Is the color selection etc. dependend of the used color space (type, sampling, bit depth)?

Myrsloik
7th July 2022, 17:43
Using BlankClip (http://www.vapoursynth.com/doc/functions/video/blankclip.html) there is a color parameter,
float[] color=<black>
is there some documentation about this? What range are these floats? I guess one should use three or four, right? Is the color selection etc. dependend of the used color space (type, sampling, bit depth)?

They are 1:1 copied into the destination clip (rounded for int formats of obviously). Out of range values for the format throws an error. Number of planes values expected.

Selur
7th July 2022, 18:07
Okay,.. so the best way if I got a rgb(50,205,50) color coding would be to first create a RGB24 clip with my values and then use for example:
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="470bg", range_s="limited")
to convert to YUV420P8 if that is the color space I need, right?

Myrsloik
7th July 2022, 18:20
Okay,.. so the best way if I got a rgb(50,205,50) color coding would be to first create a RGB24 clip with my values and then use for example:
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="470bg", range_s="limited")
to convert to YUV420P8 if that is the color space I need, right?

Yes. That's the easiest way.

Selur
7th July 2022, 18:21
Okay, thanks. :)

Selur
7th July 2022, 18:52
Using:
# Imports
import vapoursynth as vs
import os
import sys
# getting Vapoursynth core
core = vs.core
# Import scripts folder
scriptPath = 'i:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# Import scripts
import havsfunc
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/files/test.avi",cachefile="E:/Temp/avi_6c441f37d9750b62d59f16ecdbd59393_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# Setting color matrix to 470bg.
clip = core.std.SetFrameProps(clip, _Matrix=5)
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
## Starting left=60, top=60, right=50, bottom=50
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P8, range_s="limited") # convert clip to 4:4:4 to allow uneven positions
clipVline = core.std.BlankClip(clip=clip, width=1, format=vs.RGB24, color=[50,205,5]) # set color of vertical line
clipHline = core.std.BlankClip(clip=clip, height=1,format=vs.RGB24, color=[50,205,5]) # set color of horizontal line
clipVline = core.resize.Bicubic(clip=clipVline, format=vs.YUV444P8, matrix_s="470bg", range_s="limited") # change color to that of clip
clipHline = core.resize.Bicubic(clip=clipHline, format=vs.YUV444P8, matrix_s="470bg", range_s="limited") # change color to that of clip
#overlay vertical lines
clip = havsfunc.Overlay(base=clip, overlay=clipVline, x=60)
clip = havsfunc.Overlay(base=clip, overlay=clipVline, x=clip.width-50)
clip = havsfunc.Overlay(base=clip, overlay=clipHline, y=60)
#overlay horizontal lines
clip = havsfunc.Overlay(base=clip, overlay=clipHline, y=clip.height-50)
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, range_s="limited")
## Finished

# set output frame rate to 25fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
I basically get what I expected, but something seems to be amiss, since I see some pinkg lines
https://i.ibb.co/ChQh1PX/pink.png (https://ibb.co/f4H41DK)
that should not be there,...
https://i.ibb.co/CQSzxSC/pink-zoomed.png (https://ibb.co/RcJ9LJr)
any idea where I go wrong?
Did I do something wrong or this a bug in overlay or somewhere else? (it's not much of an issue for my use case here, but seem to be wrong)

Cu Selur

Ps.: In case it's helps, I got the source clip I used in my google drive (https://drive.google.com/file/d/1xchtRU6uZyLm9xJWh4HgNxDrSqC70zhl/view?usp=sharing).

Julek
7th July 2022, 20:02
Using:
any idea where I go wrong?
Did I do something wrong or this a bug in overlay or somewhere else? (it's not much of an issue for my use case here, but seem to be wrong)

Cu Selur

Ps.: In case it's helps, I got the source clip I used in my google drive (https://drive.google.com/file/d/1xchtRU6uZyLm9xJWh4HgNxDrSqC70zhl/view?usp=sharing).
It's just chroma subsampling effect.

MonoS
7th July 2022, 20:10
Did I do something wrong or this a bug in overlay or somewhere else? (it's not much of an issue for my use case here, but seem to be wrong)

Cu Selur

That's an artifact from doing chroma subsampling, 4:2:0 (YUV420Px) has a 1/4 resolution for chroma and using a bicubic kernel (which use some negative lobe IIRC) generate that purple line (if you invert your green to [155,50,250] you will in fact generate a faint green line), if you use a kernel without negative lobes such a bilinear one you can avoid that kind of artifact, but introducing a strong chroma contrast line like that i a subsampled pic will always introduce some artifact, leave in in 444 subsampling (or RGB) and you will avoid that.

Selur
8th July 2022, 17:22
Okay, thanks for clearing that. :)

lansing
20th July 2022, 03:16
I have a problem with the R59 installer. I have both Python 3.8 and 3.9 installed with 3.9 being the default. But the installer is only able to detect 3.8. I tested R57 and it is able to see both python versions.

Julek
20th July 2022, 03:57
I have a problem with the R59 installer. I have both Python 3.8 and 3.9 installed with 3.9 being the default. But the installer is only able to detect 3.8. I tested R57 and it is able to see both python versions.

Since R58 VS supports only 3.8 OR 3.10.
3.8 is still kept because it is the latest version available for windows 7.

More info: https://github.com/vapoursynth/vapoursynth/issues/858

lansing
20th July 2022, 17:59
Since R58 VS supports only 3.8 OR 3.10.
3.8 is still kept because it is the latest version available for windows 7.

More info: https://github.com/vapoursynth/vapoursynth/issues/858

The documentation should be updated, as it is still stating 3.9 to be the supported version.

http://www.vapoursynth.com/doc/installation.html#windows-installation

Julek
20th July 2022, 19:56
The documentation should be updated, as it is still stating 3.9 to be the supported version.

http://www.vapoursynth.com/doc/installation.html#windows-installation

Yes, the site usually takes longer to update, even though it is already updated on GitHub (https://github.com/vapoursynth/vapoursynth/blob/master/doc/installation.rst#prerequisites).

Myrsloik
3rd August 2022, 18:29
R60 RC1 (https://github.com/vapoursynth/vapoursynth/releases/tag/R60-RC1)

r60:
fixed blankclip crashing when fpsnum or fpsden is 0 despite it being allowed
fixed invalid format ids sometimes being treated as api3 values when passed to resize
fixed error message frame generation in vfw
fixed writing beyond end out output buffer for audio in vfw
blankaudio now takes an array of channel constants since this better matches how most other functions work
fixed splitchannels crash on certain channel configurations (YomikoR)
added makefulldiff and mergefulldiff, these are versions of makediff and mergediff that don't clamp the difference to half range and instead use a higher precision diff clip
better error messages when filters get unsupported input formats or combinations thereof
freezeframes now accepts empty arrays and simply passes through the source clip
you can directly assign to frame-props
removed all deprecated (and replaced by better versions) functions in python: get_frame_async_raw, get_plugins, get_functions, list_functions, get_format, register_format
fixed convolution output for 9-15 bit material

Note that MakeFullDiff and MergeFullDiff are experimental functions that may be killed off if nobody does fun things with them. That's all.

Greenhorn
3rd August 2022, 23:02
What's the difference between Make/MergeDiff and Make/MergeFullDiff when using float format? Was that also clamped?

Myrsloik
4th August 2022, 11:58
What's the difference between Make/MergeDiff and Make/MergeFullDiff when using float format? Was that also clamped?

It's the same for float.

mastrboy
7th August 2022, 19:16
ColorYUV std.Lut/std.Expr Do the adjustment yourself
https://github.com/amichaelt/vapoursynth/blob/master/doc/avisynthcomp.rst

Honestly, this is just too complicated to figure out for me, is there any helper functions available for this?

I tried to understand the code here: https://github.com/AviSynth/AviSynthPlus/blob/master/avs_core/filters/color.cpp

But can not figure out how the Lut/expression for off_v is built from those functions...

I'm just trying to do the avisynth equivalent to "coloryuv(off_v=0.5)"

Myrsloik
7th August 2022, 20:22
Honestly, this is just too complicated to figure out for me, is there any helper functions available for this?

I tried to understand the code here: https://github.com/AviSynth/AviSynthPlus/blob/master/avs_core/filters/color.cpp

But can not figure out how the Lut/expression for off_v is built from those functions...

I'm just trying to do the avisynth equivalent to "coloryuv(off_v=0.5)"

Add .5 to the third plane of a float format?

Expr(clip, ["", "", "x 0.5 +"])

mastrboy
7th August 2022, 21:29
Add .5 to the third plane of a float format?

Expr(clip, ["", "", "x 0.5 +"])

Thanks, that works... I have a difficult time properly understanding lut/expr, is there any decent documentation freely available that is recommended for beginners that want to learn?

That only works for 8bit though, I guess ColorYUV scales input values internally... So what is the math to convert 8bit Expr to 16bit?

Edit: nevermind, found a helper function for scaling values between bitdepths: https://github.com/Irrational-Encoding-Wizardry/vsutil/blob/master/vsutil/info.py#L129

Selur
15th September 2022, 15:19
R60 is released. :)

fixed blankclip crashing when fpsnum or fpsden is 0 despite it being allowed
fixed invalid format ids sometimes being treated as api3 values when passed to resize
fixed error message frame generation in vfw
fixed writing beyond end out output buffer for audio in vfw
blankaudio now takes an array of channel constants since this better matches how most other functions work
fixed splitchannels crash on certain channel configurations (YomikoR)
added makefulldiff and mergefulldiff, these are versions of makediff and mergediff that don't clamp the difference to half range and instead use a higher precision diff clip
better error messages when filters get unsupported input formats or combinations thereof
freezeframes now accepts empty arrays and simply passes through the source clip
you can directly assign to frame-props
removed all deprecated (and replaced by better versions) functions in python: get_frame_async_raw, get_plugins, get_functions, list_functions, get_format, register_format
fixed convolution output for 9-15 bit material
source: https://github.com/vapoursynth/vapoursynth/releases

Thanks!

Cu Selur

Yomiko
18th September 2022, 11:16
Is there a way (with API4) to tell if a clip has "valid" variable format?

Myrsloik
18th September 2022, 12:26
Is there a way (with API4) to tell if a clip has "valid" variable format?

What do you mean by "valid"? If you get an input clip that's variable format it'll always be valid. If a filter returns a frame that doesn't fit the description things will error out.

Yomiko
18th September 2022, 15:09
I was thinking about the recently fixed resize issue, where a clip with "dynamic" format might be mistakenly made. Although previewers actually can handle such output nodes, I hope users can be well informed.

Yomiko
29th September 2022, 12:48
In the C headers of API 3, VideoFormat is provided as a pointer in VSVideoInfo, effectively preventing me from creating a var format clip in a filter. Since API 4 it has been changed in the C header, but in python it remains to be None when the clip format is variable. Do you have any plan to also change in python?

Myrsloik
1st October 2022, 18:29
In the C headers of API 3, VideoFormat is provided as a pointer in VSVideoInfo, effectively preventing me from creating a var format clip in a filter. Since API 4 it has been changed in the C header, but in python it remains to be None when the clip format is variable. Do you have any plan to also change in python?

Change it to what? I don't understand the question.