View Full Version : How do I append video from another script using subprocess?
lansing
27th November 2017, 02:25
I want to append a video loaded from a script with video data piped from another script using subprocess.
child.vpy
import vapoursynth as vs
core = vs.get_core()
clip = core.ffms2.Source(r"a.mp4")
clip.set_output()
main.vpy
import vapoursynth as vs
import subprocess
core = vs.get_core()
clip = core.ffms2.Source(r"b.mp4")
command = "vspipe child.vpy -"
child = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
final = clip + child
final.set_output()
When I run the main.vpy, the editor frozed.
Are_
27th November 2017, 02:57
OK, this looks really ugly to me, but if you really want to do that maybe you need to do something like this:
slave_script.py:
def my_output(core):
clip = core.ffms2.Source('something)
# And do something here, maybe
return clip
master_script.py:
import sys
import os
import vapoursynth as vs
sys.path.append(os.getcwd())
import slave_script
core = vs.get_core()
clip = core.ffms2.Source(somethin_else)
clipb = slave_script.my_output(core)
clip = clip + clipb
clip.set_output()
lansing
27th November 2017, 03:18
The reason for this is that my denoiser can only have one instance per script, it will crash if there're more than one. And I need to call it multiple times on multiple clips in one script and then joined the results. So I have to find a workaround. I'm hoping that by piping in a video stream from another script would count as another instance.
I doubt that simply importing a slave script will work.
Mystery Keeper
27th November 2017, 21:24
The reason for this is that my denoiser can only have one instance per script, it will crash if there're more than one. And I need to call it multiple times on multiple clips in one script and then joined the results. So I have to find a workaround. I'm hoping that by piping in a video stream from another script would count as another instance.
I doubt that simply importing a slave script will work.
A plugin you wrote yourself? Is it using FFTW?
If both answers are yes - you just need to create buffers and plans for each instance and remember them in the instance data. Plan creation functions are not thread-safe, so you need to put a global mutex around them. That should work.
lansing
27th November 2017, 22:01
A plugin you wrote yourself? Is it using FFTW?
If both answers are yes - you just need to create buffers and plans for each instance and remember them in the instance data. Plan creation functions are not thread-safe, so you need to put a global mutex around them. That should work.
No, It's a virtualdub filter
lansing
28th November 2017, 01:31
Okay I figured out a workaround. I loaded the same filter into vapoursynth as a different function name and it works, no crash. Test encoding the script for 10000 frames without problem.
core.avs.LoadPlugin(r"C:\Program Files (x86)\AviSynth+\plugins64+\VDubFilter.dll")
core.avs.LoadVirtualdubPlugin(r'nv.vdf', 'nv', 1)
core.avs.LoadVirtualdubPlugin(r'nv.vdf', 'nv2', 1)
clipa = core.avs.nv(clip)
clipb = core.avs.nv2(clip)
clip = clipa + clipb
clip.set_output()
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.