Created
February 20, 2016 00:25
-
-
Save ata4/b19ebff0bc5ecd7aeb9f to your computer and use it in GitHub Desktop.
Ping-pong analyzer script for /r/perfectloops
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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