Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ping-pong analyzer script for /r/perfectloops
Function TrimLoop(Clip clip)
{
clip
# delete first frame if clip has an even frame count
DeleteFrame(0)
# optional: delete duplicate frame in the middle
#DeleteFrame(FrameCount / 2)
return last
}
Function CreateForward(Clip clip)
{
clip
Subtitle("Forward")
ShowFrameNumber(x = 8, y = Height - 8)
TrimLoop()
return last
}
Function CreateReverse(Clip clip)
{
clip
Subtitle("Reverse")
ShowFrameNumber(x = 8, y = Height - 8)
TrimLoop()
Reverse()
return last
}
Function CreateDifference(Clip clip)
{
clip
TrimLoop()
Subtract(Reverse())
Subtitle("Difference")
return last
}
Function ResizeByWidth(Clip clip, int width, String "algo")
{
algo = Default(algo, "Lanczos4")
height = Floor(clip.height * width / clip.width)
return Eval("clip." + algo + "Resize(width, height)")
}
Function PingPongAnalyze(Clip clip, int baseWidth)
{
clip
ConvertToRGB24()
forward = ResizeByWidth(baseWidth / 2).CreateForward()
reverse = ResizeByWidth(baseWidth / 2).CreateReverse()
difference = ResizeByWidth(baseWidth).CreateDifference()
return StackVertical(StackHorizontal(forward, reverse), difference)
}
#AVISource("video.avi")
FFVideoSource("video.mp4")
PingPongAnalyze(640)
# crop to mod16 for better codec compatibility
Crop(0, 0, -(Width % 16), -(Height % 16))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.