View Full Version : How to debug Vapoursynth script?
Bob_97
6th September 2020, 04:41
I have a vapoursynth script that I am attempting to pass a variable clipname to using vspipe. When the clipname is hard-coded in the vs script it works fine. I suspect that what I am passing (a clip name string) is not being read correctly by the vs script.
How can I get debug info on this - print statements in the vs script dont work when run under vspipe (maybe output going somehwre else?)
Any help appreciated.
fAy01
6th September 2020, 07:08
Try vseditor or vseditor2.
_Al_
6th September 2020, 16:07
you can pass string type object into vspipe:
vspipe.exe --arg "my_input=D:/path/my_video.avi" script.vpy - --y4m | x264.exe ......
and having script line, something like:
clip = core.avisource.AVISource(my_input)
but passing VideoNode type of object would not work , because you are not in Python enviroment using vspipe,
you technically could pass string and then use getattr() to get select that object in script but it is complicated
you use output indexes, that is why it was designed for, you can pipe many VideoNode objects in your script , many variants, like that:
clip.set_output(0)
other_clip.set_output(1)
etc.
.
and in vspipe you select those indexes:
vspipe -o 1 my_script.vpy | x264 ....
which would use your other_clip VideoNode. You can loop those indexes in batch script, whatever
_Al_
6th September 2020, 18:35
Vapoursynth (edit: actually python) puts videonode reference into globals dict so it can be pulled from there. At the end of your script you can set up output like this:
clip = core.avisource.AVISource('my_file.avi')
blurred = clip.std.BoxBlur()
.
.
dict(globals())[vspipe_passing].set_output()
and using this to preview it:
vspipe.exe --arg "vspipe_passing=blurred" script.vpy - --y4m | mpv.exe -
or
vspipe.exe --arg "vspipe_passing=clip" script.vpy - --y4m | mpv.exe -
did not tested it but it should work. Although I would rather focus working with pipe indexes, because you have no preview available etc.
Also note, there are previewers out there, that do it more easily (https://github.com/UniversalAl/view), also comparing (debugging) videonodes. :-)
Bob_97
6th September 2020, 23:52
Thanks for all your help, it has solved my problem, but I have found an odd result.
If I use:
vspipe --arg my_clip=arthur.mov --y4m -p ...etc
and in the vapoursynth script:
clipname=my_clip.decode('utf-8')
it works perfectly (passes the binary string). But if I do:
vspipe --arg "my_clip=arthur.mov" --y4m -p ...etc
script (with no decode line) throws error: NameError: name 'my_clip' is not defined. What's that about?
_Al_
7th September 2020, 00:24
I just tried it, using:
clipname=my_clip.decode('utf-8')
or
clipname=my_clip.decode()
or
clipname=my_clip #using simple characters and it perhaps still works
all work
vapoursynth manual says (http://www.vapoursynth.com/doc/vspipe.html#options) it is indeed in bytes i global dictionary, but not decoding it still works. But I use script.py not script.vpy, not sure if it matters now.
But I would not use wording clip for filename paths, it is misleading sort of. In Vapoursynth clip usually means VideoNode object, it s sort of consensus, which is Python object. You were perhaps talking about paths since the beginning which was confusing. Paths are string type of objects.
Bob_97
7th September 2020, 03:24
yes clipname=my_clip.decode() works fine on my setup (script = .vpy) as does clipname=my_clip. Its just odd that the doublequote version of --args doesnt? Results in error: NameError: name 'my_clip' is not defined
Tried with the script.py and same result as script.vpy
But I'm moving forward, so thanks a heap for your help
Cheers
_Al_
7th September 2020, 04:32
I don't remember why I started to wrapping quotes for both key and path: --arg "key=filepath". Most likely there was a space in a path, where it would fail in command line, and I put quotes like that and it worked. Similar like in windows batch does.
Maybe it is wrong and it is better to wrap quotes just around path: --arg key="C:\path\my file with space characters.avi"
whatever works. Not sure how it is parsed before it is put in that globals dictionary.
Bob_97
7th September 2020, 07:09
The docs say to do it the way you have --arg "key=filepath"
I tried both ways and neither works on my system.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.