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 22nd January 2021, 22:15   #4241  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 181
is it possible using VaporMagik to do get things out of tuple to atribute:
Code:
@property
def rgb(self):
    #action of converting
    return rgb_clip, isError, log  #returned is vs.VideoNode, bool and string

#something:
SetTypeAttribute(vs.VideoNode, 'rgb', rgb)

clip = core.avisource.AVISource(file.avi)
print(clip)
print(clip.rgb)
print(clip.isError)
print(clip.log)
#or maybe better
print(clip.rgb)
print(clip.rgb.isError)
print(clip.rgb.log)
#or
print(clip.rgb[0], clip.rgb[1], clip.rgb[2])
_Al_ is offline   Reply With Quote
Old 23rd January 2021, 07:20   #4242  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,525
I don't see why you'd think that you cannot do that, although what you're trying to do doesn't seem elegant to me.
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is online now   Reply With Quote
Old 23rd January 2021, 09:00   #4243  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 181
ok, I got that, thanks, but then I could not figure out how to have array/list of clips done by that, that code is too much for me, I settled with something like this at the end:
Code:
import vapoursynth as vs
from vapoursynth import core
import collections

class Clips(list):    
    def __init__(self, inputs):
        list.__init__(self,[])
        
        self.Clip_data = collections.namedtuple('Clip_data', ['clip','rgb','isError','log','output_index'])

        if isinstance(inputs, type(vs.get_outputs())):
            inputs = [ (clip, output_index) for output_index, clip in inputs.items()]
                                         
        elif isinstance(inputs, list):
            inputs = [ (clip, None) for clip in inputs]
        else:
            raise ValueError('wrong input')
        for clip, output_index in inputs:
            self.append(self.set(clip, output_index))
 
    def set(self, clip, output_index=None):
        rgb, isError, log = self.toRGB(clip)
        #other work
        return self.Clip_data(clip=clip, rgb=rgb, isError=isError, log=log, output_index=output_index)
        
    def replace(self, index, clip, output_index=None):
        self[index] = self.set(clip, output_index)

    def appending(self, clip, output_index=None):
        self.append(self.set(clip, output_index))
        
    def toRGB(self, c):
        #conversion to rgb, mocking a return for show
        return core.resize.Bicubic(c, matrix_in_s='170m',format=vs.RGB24), False, 'this is a conversion log'
    
vs.clear_outputs()
clip = core.std.BlankClip(format=vs.YUV420P8)
clip.set_output(0)

bright = clip.std.Expr(['x 40 +','',''])
bright.set_output(1)

clips = Clips([clip, bright])
##clips = Clips(vs.get_outputs())

print(clips[0].clip)
print(clips[0].rgb)
print(clips[0].log)
print(clips[1].clip)
#...

#replacing clip on index 1
brightest = clip.std.Expr(['x 100 +','',''])
clips.replace(1, brightest)

#apending clip
clip = core.std.BlankClip(color=(255,0,0)).resize.Point(matrix_s='170m',format=vs.YUV420P8)
clips.appending(clip)
_Al_ is offline   Reply With Quote
Old 23rd January 2021, 12:39   #4244  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,525
Quote:
Originally Posted by _Al_ View Post
but then I could not figure out how to have array/list of clips done by that
obviously, you need to inject your custom attributes into the built-in list type. use the @Inject decorator provided by VaporMagik

Code:
@Inject
def f(self: list):
    for x in self:
        print(x)

[1, 2, 3, 4].f() # prints "1 2 3 4"
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated

Last edited by feisty2; 23rd January 2021 at 12:42.
feisty2 is online now   Reply With Quote
Old 25th January 2021, 23:20   #4245  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 181
ok thanks, I used dataclass at the end, same syntax as namedtuple, I understand it, and it can assign and change attributes directly (namedtuple has awkward syntax). Not saying that VaporMagik cannot do that, most likely yes.
_Al_ is offline   Reply With Quote
Old 27th January 2021, 07:12   #4246  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,525
@Myrsloik
could you explain how getFrame() is invoked with different activation reasons, particularly the case involving arAllFramesReady && !*frameData? it seems getFrame() might be invoked twice with the same activation reason, what happens after getFrame() exits from the arAllFramesReady && !*frameData branch and before it gets invoked again? if several frames (either from the same node or from several nodes) are requested in the arAllFramesReady && !*frameData branch, is it guaranteed that all requested frames are ready before the next call to getFrame()?

