View Full Version : Fade-in, fade-out, crossfade/transition, and video overlay on VapourSynth?
SilSinn9801
17th April 2019, 08:38
How do I implement these video effects on VapourSynth?
100-frame-long fade-in (from solid black) of a frame-repeated still image (or a video clip)
15-frame-long fade-out (to solid black) of the same still image (or video clip) above
45-frame-long crossfade (or transition) from one still image to another (or from one video clip to another)
Overlaying a video clip (or repeated image, possibly with the fade-in above first applied to it) onto another video clip (or repeated image)
Thankee!
ChaosKing
17th April 2019, 09:20
A good start would be checking these out
- FadeEachFrame, FadeOut/In: https://github.com/jeremypoulter/vsutils
- crossfade: https://github.com/Irrational-Encoding-Wizardry/kagefunc
- colorfade: https://github.com/tormaid/colorfade
- transition https://forum.doom9.org/showthread.php?t=172594
- Overlay https://github.com/HomeOfVapourSynthEvolution/havsfunc/blob/771ef4b5cac89aa985f40786e9eaf82cbdabc888/havsfunc.py#L5072
Can't provide a sample right now.
SilSinn9801
17th April 2019, 17:29
So they're Python-script libraries of functions which I would need to import into my script (with the import command?) before using them.
Thankee! This is a good start for now for a project of my own.
As for other types of clip-to-clip (or image-to-image) transitions (like blinds, dissolve, shutter, etc.) usually offered by payware video editors (like CyberLink PowerDirector), any idea if some sort of genius managed to implement them in VS?
I am also interested in some type of legacy crossfade technique used on some MS-DOS-era PC games (both IBM-PC/AT and NEC PC-9801 classes); an example of such crossfade can be found in the opening sequence of ZUN's 5th Toho game (Mystic Square), when a simple purple background (with a yin-yang orb) slowly transitions to a full artwork with the game title and a sitting miko to the left of the orb.
Tormaid
17th April 2019, 19:12
Have a look at the internal dissolve function in my colorfade script (linked above). It would work with static images looped over a range or a moving clip. Other implementations of this that I've looked at don't seem to align the input clips correctly so that the fade is linear across the entire transition (i.e. the first frame of the transition is 100% clip A and the last is 100% clip B).
SilSinn9801
29th April 2019, 21:12
A good start would be checking these out
- FadeEachFrame, FadeOut/In: https://github.com/jeremypoulter/vsutils
- crossfade: https://github.com/Irrational-Encoding-Wizardry/kagefunc
- colorfade: https://github.com/tormaid/colorfade
- transition https://forum.doom9.org/showthread.php?t=172594
- Overlay https://github.com/HomeOfVapourSynthEvolution/havsfunc/blob/771ef4b5cac89aa985f40786e9eaf82cbdabc888/havsfunc.py#L5072
Can't provide a sample right now.
Hello again, I am having troubles importing such Python scripts (I am first trying vsutils.py) into my main script. Here is what I have:
from vapoursynth import core
import vsutils as vsu
import functools
# 24-bit RGB (RGB888); using most recent version of FFMS2 to open PNG image
TSArawlogo = core.ffms2.Source(r'TeamShanghaiAlice.png')
TSArawlogoseq = TSArawlogo.std.AssumeFPS(fpsnum=60000,fpsden=1001)*339
TSAfadeinlogo = vsu.FadeIn(TSArawlogoseq,1.685)
TSAfadeoutlogo = vsu.FadeOut(TSAfadeinlogo,0.25)
# Simulate 12-bit RGB (RGB444) by integer-dividing all RGB values by 16 (#10h)
# then multiplying them by 17 (#11h)
rgb444logo = TSAfadeinlogo.std.Expr(expr=["x 16 /", "x 16 /", "x 16 /"])
rgb888logo = rgb444logo.std.Expr(expr=["x 17 *", "x 17 *", "x 17 *"])
rgb888logo.set_output()
I get this error when opening the script (which I provisionally named Danmaku.vpy) with VirtualDub2:Avisynth open failure:
Python exception: No module named 'vsutils'
Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 1927, in
vapoursynth.vpy_evaluateScript
File "src\cython\vapoursynth.pyx", line 1928, in
vapoursynth.vpy_evaluateScript
File "C:\(fakepath)\Danmaku.vpy", line 2, in <module>
import vsutils as vsu
ModuleNotFoundError: No module named 'vsutils'
I have vsutils.py stored in the same folder as all the user plugins (C:\Program Files (x86)\VapourSynth\plugins64 for x64 machines like mine). Should I load vsutils.vs from a different path? Thankee!
Cary Knoop
29th April 2019, 21:27
How do I implement these video effects on VapourSynth?
100-frame-long fade-in (from solid black) of a frame-repeated still image (or a video clip)
15-frame-long fade-out (to solid black) of the same still image (or video clip) above
45-frame-long crossfade (or transition) from one still image to another (or from one video clip to another)
Overlaying a video clip (or repeated image, possibly with the fade-in above first applied to it) onto another video clip (or repeated image)
Thankee!
I would use the right tool for the right job.
I think what you need is an NLE.
SilSinn9801
30th April 2019, 00:46
I would use the right tool for the right job.
I think what you need is an NLE.
What kind of NLE are you talking about? Because if it doesn’t let me do vintage-PC-style transitions (or restrict colors to an archaic 12-bit RGB colorspace), then it is useless to me. I have been using CyberLink PowerDirector 15 for a few years and for one project in particular I don’t want to use it (because its transitions look way too modern to me)
poisondeathray
30th April 2019, 00:51
I have vsutils.py stored in the same folder as all the user plugins (C:\Program Files (x86)\VapourSynth\plugins64 for x64 machines like mine). Should I load vsutils.vs from a different path?
put it in the python => lib => site-packages folder
SilSinn9801
30th April 2019, 03:52
put it in the python => lib => site-packages folder
I think HolyWu mentioned this on his havsfunc.py readme. I’ll give it a try and see if it works for me.
I think HolyWu mentioned this on his havsfunc.py readme. I’ll give it a try and see if it works for me.
This is a Python thing, not Vapoursynth. Dll's on the other hand belong to Vapoursynth. When importing a modul it is searched by Python in directories that are stored in sys.path. You can try yourself, run this something.py script:
import sys
print(sys.path)
it could be current directory and bunch of others.
After you install Vapoursynth you have also Vapoursynth directory in site-packages directory, so it might be a good idea to always put those py moduls into that directory.
On linux, like Ubuntu, you search for site-packages, it can be behind your home/username, down the path.
SilSinn9801
2nd May 2019, 01:50
This is a Python thing, not Vapoursynth. Dll's on the other hand belong to Vapoursynth. When importing a modul it is searched by Python in directories that are stored in sys.path. You can try yourself, run this something.py script:
import sys
print(sys.path)
it could be current directory and bunch of others.
After you install Vapoursynth you have also Vapoursynth directory in site-packages directory, so it might be a good idea to always put those py moduls into that directory.
On linux, like Ubuntu, you search for site-packages, it can be behind your home/username, down the path.
What about .VPY scripts (like YoloCR.vpy, etc.)? Shall they go into the same path as the .PY scripts?
SilSinn9801
2nd May 2019, 02:18
put it in the python => lib => site-packages folder
I put vsutils.py into the folder you told me. Now I get this new error:
Avisynth open failure:
Python exception: module 'vsutils' has no attribute 'FadeIn'
Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 1927, in
vapoursynth.vpy_evaluateScript
File "src\cython\vapoursynth.pyx", line 1928, in
vapoursynth.vpy_evaluateScript
File "C:\(fakepath)\Danmaku.vpy", line 7, in <module>
TSAfadeinlogo = vsu.FadeIn(TSArawlogoseq,1.685)
ModuleNotFoundError: module 'vsutils' has no attribute 'FadeIn'
What am I doing wrong now?
What about .VPY scripts (like YoloCR.vpy, etc.)? Shall they go into the same path as the .PY scripts?
.vpy is just vapoursynth script, not Python script, but you can name them .py and using them as a modul , importing them, but then you'd need to follow other python "stuff" to get output or use its functions, attributes. The key is to learn Python and then it just comes together.
But .py is not understood by VirtualDub2 for example, only .vpy . vspipe has no problem with .py
import vsutils as vsu
TSAfadeinlogo = vsu.FadeIn(TSArawlogoseq,1.685)
ModuleNotFoundError: module 'vsutils' has no attribute 'FadeIn'
in Python it means, that vsutils.py have to have function FadeIn:
def FadeIn(....):
is it in there? It is also case sensitive.
edit: I just downloaded vsutils.py and that has a Class vsutils, so try to instantiate that Class first and then call it:
my_edits = vsu.vsutils()
TSAfadeinlogo = my_edits.FadeIn(TSArawlogoseq,1.685)
SilSinn9801
2nd May 2019, 04:58
in Python it means, that vsutils.py have to have function FadeIn:
def FadeIn(....):
is it in there? It is also case sensitive.
edit: I just downloaded vsutils.py and that has a Class vsutils, so try to instantiate that Class first and then call it:
my_edits = vsu.vsutils()
TSAfadeinlogo = my_edits.FadeIn(TSArawlogoseq,1.685)
Just did your suggestion and now it works! Thankee! Now I can finish my secret project for Reitaisai!
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.