Log in

View Full Version : TemporalSoften alternative for Timelapse


Zanthra
10th November 2013, 09:27
So I do a lot of video game videos, and I particularly like turning them into time-lapse videos. I used to use something like TemporalSoften(10, 255, 255, 0, 2).SelectEvery(10), and it looked better than just a SelectEvery(10), but I realized that the radius was blending 19 frames together (I should have been using TemporalSoften(5, 255, 255, 0, 2).SelectEvery(11, 5)).

I switched to using a series of SelectEvery, SelectRangeEvery and recursive calls to Overlay mode="blend", but rescently I wanted to shrink 3 hours into 4 minutes, and wanted to blend every 40 frames, and it became incredibly slow. I ended up converting to yuy2 to use Layer() in a tree to blend 32 frames together and managed a descent speed.

I looked back and found TemporalSoften was faster still (and worked in a wide variety of colorspaces) even with very large groups, but the one catch with it is I can't find any way to get it to blend an even number of frames together. I know I can be one off and not make a huge difference at the higher numbers (and use the alternatives like overlay for 2, 4 and 6 frames), although it seems there should be an alternative as TemporalSoften has a lot of code I don't need for what I am trying to do.

Any suggestions are welcome,
Thanks,
Zanthra

Gavino
10th November 2013, 12:46
How about this:
function TimeLapse(clip c, int n) {
# blends together every n frames
radius = (n-1)/2
c.TemporalSoften(radius, 255, 255, 0, 2)
n%2 == 0 ? Merge(c.SelectEvery(1, n/2), 1.0/n) : NOP
SelectEvery(n, radius)
AssumeFPS(c)
}
For an even number of frames, it uses Merge() to blend in an extra frame beyond the range of the TemporalSoften().

Zanthra
10th November 2013, 22:47
That works perfectly thanks! Much nicer than any script I would have come up with ;P.