View Single Post
Old 13th December 2017, 15:17   #11  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by lansing View Post
Update script in top post.

And I ran into a performance issue with the build montage function, mainly with the many calls to stackhorizontal and stackvertical.

Code:
clip = core.ffms.source("hi.mp4")
frame_list = range(300)

frame_counter = 0
change_row = False

for n in frame_list:
    frame_counter += 1
    
    if frame_counter == 1:
        row = clip[n]
    elif frame_counter == per_row:
        row = core.std.StackHorizontal([row, clip[n]])
        change_row = True

    ...
I create the montage by looping through a list of frame numbers and stack them one at a time with stackhorizontal and stackvertical. But this slows the script instantiating time to 6 seconds and each seek in preview costed 80MB of RAM...

I have had a similar performance issue with looping and concatenating clip before:
Code:
clip = core.ffms.source("hi.mp4")
 
frame_list = range(300)
clip_list = []

for n in frame_list:
    clip_list += clip[n:600]
The solution to this is to use append instead of "+="
Code:
for n in frame_list:
    clip_list.append(clip[n:600])
But I don't know how to do that for stackhorizontal/vertical. Vapoursynth will flush the memory when the program hits 4.5G so there's no worry about that it will run out of memory, but I just want to know if there is a more efficient way to stack the frames together?
Incomplete script so can't even figure out exactly what you're doing. You are passing a list of all the clips in a row at once, right? That'll reduce the number of intermediate frames. 80MB sounds quite reasonable for a 300 frame montage...
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is online now   Reply With Quote