Skip to content

Instantly share code, notes, and snippets.

@kgrabs
Created January 23, 2018 23:02
Show Gist options
  • Save kgrabs/ed491813e655297a5a07a0743f6c4331 to your computer and use it in GitHub Desktop.
Save kgrabs/ed491813e655297a5a07a0743f6c4331 to your computer and use it in GitHub Desktop.
# paste this all into a Vapoursynth Editor window
# replace the variables w/h, frames, paths
# optionally define separate start frames or subtitle files
# protip: set "showsubs = frames" to display subs on every frame
# hit F7 and wait for the Benchmark mini-window to pop up
# hit Enter and let the script run
# the screenshots will be in the folder of the first path in paths
w, h = 1920, 1080
frames = [24, 192, 9465, 32245]
showsubs = [192, 32245]
paths = [r'C:\[Group1] Show - 00 [CRC32].mkv']
start = [0] # start on frame number n
subs = [None] # .ass file path
paths+= [r'C:\[Group2] Show - 00 [CRC32].mkv']
start+= [0]
subs += [None]
paths+= [r'C:\[Group3] Show - 00 [CRC32].mkv']
start+= [0]
subs += [None]
paths+= [r'C:\[Group4] Show - 00 [CRC32].mkv']
start+= [0]
subs += [None]
paths+= [r'C:\[Group5] Show - 00 [CRC32].mkv']
start+= [0]
subs += [None]
#####################
from vapoursynth import core, RGBS, YUV444PS
outpath = paths[0].split('\\')
outpath = [i+'/' for i in outpath[:len(outpath)-1]]
outpath = ''.join(outpath)
#outpath = r'C:\Show Title\Screenshots\'
def getmatrix(clip):
if clip.width <= 1024 and clip.height <= 576:
return 6
if clip.width <= 2048 and clip.height <= 1536:
return 1
return 9
shots, clip_subs = [core.std.BlankClip(None, w, h, RGBS, 1)] * 2
for i in range(len(paths)):
if paths[i].endswith('.m2ts'):
clip_o = core.lsmas.LWLibavSource(paths[i])
else:
clip_o = core.ffms2.Source(paths[i])
clip = core.resize.Spline36(clip_o, w, h, format=YUV444PS)
if subs[i] is not None:
clip_subs = core.sub.TextFile(clip, subs[i])[start[i]:]
clip_subs = core.resize.Point(clip_subs, format=RGBS,prefer_props=1,matrix_in=getmatrix(clip_o))
clip = core.resize.Point(clip, format=RGBS,prefer_props=1,matrix_in=getmatrix(clip_o))[start[i]:]
title = paths[i].split('\\')[-1]
for n in frames:
clipn = clip_subs if n in showsubs and subs[i] is not None else clip
shots = shots + clipn[n].text.Text(title,7).text.Text(str(n+start[i]),9).imwri.Write('PNG', outpath+'{}__'.format(n)+title+'%d.png', 0, 0)
shots[1:].set_output()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment