Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th May 2020, 14:21   #3841  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
@Txico: you can also do something like:
Code:
# Import scripts folder
scriptPath = '/home/myuser/vapoursynth-scripts'
sys.path.append(os.path.abspath(scriptPath))
to allow "import havsfunc as haf" when the havsfunc.py is inside the '/home/myuser/vapoursynth-scripts' folder.
Note that this will not automatically import the libraries,...

---
@all: are there any Intel® Open Image Denoise filters for Vapoursynth out there?
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 14th May 2020 at 14:26.
Selur is offline   Reply With Quote
Old 16th May 2020, 20:29   #3842  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,795
Lets talk again about this problem here https://forum.doom9.org/showthread.p...96#post1840996

I'm now very sure that this problem is in some way connected to FrameEval()

Problem: Functions with a high temporal radius (called by frameEval) produces different results then without FrameEval


I don't think that all 4 plugins are storing temporal state incorrectly.

Example script:
Code:
import functools
import vapoursynth as vs
import mvsfunc as mvf #https://github.com/HomeOfVapourSynthEvolution/mvsfunc/blob/master/mvsfunc.py

core = vs.get_core()

def comp(a, b, crop=0):
	return core.std.StackHorizontal([
		core.std.CropRel(a, crop,crop,0,0), \
		core.std.CropRel(b, crop,crop,0,0), \
		])
		

# Goal here is to remove dynamic grain and replace it with similar static grain
def ReGrainDenoise(clip):
	# test denoiser 1
	#clip = mvf.Depth(clip, 32)
	#sup = core.mvsf.Super(clip)
	#vec = core.mvsf.Analyze(sup, radius=9, overlap=4)
	#vec = core.mvsf.Recalculate(sup, vec, blksize=4, overlap=2)
	#denoised = core.mvsf.Degrain(clip, sup, vec, thsad=1600)

	# test denoiser 2
	#import havsfunc as haf #https://github.com/HomeOfVapourSynthEvolution/mvsfunc/blob/master/mvsfunc.py
	#clip = mvf.Depth(clip, 16)
	#denoised = haf.SMDegrain(clip, tr=3, thSAD=1500)
	#denoised = denoised.flux.SmoothST( temporal_threshold=16,  spatial_threshold=16)
	#denoised = mvf.Depth(denoised, 32)
	#clip = mvf.Depth(clip, 32)

	# test denoiser 3
	##lip = mvf.Depth(clip, 16)
	#denoised = clip.knlm.KNLMeansCL(d=8, h=6)
	#denoised = mvf.Depth(denoised, 32)
	#clip = mvf.Depth(clip, 32)

	# test "denoiser" 4
	denoised = clip.misc.AverageFrames(weights=[1]*31)[::31].misc.AverageFrames(weights=[1]*31)
	
	# add back static grain
	grain = denoised.grain.Add(var=1200.0, constant=True)
	diff_clip = core.std.Expr([clip, denoised], 'x y - abs').std.Inflate(threshold=200/255).std.Inflate(threshold=200/255)
	mask_clip = diff_clip.std.Binarize(threshold=[3.3/219, 3.3/224], v0=0, v1=80/255)
	clip = core.std.MaskedMerge(clipa=denoised, clipb=grain, mask=mask_clip)
	
	return mvf.Depth(clip, 32)
	
	

clip = core.std.BlankClip(format=vs.YUV420P16, width=120*2, height=80*2, length=100, color=[206,235,135])
clip = mvf.Depth(clip, 32)
clip = clip.grain.Add(var=100.0, constant=False)
orig=clip


def CalledbyFrameEval(n, c):
	return ReGrainDenoise(c)
	
WithFrameEval = clip.std.FrameEval(functools.partial(CalledbyFrameEval, c=clip))
NoFrameEval = ReGrainDenoise(clip)

clip = comp(
		WithFrameEval.text.Text("called from FrameEval").std.AddBorders(right=2), 
		NoFrameEval.text.Text("Without FrameEval").std.AddBorders(right=2), crop=0
		)
clip = comp(clip, orig.text.Text("unfiltered"), crop=0)

clip.set_output()
EDIT: Added AverageFrames() as "denoiser"
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database

Last edited by ChaosKing; 16th May 2020 at 20:36.
ChaosKing is online now   Reply With Quote
Old 18th May 2020, 19:15   #3843  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
I have 2 questions regarding the API

1) what kind of filter outputs multiple clips, and what is the python syntax to bind the outputs of such filter?
is it
Code:
clips = core.???.filter(...)
#clips[0], clips[1], ...
or
Code:
clip1, clip2, ... = core.???.filter(...)
?

2) does audio support break compatibility with the current API? where can I find the audio API?
feisty2 is offline   Reply With Quote
Old 18th May 2020, 20:00   #3844  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by feisty2 View Post
I have 2 questions regarding the API

