forked from Selur/VapoursynthScriptsInHybrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fade.py
26 lines (24 loc) · 976 Bytes
/
fade.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import vapoursynth as vs
core = vs.core
# based on: http://forum.doom9.org/archive/index.php/t-165771-p-4.html
def fadeout(inputClip, fadeframes):
beginframes = inputClip.num_frames-1 - fadeframes
blank = core.std.BlankClip(clip=inputClip, length=1)
fade_frames = []
for i in range(inputClip.num_frames):
if (i <= beginframes) :
fade_frames.append(inputClip[i])
else :
fade_frames.append(core.std.Merge(clipa=inputClip[i], clipb=blank, weight=[(i-beginframes)/fadeframes]))
fade_output = core.std.Splice(clips=fade_frames)
return fade_output
def fadein(inputClip, fadeframes):
blank = core.std.BlankClip(clip=inputClip, length=1)
fade_frames = []
for i in range(inputClip.num_frames):
if (i > fadeframes) :
fade_frames.append(inputClip[i])
else :
fade_frames.append(core.std.Merge(clipa=inputClip[i], clipb=blank, weight=[(fadeframes-i)/fadeframes]))
fade_output = core.std.Splice(clips=fade_frames)
return fade_output