there seems to be 4 types of filters with different getFrame() skeletons:

standard filters
arInitial -> RequestReferenceFrames()
arAllFramesReady -> DrawFrame()

source filters
arInitial -> DrawFrame()

special filters (e.g. std.FrameEval)
arInitial -> RequestReferenceFrames()
arAllFramesReady && !*frameData -> RequestSpecialResources()
arAllFramesReady -> DrawFrame()

special(or weird?) source filters
arInitial && !*frameData -> RequestSpecialResources()
arInitial -> DrawFrame()

any other possibilities? also is it possible to get a concrete error message if the arError branch is activated?
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is online now   Reply With Quote
Old 27th January 2021, 11:09   #4247  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,289
Quote:
Originally Posted by feisty2 View Post
@Myrsloik
could you explain how getFrame() is invoked with different activation reasons, particularly the case involving arAllFramesReady && !*frameData? it seems getFrame() might be invoked twice with the same activation reason, what happens after getFrame() exits from the arAllFramesReady && !*frameData branch and before it gets invoked again? if several frames (either from the same node or from several nodes) are requested in the arAllFramesReady && !*frameData branch, is it guaranteed that all requested frames are ready before the next call to getFrame()?

there seems to be 4 types of filters with different getFrame() skeletons:

standard filters
arInitial -> RequestReferenceFrames()
arAllFramesReady -> DrawFrame()

source filters
arInitial -> DrawFrame()

special filters (e.g. std.FrameEval)
arInitial -> RequestReferenceFrames()
arAllFramesReady && !*frameData -> RequestSpecialResources()
arAllFramesReady -> DrawFrame()

special(or weird?) source filters
arInitial && !*frameData -> RequestSpecialResources()
arInitial -> DrawFrame()

any other possibilities? also is it possible to get a concrete error message if the arError branch is activated?
That's more or less the existing cases. Rule is very simple (ignore arFrameReady since it's effectively deprecated):

At the end of each invocation either an output frame must be returned OR there must be outstanding frame requests (requestFrameFilter).

First call is always arInitial to make things clear.
Once all requested frames are available arAllFramesReady is called.
You're allowed to request additional frames in arAllFramesReady which will then result in getting called with arAllFramesReady again and you can repeat this as many times as you like.
Errors may be propagated from other filters at any time after the arInitial call and then it's not the filter's job to handle it, only to clean up any allocated resources and return nothing. The error message is always propagated to the original requester to display. (As in whoever called getFrame/getFrameAsync)

Your last weird example is obviously invalid since it'll have outstanding frame requests when returning an output frame.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 27th January 2021, 12:51   #4248  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,525
Quote:
Your last weird example is obviously invalid since it'll have outstanding frame requests when returning an output frame.
that's good to know. then apparently the last weird case and the standard case could be unified by generalizing RequestReferenceFrames() to RequestResources()

Code:
if (activationReason == arInitial)
    if constexpr (requires { { filter->RequestResources() }->AnyBut<void>; })
        *frameData = new auto{ filter->RequestResources() };
    else if constexpr (requires { filter->RequestResources(); }) // fails to satisfy AnyBut<void>, therefore returns void, equivalent to RequestReferenceFrames()
        filter->RequestResources();
    else if constexpr (requires { { filter->DrawFrame() }->SubtypeOf<FrameReference>; }) // source filter
        return filter->DrawFrame().Leak();
    else
        static_assert(AlwaysFalse<decltype(filter)>, "missing attribute!");
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is online now   Reply With Quote
Old 28th January 2021, 07:49   #4249  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,525
what happens if there's no frame requested or generated in the arInitial branch (empty branch)? it might happen in rare cases like the following
Code:
if (activationReason == arInitial)
    for (auto& node : inputs) // inputs might be an empty container depending on the user input
        node.RequestFrame(n, FrameContext);
will getFrame() still be invoked with arAllFramesReady later on?
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is online now   Reply With Quote
Old 28th January 2021, 09:59   #4250  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,289
Quote:
Originally Posted by feisty2 View Post
what happens if there's no frame requested or generated in the arInitial branch (empty branch)? it might happen in rare cases like the following
Code:
if (activationReason == arInitial)
    for (auto& node : inputs) // inputs might be an empty container depending on the user input
        node.RequestFrame(n, FrameContext);
