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 21st June 2021, 22:40   #1  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Creating/Loading Script Files

I'm looking into converting an Avisynth AVSI file to VapourSynth.

I'm stuck at the very basics: importing a script file into another one.

Code:
import FrameRateConverter as frc
Python exception: No module named 'FrameRateConverter'

Code:
from . import FrameRateConverter as frc
Python exception: attempted relative import with no known parent package

How am I supposed to do it? And do I have to create utility files with .py extension, while the main VapourSynth script file itself is .vpy?
MysteryX is offline   Reply With Quote
Old 22nd June 2021, 02:05   #2  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
I found the sample scripts here
https://vsdb.top/

Obviously it will load if it's in the VapourSynth plugin folders. Does that mean I need to do all the development in the VapourSynth plugin folder?

Then for software like StaxRip coming with plugins bundled, how does it set to search in its own folder?
MysteryX is offline   Reply With Quote
Old 22nd June 2021, 19:25   #3  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,277
This is how Hybrid which uses a portable Vapoursynth imports stuff:
Code:
# Imports
import os
import sys
import ctypes
# Loading Support Files
Dllref = ctypes.windll.LoadLibrary("I:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
import vapoursynth as vs
core = vs.get_core()
# Import scripts folder
scriptPath = 'I:/Hybrid/64bit/vsscripts'
sys.path.append(os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/EEDI3.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/vsznedi3.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/temporalsoften.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/d2vSource/d2vsource.dll")
# Import scripts
import havsfunc
Cu Selur
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 23rd June 2021, 02:05   #4  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
I'm having issues loading .py script files. If I put them in the same folder, it doesn't recognize them. If I put it in the VapourSynth\plugins folder, it loads the DLLs but doesn't recognize the scripts either.

How do I get them to be found?
MysteryX is offline   Reply With Quote
Old 23rd June 2021, 03:57   #5  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Installing the scripts via vsrepo does work, but that doesn't answer how to load scripts as I'm developing them, or how to load them from a set folder.
MysteryX is offline   Reply With Quote
Old 23rd June 2021, 04:27   #6  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,370
By default they are imported from the python site-packages directory

eg.
import havsfunc

would automatically look in the site-packages directory for havsfunc.py


Selur has an example above of how to use a custom location
poisondeathray is offline   Reply With Quote
Old 23rd June 2021, 19:23   #7  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,277
Through sys.path.append(os.path.abspath(scriptPath)) I tell Python to that 'scriptPath' is an additional path or for find scripts in side.
With 'import havsfunc' I tell it to search all the script paths for a file named havsfunc(.py) and load it under the name havsfunc, if I would use 'import havsfunc as havs' it would be available under 'havs'.
When using 'import havsfunc' I can access QTGMC through 'clip = havsfunc.QTGMC(...)'
So unless you use the one of the autoloading/importing folders from Python, this is the way it goes afailk.

Your
Code:
from . import FrameRateConverter as frc
should be
Code:
import os
import sys
# append current dir, the current script file resides in, to sys.path
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
# import FrameRateConver script file under the name frc
import FrameRateConverter as frc
__file__ = current file
os.path.abspath(__file__)) = absolute path to current file
os.path.dirname(os.path.abspath(__file__))) = absolute path to the directory the current file resides in

Cu Selur

Ps.: I hope this helps a bit
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 23rd June 2021 at 19:36.
Selur is offline   Reply With Quote
Reply

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 14:40.


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