1) what kind of filter outputs multiple clips, and what is the python syntax to bind the outputs of such filter?
is it
Code:
clips = core.???.filter(...)
#clips[0], clips[1], ...
or
Code:
clip1, clip2, ... = core.???.filter(...)
?

2) does audio support break compatibility with the current API? where can I find the audio API?
1. It returns a list of clips so your first guess is used.
2. Audio support doesn't break the API at all, simply extends it. You can find it in the doodle1 branch. Expect a new test release in a few days when I finish writing and testing a few more simple audio filters.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is online now   Reply With Quote
Old 25th May 2020, 19:34   #3845  |  Link
HuBandiT
Registered User
 
Join Date: Dec 2017
Posts: 12
What is the problem you are trying to solve?

Do you really need FrameEval() for it?

Also, why are you denoising in YUV space? Your result will look blurry.

Last edited by HuBandiT; 25th May 2020 at 19:36.
HuBandiT is offline   Reply With Quote
Old 2nd June 2020, 20:20   #3846  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
why does vspipe freeze then crash if I comment out this line (which assumes the default multithreading mode, fmParallel)?

the default multithreading mode however seems to work with vsedit (preview)

Last edited by feisty2; 2nd June 2020 at 20:25.
feisty2 is offline   Reply With Quote
Old 2nd June 2020, 20:34   #3847  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by feisty2 View Post
why does vspipe freeze then crash if I comment out this line (which assumes the default multithreading mode, fmParallel)?

the default multithreading mode however seems to work with vsedit (preview)
Does this require a C++20 comoiler to test?
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is online now   Reply With Quote
Old 2nd June 2020, 20:42   #3848  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
Quote:
Originally Posted by Myrsloik View Post
Does this require a C++20 comoiler to test?
yes, GCC10 is required to compile this thing, I guess clang10 should also work. However I believe this problem could be reproduced with the C API as well, since I copied this parallel request mode from the core code base.
feisty2 is offline   Reply With Quote
Old 3rd June 2020, 10:41   #3849  |  Link
ortoni
Registered User
 
Join Date: Oct 2010
Location: Auckland, Aotearoa/New Zealand
Posts: 8
Getting an odd compilation error Cython compiling vapoursynth.c during vapoursynth make:
Error compiling Cython file:
------------------------------------------------------------
...
def keys(self):
cdef const VSMap *m = self.funcs.getFramePropsRO(self.constf)
cdef int numkeys = self.funcs.propNumKeys(m)
result = set()
for i in range(numkeys):
set.add(self.funcs.propGetKey(m, i).decode('utf-8'))
^
------------------------------------------------------------

src/cython/vapoursynth.pyx:1095:19: Call with wrong number of arguments (expected 2, got 1)
make: *** [Makefile:2368: src/cython/vapoursynth.c] Error 1

Ubuntu 20.04 on Windows Linux Subsystem, did a pip3 install cython: Successfully installed cython-0.29.19
added /home/<username>/.local/bin to $PATH, all the usual stuff.

Any ideas/ further information needed? I successfully installed on Native Ubuntu 19.10 a while back and updated to 20.04; all still A-OK there.
TIA
ortoni is offline   Reply With Quote
Old 3rd June 2020, 10:52   #3850  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by ortoni View Post
Getting an odd compilation error Cython compiling vapoursynth.c during vapoursynth make:
Error compiling Cython file:
------------------------------------------------------------
...
def keys(self):
cdef const VSMap *m = self.funcs.getFramePropsRO(self.constf)
cdef int numkeys = self.funcs.propNumKeys(m)
result = set()
for i in range(numkeys):
set.add(self.funcs.propGetKey(m, i).decode('utf-8'))
^
------------------------------------------------------------

src/cython/vapoursynth.pyx:1095:19: Call with wrong number of arguments (expected 2, got 1)
make: *** [Makefile:2368: src/cython/vapoursynth.c] Error 1

Ubuntu 20.04 on Windows Linux Subsystem, did a pip3 install cython: Successfully installed cython-0.29.19
added /home/<username>/.local/bin to $PATH, all the usual stuff.

Any ideas/ further information needed? I successfully installed on Native Ubuntu 19.10 a while back and updated to 20.04; all still A-OK there.
TIA
Update to latest master and try again. And specify that it's master you're compiling next time.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is online now   Reply With Quote
Old 4th June 2020, 00:31   #3851  |  Link
ortoni
Registered User
 
Join Date: Oct 2010
Location: Auckland, Aotearoa/New Zealand
Posts: 8
Quote:
Originally Posted by Myrsloik View Post
Update to latest master and try again. And specify that it's master you're compiling next time.
And that did the trick! Thanks for this - and thanks for the all-around majorly awesome VapourSynth project. You, Sir, are a scholar and a gentleman.
ortoni is offline   Reply With Quote
Old 7th June 2020, 06:26   #3852  |  Link
ortoni
Registered User
 