will getFrame() still be invoked with arAllFramesReady later on?
That's a fatal error since you either must have outstanding requests or return a frame.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 1st February 2021, 04:39   #4251  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,435
How does the api getCoreInfo2() function works? It asks for the core and VSCoreInfo as parameters. But the only way to get the VSCoreInfo from the document is by using api->getCoreInfo(), but it also said that this function was deprecated.
lansing is offline   Reply With Quote
Old 1st February 2021, 06:15   #4252  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,525
Quote:
Originally Posted by lansing View Post
How does the api getCoreInfo2() function works? It asks for the core and VSCoreInfo as parameters. But the only way to get the VSCoreInfo from the document is by using api->getCoreInfo(), but it also said that this function was deprecated.
https://github.com/IFeelBloated/vsFi...de/Core.vxx#L9
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is online now   Reply With Quote
Old 1st February 2021, 06:43   #4253  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,435
Quote:
Originally Posted by feisty2 View Post
Thanks I got it working. The naming is confusing, this is more like setCoreInfo rather than getCoreInfo
lansing is offline   Reply With Quote
Old 1st February 2021, 08:09   #4254  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,525
it's a common practice in C to return something via side effects (by manipulating global variables or modifying something from a foreign scope via pointers)
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is online now   Reply With Quote
Old 2nd February 2021, 01:46   #4255  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,435
Can I retrieve the paths for the vs plugin folder and script folder through the api?
lansing is offline   Reply With Quote
Old 2nd February 2021, 05:27   #4256  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Providence, RI
Posts: 2,525
plugin path: https://github.com/IFeelBloated/vsFi...Plugin.vxx#L59
script path: https://github.com/IFeelBloated/Vapo...orMagik.py#L71
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is online now   Reply With Quote
Old 2nd February 2021, 11:52   #4257  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,289
Quote:
Originally Posted by lansing View Post
Can I retrieve the paths for the vs plugin folder and script folder through the api?
The script "folder" isn't a single folder but simply all the normal python import paths. You can see vsrepo.py to see how it's determined by default I guess.

The "vs plugin folder" is also harder to determine. Basically you have 3 locations:
1. The core plugins
2. The global plugins
3. User plugins

The location of 2 is written to the registry and 3 is always in the same appdata location. Why do you even need to find out where things are?
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 2nd February 2021, 12:09   #4258  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,435
Quote:
Originally Posted by Myrsloik View Post
The script "folder" isn't a single folder but simply all the normal python import paths. You can see vsrepo.py to see how it's determined by default I guess.

The "vs plugin folder" is also harder to determine. Basically you have 3 locations:
1. The core plugins
2. The global plugins
3. User plugins

The location of 2 is written to the registry and 3 is always in the same appdata location. Why do you even need to find out where things are?
I want to create links in vseditor to open them in one click. Right now Iím relying on vsrepogui, but when vsrepogui didnít work, itíll be a pain to look for them manually.
lansing is offline   Reply With Quote
Old 2nd February 2021, 12:28   #4259  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,467
For plugins http://www.vapoursynth.com/doc/plugins.html#windows
vsrepogui just uses the paths provided by vsrepo.

But registry can be tricky if the user has installed 32bit vapoursynth or it is a "per user installation".

I need to check 4 locations in vsrepogui to cover all cases.

Code:
            var regl32 = new VsRegistry().GetRegistry(localKey32, @"SOFTWARE\VapourSynth-32");
            var regl64 = new VsRegistry().GetRegistry(localKey64, @"SOFTWARE\VapourSynth");

            var regu32 = new VsRegistry().GetRegistry(userKey32, @"SOFTWARE\VapourSynth-32");
            var regu64 = new VsRegistry().GetRegistry(userKey64, @"SOFTWARE\VapourSynth");
localKey* => RegistryHive.LocalMachine
userKey* => RegistryHive.CurrentUser


EDIT
vsrepo code for scripts

https://github.com/vapoursynth/vsrep...vsrepo.py#L186
Code:
import site
site_package_dir = site.getusersitepackages()
Which returns C:\Users\USER\AppData\Roaming\Python\Python38\site-packages
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database || https://github.com/avisynth-repository

Last edited by ChaosKing; 2nd February 2021 at 12:42.
ChaosKing is offline   Reply With Quote
Old 2nd February 2021, 13:21   #4260  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,435
User plugin should be all I need. I think I’ll just call vsrepo to open them.
lansing is offline   Reply With Quote
Reply

Tags
speed, vaporware, vapoursynth

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 17:03.


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