Log in

View Full Version : vapoursynth enviroment


_Al_
27th January 2021, 01:34
http://www.vapoursynth.com/doc/pythonreference.html?highlight=core#Environment
Would someone be kind enough and laid out scenarios where it would be used and why, or short schema in a code etc. That be appreciated, thank you.

Myrsloik
27th January 2021, 10:59
http://www.vapoursynth.com/doc/pythonreference.html?highlight=core#Environment
Would someone be kind enough and laid out scenarios where it would be used and why, or short schema in a code etc. That be appreciated, thank you.

It's mostly if you use vapoursynth directly through python without the vsscript api. You could see it as an implementation detail being exposed more or less. I've never used it myself.

ChaosKing
27th January 2021, 11:42
I think the "Enviroment commits" came mostly from stuxcrystal, author of yuuno. It's used here: https://github.com/Irrational-Encoding-Wizardry/yuuno/blob/5d1259cc5570a0b7a670688eb10b4608d64b6f7a/yuuno_ipython/ipy_vs/vsscript.py

_Al_
28th January 2021, 21:37
Thanks, that example makes it understand better,

I have simplified code a bit, having a worker.py module like this:
import vapoursynth as vs
from vapoursynth import core
import threading
from queue import Queue

class Processor(threading.Thread):
def __init__(self, queue, clip):
threading.Thread.__init__(self)
self.queue = queue
self.clip = clip

def run(self):
clip = core.resize.Bicubic(self.clip, matrix_in_s='170m', format=vs.RGB24)
clip = clip.text.Text('I was processed')
self.queue.put(clip)

def input(clip):
queue = Queue()
processor = Processor(queue, clip)
processor.start()
processor.join()
return queue.get()
when running this code in vsedit:
import vapoursynth as vs
from vapoursynth import core
import sys
sys.path.append(r'H:\directory_where_worker_module_is')
sys.argv = 'pythonw'
import worker
clip = core.std.BlankClip(format=vs.YUV420P8)
clip = worker.input(clip)
clip.set_output()
It freezes or does not pass correct clip. When tried to raise error with not simplified version, perhaps as soon as calling vs in a thread I got:
Internal environment id not set. Was get_core() called from a filter callback?
that is why i tried to prevent it if possible, no luck. Still using obsolete R45 with python 3.7 though and latest vsedit (19).
Also, it works if using IDLE.

feisty2
29th January 2021, 18:52
what's with all that threading stuff? the single core instance already utilizes all physical threads of your hardware.

_Al_
29th January 2021, 19:21
Yes, it's oversimplified nonsense, because there is actually a loop running in that threaded run() and more classes working in parallel. There is no processor.join() because mainloop blocks the code itself. I guess it would be better to wait until everything is done and then to post a link to a whole thing, if that still will be an issue.
Or maybe is this error:
Internal environment id not set. Was get_core() called from a filter callback? signaling something specific that could be mentioned, what it means? Except of course that id is not set? :-)