Skip to content

Instantly share code, notes, and snippets.

@ZoomTen
Created April 16, 2019 10:55
Show Gist options
  • Save ZoomTen/05f33396128a86c3f20adf9852ffc803 to your computer and use it in GitHub Desktop.
Save ZoomTen/05f33396128a86c3f20adf9852ffc803 to your computer and use it in GitHub Desktop.

slomo.vpy

from vapoursynth import core

# vf is set in view/render script, points to video file in current directory
source = core.ffms2.Source(vf)
msuper = core.mv.Super(source, pel=2)

# analyze motion vectors
back = core.mv.Analyse(msuper,blksize=8, overlap=2, isb=True, search=3)
fwd = core.mv.Analyse(msuper,blksize=8, overlap=2, isb=False,search=3)

# take motion vectors and interpolate to ~60fps
video = core.mv.FlowFPS(source,msuper,back,fwd,num=60000,den=1001,ml=100)

# play back at 24fps
slomo = core.std.AssumeFPS(video,fpsnum=24000,fpsden=1001)

slomo.set_output()

viewing

vspipe --y4m slomo.vpy --arg "vf=videofile.avi" - | ffplay -i -

rendering

vspipe --y4m slomo.vpy --arg "vf=videofile.avi" - | ffmpeg -i - video_slowmoed.mkv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment