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 13th September 2017, 18:19   #2761  |  Link
splinter98
Registered User
 
Join Date: Oct 2010
Posts: 36
Quote:
Originally Posted by Myrsloik View Post
Trim and splice. Like avisynth.
Yep, but unlike avisynth you can sprinkle some python magic (untested):

Code:
def gen_clip(clip, ranges, settings):
    i = 0
    for rng, setting in ranges:
        start, end = rng
        if start > i:
            yield clip[i:start], None
        yield clip[start:end]), setting
        i = end
    if end < len(clip):
        yield clip[end:]

clip = core.std.Splice([somefunc(c, setting=s) for c,s in gen_clip(clip, ranges, settings) if s is not None else c])

Last edited by splinter98; 13th September 2017 at 18:24.
splinter98 is offline   Reply With Quote
Old 13th September 2017, 20:33   #2762  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,080
Quote:
Originally Posted by Myrsloik View Post
Trim and splice. Like avisynth.
Except AviSynth has ReplaceFramesSimple:

A=somefunc(settings)
ReplaceFramesSimple(Last,A,Mappings="[0 500]")


It is, admittedly, even more helpful when you have multiple instances of needing the same settings over a limited range of frames but I couldn't live without it and find the more traditional Trim/Splice method pretty clunky and completely unworkable when there are a lot of different filters with different settings to use over a limited range of frames. It won't work in Vapoursynth without changes being made?

http://www.avisynth.nl/users/stickboy/

Last edited by manono; 14th September 2017 at 05:18. Reason: Fixed an incomplete ReplaceFramesSimple line. Can also add more frame ranges if needed.
manono is offline   Reply With Quote
Old 13th September 2017, 23:42   #2763  |  Link
Are_
Registered User
 
Join Date: Jun 2012
Location: Ibiza, Spain
Posts: 238
And in vapoursynth you have https://github.com/Irrational-Encodi...th-RemapFrames and https://github.com/Irrational-Encodi...vsfunc.py#L825 and only god know how many more python functions scattered around the internet.
Are_ is offline   Reply With Quote
Old 14th September 2017, 00:32   #2764  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 951
Yes. You have the Python standard library at your fingertips and the VS clips are list-like objects. There is absolutely no need for plugins to muck around with frame orders or applying filters to parts of clips.

If I read the original request correctly you just want to use zip() to pair up frame ranges with their arguments. That's pretty much a oneliner, something like
Code:
ranges = [(0, 200), (300, 400)]
settings = [{'argument': 3}, {'argument': 4}]
clip = core.std.splice([core.foo.Bar(clip, **args)[start:end] for (start, end), args in zip(ranges, settings)])
Not tested, of course.

Python syntax abuse used:
- Double splat operator (**), or "argument dict unpacking": if you have a function in Python that takes two named arguments a and b, and a dict like {"a": 3, "b": 4}, calling func(**argsDict) will end up calling the function with the a parameter being 3 and the b parameter being 4. Very handy, that. Use single splat (*) for similarly translating a list to positional arguments. You can use both at the same time, as in func(*positional, **named).

- List comprehensions, as in [str(x) for x in [0, 1, 2]] - a handy way to write oneliners and you should use them at every opportunity to make sure nobody can read your code.

- Nested destructuring (or maybe it's more appropriately called "unpacking" in Python terminology?) assignment of iterator variables, as in:
Code:
[str(c) for (b, c), a in [((3, 5), 6)]]
# returns ['5']

Last edited by TheFluff; 14th September 2017 at 00:56.
TheFluff is offline   Reply With Quote
Old 14th September 2017, 00:55   #2765  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 699
Quote:
Originally Posted by TheFluff View Post
Yes. You have the Python standard library at your fingertips and the VS clips are list-like objects. There is absolutely no need for plugins to muck around with frame orders or applying filters to parts of clips.

If I read the original request correctly you just want zip() to pair up frame ranges with their arguments. That's pretty much a oneliner, something like
Code:
ranges = [(0, 200), (300, 400)]
settings = [{'argument': 3}, {'argument': 4}]
clip = core.std.splice([core.foo.Bar(clip[start:end], **args) for (start, end), args in zip(ranges, settings)])
Not tested, of course.

Python syntax abuse used:
- Double splat operator (**), or "argument dict unpacking": if you have a function in Python that takes two named arguments a and b, and a dict like {"a": 3, "b": 4}, calling func(**argsDict) will end up calling the function with the a parameter being 3 and the b parameter being 4. Very handy, that. Use single splat (*) for similarly translating a list to positional arguments. You can use both at the same time, as in func(*positional, **named).

- List comprehensions, as in [str(x) for x in [0, 1, 2]] - a handy way to write oneliners and you should use them at every opportunity to make sure nobody can read your code.

- Nested destructuring (or maybe it's more appropriately called "unpacking" in Python terminology?) assignment of iterator variables, as in:
Code:
[str(c) for (b, c), a in [((3, 5), 6)]]
# returns ['5']
I did use zip() in a for loop similar, but then that will only append clips with frames that were specified in the ranges. In this example, I want to apply filter on frame 0-200 and 300-400, and have frame 201-299 and frames after 400 untouched.

Reading through the filter description, looks like ReplaceFrames is the function for this task.
lansing is offline   Reply With Quote
Old 14th September 2017, 15:30   #2766  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 699
Ok I got it working with ReplaceFramesSimple in the remapframes package
Code:
ranges = [[0,200],[300,400],[1000,10000]]
settings = [1,2,3]

for r, s in zip(ranges, settings):
	temp = somefunc(clip, setting=s)
	map_string = '[{} {}]'.format(r[0], r[1])	
	final_clip = core.remap.Rfs(clip, temp, mappings=map_string, mismatch=False)
lansing is offline   Reply With Quote
Old 19th September 2017, 13:04   #2767  |  Link
Artofeel
Registered User
 
Artofeel's Avatar
 
Join Date: Apr 2016
Posts: 7
AVFS is not working since pfmap-185 version
just closes right after start mounting (VapourSynth-R39-test4 \ VapourSynth-R38)
pfmap-184 is last working
I'm only one who used that feature?..
Artofeel is offline   Reply With Quote
Old 19th September 2017, 13:08   #2768  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,520
Quote:
Originally Posted by Artofeel View Post
AVFS is not working since pfmap-185 version
just closes right after start mounting (VapourSynth-R39-test4 \ VapourSynth-R38)
pfmap-184 is last working
I'm only one who used that feature?..
I'll give it a try then. Note that you don't even need it since a branded pismo library is also included in the installer.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 19th September 2017, 15:08   #2769  |  Link
Artofeel
Registered User
 
Artofeel's Avatar
 
Join Date: Apr 2016
Posts: 7
Quote:
Originally Posted by Myrsloik View Post
Note that you don't even need it since a branded pismo library is also included in the installer.
yeah, but I use pismo
like store thousands of images in one .pfo file
so I need new version of it due to some bugfixes
Artofeel 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:05.


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