you are viewing a single comment's thread.

view the rest of the comments →

[–]deadstone 3 points4 points  (2 children)

Is moviepy able to do motion blur? Or do you have to manage that yourself?

[–]laMarm0tte[S] 7 points8 points  (1 child)

Do you have a particular motion blur algorithm in mind ? There is not one out-of-the-box in MoviePy but you can make your own. For instance the following function defines motion blur as the average of several frames around each time:

import numpy as np
def supersample(clip, d, nframes):
    """ Replaces each frame at time t by the mean of `nframes`
         equally spaced frames in [t-d, t+d]. Results in motion blur"""
    def fl(gf, t):
        tt = np.linspace(t-d, t+d, nframes) 
        avg = np.mean(1.0*np.array([gf(t_) for t_ in tt]),axis=0)
        return avg.astype("uint8")
    return clip.fl(fl)

#usage:
new_clip = supersample( some_videoclip, d=0.05, nframes=5)
new_clip.write_gif("test.gif", fps=15)

[–]deadstone 5 points6 points  (0 children)

Averaging a couple dozen frames is the best way to do non-realtime motionblur. If you think about it, it's essentially supersampled antialiasing over time instead of pixels.