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 27th November 2017, 02:25   #1  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
How do I append video from another script using subprocess?

I want to append a video loaded from a script with video data piped from another script using subprocess.

child.vpy
Code:
import vapoursynth as vs

core = vs.get_core()

clip = core.ffms2.Source(r"a.mp4")
clip.set_output()
main.vpy
Code:
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.
lansing is offline   Reply With Quote
Old 27th November 2017, 02:57   #2  |  Link
Are_
Registered User
 
Join Date: Jun 2012
Location: Ibiza, Spain
Posts: 321
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:
Code:
def my_output(core):
    clip = core.ffms2.Source('something)
    # And do something here, maybe
    return clip
master_script.py:
Code:
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()
Are_ is offline   Reply With Quote
Old 27th November 2017, 03:18   #3  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
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.

Last edited by lansing; 27th November 2017 at 03:35.
lansing is offline   Reply With Quote
Old 27th November 2017, 21:24   #4  |  Link
Mystery Keeper
Beyond Kawaii
 
Mystery Keeper's Avatar
 
Join Date: Feb 2008
Location: Russia
Posts: 724
Quote:
Originally Posted by lansing View Post
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.
__________________
...desu!
Mystery Keeper is offline   Reply With Quote
Old 27th November 2017, 22:01   #5  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Quote:
Originally Posted by Mystery Keeper View Post
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 is offline   Reply With Quote
Old 28th November 2017, 01:31   #6  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
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.

Code:
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()
lansing 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 08:59.


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