Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
31st March 2023, 20:12 | #1 | Link |
Chiptuner & VapourSynther
Join Date: Mar 2019
Location: Scarlet Devil Mansion, Gensōkyō
Posts: 52
|
How to chroma key one video over another in VS?
I want to overlay one video (video2) over another video (video1) & have video2’s solid-black background act as chroma key (be treated as transparent background instead) so that portions of video1 can be seen through video2. For example, I have as video1 an oscilloscope view (generated by nyanpasu64’s corrscope program) of a blue-colored waveform that only swings from 0 to positive (no negative swings = DC-biased), & I have as video2 the same waveform except it has been recolored to white & fed through a 10-Hz high-pass filter in Audacity (so that the DC bias is removed & the signal now swings from negative to positive). Now how to transparently overlay that HPF’d oscview over the DC-biased original?
__________________
SilSinn9801 a.k.a. Silent Sinner in Scarlet Discord: silsinn9801 Matrix: silsinn9821:matrix.org YouTube: https://youtube.com/SilentSinnerInScarlet ニコニコ動画: https://nicovideo.jp/user/68029427 |
31st March 2023, 20:33 | #2 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,377
|
You can use a luma mask approach , assuming your FG waveform doesn't have "black" as well
There are probably many slight variations of luma masking; here is one mwlmask in xvs func https://github.com/xyx98/my-vapoursy.../master/xvs.py |
31st March 2023, 21:10 | #3 | Link |
Chiptuner & VapourSynther
Join Date: Mar 2019
Location: Scarlet Devil Mansion, Gensōkyō
Posts: 52
|
I downloaded & copied xvs.py to the same directory where I installed havsfunc.py, mvsfunc.py, etc. to try mwlmask on my script. But now I am getting an error about rgvs not existing (even after correctly importing the necessary PY scripts) when opening my script with VirtualDub2:
Code:
Avisynth open failure: Python exception: There is no attribute or namespace named rgvs Traceback (most recent call last): File "src\cython\vapoursynth.py", line 2890, in vapoursynth._vpy_evaluate File "src\cython\vapoursynth.py", line 2891, in vapoursynth._vpy_evaluate File "D:\Users\SilSinn9821\Music\Silent Sinner in Scarlet\Test Files\SSGTEST4.VPY", line 44, in <module> CorrscopeMask = xvs.mwlmask(Corrscope2) File "C:\Program Files\Python310\lib\site-packages\xvs.py", line 1756, in mwlmask clip = clip.rgvs.RemoveGrain(4) File "src\cython\vapoursynth.pyx", line 1821, in vapoursynth.VideoNode.__getattr__ AttributeError: There is no attribute or namespace named rgvs
__________________
SilSinn9801 a.k.a. Silent Sinner in Scarlet Discord: silsinn9801 Matrix: silsinn9821:matrix.org YouTube: https://youtube.com/SilentSinnerInScarlet ニコニコ動画: https://nicovideo.jp/user/68029427 |
31st March 2023, 22:15 | #4 | Link |
Registered User
Join Date: May 2011
Posts: 321
|
If you want to go using expressions:
Code:
import vapoursynth as vs from vapoursynth import core video1 = some_source_plugin(r'C:\path\video1.png') #RGB24 video2 = some_source_plugin(r'C:\path\video2.png') #RGB24 th = 5 #if r,g,b values are all smaller than threashold (th), it is a background pixel, if not it is a mask pixel expr = f'x {th} < y {th} < and z {th} < and 0 255 ?' mask = core.std.Expr([video1.std.ShufflePlanes(plane, vs.GRAY) for plane in [0,1,2]], expr) out = core.std.MaskedMerge(video2, video1, mask=mask) out.set_output() Last edited by _Al_; 31st March 2023 at 22:26. |
31st March 2023, 22:17 | #5 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,377
|
Quote:
rgvs is from removegrain https://github.com/vapoursynth/vs-removegrain/releases |
|
Tags |
chroma key, overlay, vapoursynth |
|
|