Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to pass more clips in Expr #17

Closed
couleurm opened this issue Nov 13, 2022 · 2 comments
Closed

Allow to pass more clips in Expr #17

couleurm opened this issue Nov 13, 2022 · 2 comments

Comments

@couleurm
Copy link

Could it be possible to allow for more letters (currently supports A-Z, new characters or letters could be european stuff like éöâîï, should be plenty with all combinations) and thus also allow for more clips to be provided ?

My use case for this is having more seamless motion blur (remember my script and sample in VS-Classic's #7, I currently use vs-frameblender as a backup in case user provides more than 25 weights

@AkarinVS
Copy link
Owner

AkarinVS commented Nov 13, 2022

Couldn't you divide the weights into multiple Expr's?
e.g.
w0 * x + w1 * y + w2 * z can be changed to (assuming Expr only allows two input clips):

Expr([Expr([x, y], f"{w0} x * {w1} y * +"), z], f"x {w2} y * +"))

If you have a large number of clips, an expression like this will be bounded by memory bandwidth, so splitting it into multiple passes won't hurt much. Just remember to balance the size of expressions.

For example, this function implements arbitrary frame averaging:

def Weighted(clips, weights):
    names = ''.join(map(lambda x: chr(x+ord('a')), range(26)))
    names = names[-3:] + names[:-3] # 'xyzabc...w'
    limit = 26
    if len(clips) <= limit:
        return core.akarin.Expr(clips, ' '.join(map(lambda cw: f'{cw[0]} {cw[1]} *', zip(names[:len(clips)], weights))) + ' +' * (len(clips)-1))
    else:
        return Weighted([Weighted(clips[:limit], weights[:limit])] + clips[limit:], [1.0] + weights[limit:])

(The generated data flow graph is not very efficient, but I doubt it will matter much in practice. And if you want, you can rewrite it to generate a proper balanced tree structure.)

@AkarinVS
Copy link
Owner

Implemented. Use srcN to access the N-th clip. (N counts from 0.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants