Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Sets up race grid
- function RaceGrid(clip c1, clip c2, clip c3, clip c4, int start)
- {
- border = 15
- StackVertical(StackHorizontal(c1.AddBorders(0, 0, border, border), c2.AddBorders(0, 0, 0, border)), StackHorizontal(c3.AddBorders(0, 0, border, 0), c4))
- ShowTime(offset_f=-start, x=Width(last)/2, y=Height(last)/2+13, size=18.0, text_color=$00FFFFFF, font="Arial")
- }
- # Standardized subtitle
- function HeaderText(clip c, string text, int align, int x, int y, int "start", int "end")
- {
- start = Default(start, 0)
- end = Default(end, FrameCount(c)-1)
- Subtitle(c, text, align=align, size=20.0, text_color=$00FFFFFF, font="Upheaval TT (BRK)", x=x, y=y, first_frame=start, last_frame=end)
- }
- # Prepare race video
- function Race(clip video, string name, bool detect, bool top)
- {
- # Normalize video format
- height = 640.0 / Width(video) * Height(video)
- video = video.ChangeFPS(30).BilinearResize(640, Int(height))
- trim = (360 - Height(video)) / 2
- video = (trim > 0) ? video.Crop(0, trim, 0, -trim) : video.AddBorders(0, trim, 0, trim)
- # Add header
- header = ImageSource("..\header.png", 0, FrameCount(video)-1, 30).ConvertToYV12()
- video = top ? StackVertical(header, video) : StackVertical(video, header)
- global levelX = 32
- global deathX = Width(video)-38
- global headerY = top ? 0 : Height(video)-24
- video = video.HeaderText(name, 8, -1, headerY)
- # Detect death and level transitions
- global levelString = "2-%.0fX"
- global bossString = "2-BOSS"
- global deathString = "%.0f"
- global levelLuma = 18.0
- global levelLength = 6
- global deathDiff = 10.0
- global deathLuma = 25.0
- global deathLength = 1
- global started = true
- global levelTransition = false
- global deathTransition = false
- global levelDuration = 0
- global deathDuration = 0
- global deaths = 0
- global level = 1
- detect ?\
- ScriptClip(video,"""diff = YDifferenceFromPrevious()
- luma = AverageLuma()
- deathTransition = (diff > deathDiff && luma < deathLuma)
- levelTransition = (luma < levelLuma && !deathTransition)
- level = (!levelTransition && levelDuration >= levelLength && levelDuration <= levelLength*3) ? level + 1 : level
- deaths = (!deathTransition && deathDuration == deathLength) ? deaths + 1 : deaths
- levelDuration = (levelTransition) ? levelDuration + 1 : 0
- deathDuration = (deathTransition) ? deathDuration + 1 : 0
- HeaderText(String(level, levelString), 7, levelX, headerY)
- HeaderText(String(deaths, deathString), 7, deathX, headerY)"""):\
- video.HeaderText("-", 7, levelX, headerY).HeaderText("-", 7, deathX, headerY)
- #ScriptClip(video, """Subtitle("diff:"+String(YDifferenceFromPrevious)+" avg:"+String(AverageLuma), y=30)""")
- }
Add Comment
Please, Sign In to add comment