Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_plane_size(self):
self.assertEqual((160, 120), vsutil.get_plane_size(self.YUV420P8_CLIP, 0))
self.assertEqual((80, 60), vsutil.get_plane_size(self.YUV420P8_CLIP, 1))
# these should fail because they don’t have a constant format or size
with self.assertRaises(ValueError):
vsutil.get_plane_size(
vs.core.std.Splice([self.BLACK_SAMPLE_CLIP, self.SMALLER_SAMPLE_CLIP], mismatch=True), 0)
with self.assertRaises(ValueError):
vsutil.get_plane_size(
vs.core.std.Splice([self.YUV444P8_CLIP, self.YUV422P8_CLIP], mismatch=True), 0)
def GetClip(filelist, balpha, mis = False):
#Returns a VapourSynth clip and alpha clip containing images from filelist
#Clips need to be spliced together like this to support images with multiple resolutions
if balpha == True:
clip, alphaclip = core.imwri.Read(filelist[0], mismatch=False, alpha=True)
if len(filelist) > 1:
filelist = filelist[1:]
for file in filelist:
singleclip, singlealphaclip = core.imwri.Read(file, mismatch=False, alpha=True)
clip = core.std.Splice([clip, singleclip], mismatch = mis)
alphaclip = core.std.Splice([alphaclip, singlealphaclip], mismatch = mis)
return clip, alphaclip
else:
clip = core.imwri.Read(filelist[0], mismatch=False, alpha=False)
if len(filelist) > 1:
filelist = filelist[1:]
for file in filelist:
singleclip = core.imwri.Read(file, mismatch=False, alpha=False)
clip = core.std.Splice([clip, singleclip], mismatch = mis)
return clip, core.std.BlankClip(clip, length = clip.num_frames)
if balpha == True:
clip, alphaclip = core.imwri.Read(filelist[0], mismatch=False, alpha=True)
if len(filelist) > 1:
filelist = filelist[1:]
for file in filelist:
singleclip, singlealphaclip = core.imwri.Read(file, mismatch=False, alpha=True)
clip = core.std.Splice([clip, singleclip], mismatch = mis)
alphaclip = core.std.Splice([alphaclip, singlealphaclip], mismatch = mis)
return clip, alphaclip
else:
clip = core.imwri.Read(filelist[0], mismatch=False, alpha=False)
if len(filelist) > 1:
filelist = filelist[1:]
for file in filelist:
singleclip = core.imwri.Read(file, mismatch=False, alpha=False)
clip = core.std.Splice([clip, singleclip], mismatch = mis)
return clip, core.std.BlankClip(clip, length = clip.num_frames)
def GetClip(filelist, balpha, mis = False):
#Returns a VapourSynth clip and alpha clip containing images from filelist
#Clips need to be spliced together like this to support images with multiple resolutions
if balpha == True:
clip, alphaclip = core.imwri.Read(filelist[0], mismatch=False, alpha=True)
if len(filelist) > 1:
filelist = filelist[1:]
for file in filelist:
singleclip, singlealphaclip = core.imwri.Read(file, mismatch=False, alpha=True)
clip = core.std.Splice([clip, singleclip], mismatch = mis)
alphaclip = core.std.Splice([alphaclip, singlealphaclip], mismatch = mis)
return clip, alphaclip
else:
clip = core.imwri.Read(filelist[0], mismatch=False, alpha=False)
if len(filelist) > 1:
filelist = filelist[1:]
for file in filelist:
singleclip = core.imwri.Read(file, mismatch=False, alpha=False)
clip = core.std.Splice([clip, singleclip], mismatch = mis)
return clip, core.std.BlankClip(clip, length = clip.num_frames)
start = start + clip.num_frames
if not nopreview: #pad the clip with borders
if fullclip.format != clip.format:
fullclip = core.std.BlankClip(clip, length = 1)
if clip.width > fullclip.width:
fullclip = core.std.AddBorders(fullclip, right = clip.width - fullclip.width)
if clip.height > fullclip.height:
fullclip = core.std.AddBorders(fullclip, bottom = clip.height - fullclip.height)
if clip.width < fullclip.width:
clip = core.std.AddBorders(clip, right = fullclip.width - clip.width)
if clip.height < fullclip.height:
clip = core.std.AddBorders(clip, bottom = fullclip.height - clip.height)
#Splice everything into a uniform clip for previewing
fullclip = fullclip + core.std.AssumeFPS(clip, fpsnum = 1)
else:
fullclip = core.std.Splice([fullclip, clip], mismatch = 1)
fullclip = core.std.DeleteFrames(fullclip, [0])
return fullclip
else:
raise Exception('No input data!')