Join Date: Oct 2010
Location: Auckland, Aotearoa/New Zealand
Posts: 8
Interesting scripting error arose:

outclip = core.std.StackVertical(clip,clip,clip,clip) gave the error File "src/cython/vapoursynth.pyx", line 1822, in vapoursynth.Function.__call__
vapoursynth.Error: StackVertical: Too many unnamed arguments specified.

Is there not a way to stack the same clip vertically or horizontally, or am I missing something?
TIA
ortoni is offline   Reply With Quote
Old 7th June 2020, 07:05   #3853  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,345
Quote:
Originally Posted by ortoni View Post
Interesting scripting error arose:

outclip = core.std.StackVertical(clip,clip,clip,clip) gave the error File "src/cython/vapoursynth.pyx", line 1822, in vapoursynth.Function.__call__
vapoursynth.Error: StackVertical: Too many unnamed arguments specified.

Is there not a way to stack the same clip vertically or horizontally, or am I missing something?
TIA
Enclose in square brackets
Code:
outclip = core.std.StackVertical([clip,clip,clip,clip])
poisondeathray is offline   Reply With Quote
Old 7th June 2020, 19:17   #3854  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
suggestion: dynamically typed filter arguments should be supported (something like "param: dynamic: opt")
this could greatly simplify the user interface of filters like std.SetFrameProp
"intval", "floatval" and "data" could be unified by a single dynamically typed parameter "val"
there's no need to separate arguments of different data types since whenever the user passes a value to "val", the C++ plugin could query the type of the item associated with "val", then decide how "val" should be handled, example here: https://github.com/IFeelBloated/vsFi...e/Map.vxx#L159
feisty2 is offline   Reply With Quote
Old 7th June 2020, 23:54   #3855  |  Link
ortoni
Registered User
 
Join Date: Oct 2010
Location: Auckland, Aotearoa/New Zealand
Posts: 8
Quote:
Originally Posted by poisondeathray View Post
Enclose in square brackets
Code:
outclip = core.std.StackVertical([clip,clip,clip,clip])
...aaaand thank you! Normal service has resumed
ortoni is offline   Reply With Quote
Old 10th June 2020, 09:26   #3856  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Those of you who are interested in audio support should take a look at the latest audio build and the audio development thread.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is online now   Reply With Quote
Old 14th June 2020, 04:18   #3857  |  Link
nacho
Registered User
 
Join Date: May 2019
Posts: 5
Hi I need some help.
I have a clip with the property 'Scenechange' added to all frames (by WWXD) I want to do the following:
For every scenechange frame I want to extract 4 frames:
The two before it, the marked frame and the 1 after it. I also want to label them with their frame numbers in the source (using Text).

I then want all these series' of 4 frames in sequence as 1 clip.

Can someone help me please? Also FrameEval is runtime evaluated and I don't know if I need that...

Edit:
Here's what I've come up with... it seems fairly slow - vsedit hangs for a bit. And the 4 frames all have the same frame# (of the scenechange), can anyone tell me if this is the right way to go about what I want.
Code:
def extractSC(clip):
    scdetect = core.wwxd.WWXD(clip=clip)
    extract = core.std.BlankClip(clip=scdetect, length = 1)
    sceneChangeNr = 0	
    for i in range(scdetect.num_frames-1):
        frame = scdetect.get_frame(i)	
        if frame.props['Scenechange'] == 1:
            sceneChangeNr+=1	
            before = i - 2
            after = i + 2
            if i < 2:
                before = i
            extract += core.text.Text(scdetect[before:after], "Frame No.: " + str(i) '\nScene Change: ' + str(sceneChangeNr))
    return extract

Last edited by nacho; 15th June 2020 at 01:11.
nacho is offline   Reply With Quote
Old 15th June 2020, 19:05   #3858  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
Is there maybe something like AviSynth AddAutoloadDir?
stax76 is offline   Reply With Quote
Old 15th June 2020, 19:15   #3859  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,795
I don't think so but it's easy to make your own Autoloaddir with something like

Code:
import glob
plugins = glob.glob(r"C:\plugins64\*.dll")
for plugin in plugins:
	try:
		vs.core.std.LoadPlugin(plugin)
	except:
		print("some err")
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database
ChaosKing is online now   Reply With Quote
Old 15th June 2020, 19:30   #3860  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
The reason why I ask is in portable mode VapourSynth has an auto load folder defined but I don't want staxrip users to modify anything within the startup folder because then it would be difficult to update staxrip, so for portable mode I'm adding another auto load folder located in the staxrip settings folder, it can be opened in the main menu the same way as the installed auto load folder. I've added code like suggested so no problem.
stax76 is offline   Reply With Quote
Reply

Tags
speed, vaporware, vapoursynth

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:01.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.