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. |
6th September 2020, 04:41 | #1 | Link |
Registered User
Join Date: Aug 2020
Posts: 4
|
How to debug Vapoursynth script?
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. |
6th September 2020, 16:07 | #3 | Link |
Registered User
Join Date: May 2011
Posts: 321
|
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 |
6th September 2020, 18:35 | #4 | Link |
Registered User
Join Date: May 2011
Posts: 321
|
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:
Code:
clip = core.avisource.AVISource('my_file.avi') blurred = clip.std.BoxBlur() . . dict(globals())[vspipe_passing].set_output() Code:
vspipe.exe --arg "vspipe_passing=blurred" script.vpy - --y4m | mpv.exe - Code:
vspipe.exe --arg "vspipe_passing=clip" script.vpy - --y4m | mpv.exe - Also note, there are previewers out there, that do it more easily , also comparing (debugging) videonodes. :-) Last edited by _Al_; 6th September 2020 at 23:47. |
6th September 2020, 23:52 | #5 | Link |
Registered User
Join Date: Aug 2020
Posts: 4
|
Odd result
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? |
7th September 2020, 00:24 | #6 | Link |
Registered User
Join Date: May 2011
Posts: 321
|
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 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. Last edited by _Al_; 7th September 2020 at 00:42. |
7th September 2020, 03:24 | #7 | Link |
Registered User
Join Date: Aug 2020
Posts: 4
|
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 |
7th September 2020, 04:32 | #8 | Link |
Registered User
Join Date: May 2011
Posts: 321
|
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. |
|
|