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. |
3rd May 2019, 03:29 | #1 | Link |
Chiptuner & VapourSynther
Join Date: Mar 2019
Location: Scarlet Devil Mansion, Gensōkyō
Posts: 52
|
Transparent overlay on VapourSynth?
I am using vsutils.py to try to overlay a sequence of transparent-background PNG visual effects on top of an opaque PNG logo screen:
Code:
from vapoursynth import core import vsutils as vsu import functools import sys vsufuncs = vsu.vsutils() # Background logo # 24-bit RGB (RGB888); using most recent version of FFMS2 to open PNG image rawlogo = core.ffms2.Source(r'logo.png') rawlogoframe = rawlogo.std.AssumeFPS(fpsnum=60000,fpsden=1001) blackframe = rawlogoframe.std.BlankClip() blackframeseq1 = blackframe*150 rawlogoseq = rawlogoframe*339 blackframeseq2 = blackframe*20 fadeinlogo = vsufuncs.FadeIn(rawlogoseq,1.685) fadeoutlogo = vsufuncs.FadeOut(fadeinlogo,0.25) logo = blackframeseq1+fadeoutlogo+blackframeseq2 # Overlaid VFX; 32-bit RGB+alpha (ARGB8888) vfx00 = core.ffms2.Source(r'VFX__000.PNG')*118 vfx01 = core.ffms2.Source(r'VFX__118.PNG')*8 vfx02 = core.ffms2.Source(r'VFX__126.PNG')*18 vfx03 = core.ffms2.Source(r'VFX__144.PNG')*2 vfx04 = core.ffms2.Source(r'VFX__146.PNG')*2 vfx05 = core.ffms2.Source(r'VFX__148.PNG')*2 vfx06 = core.ffms2.Source(r'VFX__150.PNG')*2 vfx07 = core.ffms2.Source(r'VFX__152.PNG')*2 vfx08 = core.ffms2.Source(r'VFX__154.PNG')*2 vfx09 = core.ffms2.Source(r'VFX__156.PNG')*2 vfx10 = core.ffms2.Source(r'VFX__158.PNG')*2 vfx11 = core.ffms2.Source(r'VFX__160.PNG')*4 vfx12 = core.ffms2.Source(r'VFX__164.PNG')*2 vfx13 = core.ffms2.Source(r'VFX__166.PNG')*2 vfx14 = core.ffms2.Source(r'VFX__168.PNG')*2 vfx15 = core.ffms2.Source(r'VFX__170.PNG')*2 vfx16 = core.ffms2.Source(r'VFX__172.PNG')*2 vfx17 = core.ffms2.Source(r'VFX__174.PNG')*2 vfx18 = core.ffms2.Source(r'VFX__176.PNG')*2 vfx19 = core.ffms2.Source(r'VFX__178.PNG')*2 vfx20 = core.ffms2.Source(r'VFX__180.PNG')*2 vfx21 = core.ffms2.Source(r'VFX__182.PNG')*2 vfx22 = core.ffms2.Source(r'VFX__184.PNG')*2 vfx23 = core.ffms2.Source(r'VFX__186.PNG')*2 vfx24 = core.ffms2.Source(r'VFX__188.PNG')*2 vfx25 = core.ffms2.Source(r'VFX__190.PNG')*2 vfx26 = core.ffms2.Source(r'VFX__192.PNG')*4 vfx27 = core.ffms2.Source(r'VFX__196.PNG')*2 vfx28 = core.ffms2.Source(r'VFX__198.PNG')*2 vfx29 = core.ffms2.Source(r'VFX__200.PNG')*2 vfx30 = core.ffms2.Source(r'VFX__202.PNG')*2 vfx31 = core.ffms2.Source(r'VFX__204.PNG')*2 vfx32 = core.ffms2.Source(r'VFX__206.PNG')*3 vfx33 = core.ffms2.Source(r'VFX__210.PNG')*2 vfx34 = core.ffms2.Source(r'VFX__211.PNG')*2 vfx35 = core.ffms2.Source(r'VFX__213.PNG')*2 vfx36 = core.ffms2.Source(r'VFX__215.PNG')*4 vfx37 = core.ffms2.Source(r'VFX__219.PNG')*2 vfx38 = core.ffms2.Source(r'VFX__221.PNG')*4 vfx39 = core.ffms2.Source(r'VFX__225.PNG')*2 vfx40 = core.ffms2.Source(r'VFX__227.PNG')*2 vfx41 = core.ffms2.Source(r'VFX__229.PNG')*2 vfx42 = core.ffms2.Source(r'VFX__231.PNG')*2 vfx43 = core.ffms2.Source(r'VFX__233.PNG')*4 vfx44 = core.ffms2.Source(r'VFX__237.PNG')*2 vfx45 = core.ffms2.Source(r'VFX__239.PNG')*2 vfx46 = core.ffms2.Source(r'VFX__242.PNG')*2 vfx47 = core.ffms2.Source(r'VFX__243.PNG')*2 vfx48 = core.ffms2.Source(r'VFX__245.PNG')*2 vfx49 = core.ffms2.Source(r'VFX__247.PNG')*4 vfx50 = core.ffms2.Source(r'VFX__251.PNG')*2 vfx51 = core.ffms2.Source(r'VFX__253.PNG')*2 vfx52 = core.ffms2.Source(r'VFX__255.PNG')*2 vfx53 = core.ffms2.Source(r'VFX__257.PNG')*2 vfx54 = core.ffms2.Source(r'VFX__259.PNG')*2 vfx55 = core.ffms2.Source(r'VFX__261.PNG')*2 vfx56 = core.ffms2.Source(r'VFX__263.PNG')*4 vfx57 = core.ffms2.Source(r'VFX__267.PNG')*2 vfx58 = core.ffms2.Source(r'VFX__269.PNG')*2 vfx59 = core.ffms2.Source(r'VFX__271.PNG')*2 vfx60 = core.ffms2.Source(r'VFX__273.PNG')*2 vfx61 = core.ffms2.Source(r'VFX__275.PNG')*2 vfx62 = core.ffms2.Source(r'VFX__277.PNG')*2 vfx63 = core.ffms2.Source(r'VFX__279.PNG')*4 vfx64 = core.ffms2.Source(r'VFX__283.PNG')*4 vfx65 = core.ffms2.Source(r'VFX__287.PNG')*2 vfx66 = core.ffms2.Source(r'VFX__289.PNG')*2 vfx67 = core.ffms2.Source(r'VFX__291.PNG')*2 vfx68 = core.ffms2.Source(r'VFX__293.PNG')*2 vfx69 = core.ffms2.Source(r'VFX__295.PNG')*2 vfx70 = core.ffms2.Source(r'VFX__297.PNG')*2 vfx71 = core.ffms2.Source(r'VFX__299.PNG')*3 vfx72 = core.ffms2.Source(r'VFX__302.PNG')*3 vfx73 = core.ffms2.Source(r'VFX__305.PNG')*2 vfx74 = core.ffms2.Source(r'VFX__307.PNG')*3 vfx75 = core.ffms2.Source(r'VFX__310.PNG')*2 vfx76 = core.ffms2.Source(r'VFX__312.PNG')*2 vfx77 = core.ffms2.Source(r'VFX__314.PNG')*2 vfx78 = core.ffms2.Source(r'VFX__316.PNG')*2 vfx79 = core.ffms2.Source(r'VFX__318.PNG')*4 vfx80 = core.ffms2.Source(r'VFX__322.PNG')*2 vfx81 = core.ffms2.Source(r'VFX__324.PNG')*2 vfx82 = core.ffms2.Source(r'VFX__326.PNG')*4 vfx83 = core.ffms2.Source(r'VFX__330.PNG')*2 vfx84 = core.ffms2.Source(r'VFX__332.PNG')*2 vfx85 = core.ffms2.Source(r'VFX__334.PNG')*4 vfx86 = core.ffms2.Source(r'VFX__338.PNG')*2 vfx87 = core.ffms2.Source(r'VFX__000.PNG')*169 vfxseq = vfx00+vfx01+vfx02+vfx03+vfx04+vfx05+vfx06+vfx07+vfx08+vfx09+ \ vfx10+vfx11+vfx12+vfx13+vfx14+vfx15+vfx16+vfx17+vfx18+vfx19+ \ vfx20+vfx21+vfx22+vfx23+vfx24+vfx25+vfx26+vfx27+vfx28+vfx29+ \ vfx30+vfx31+vfx32+vfx33+vfx34+vfx35+vfx36+vfx37+vfx38+vfx39+ \ vfx40+vfx41+vfx42+vfx43+vfx44+vfx45+vfx46+vfx47+vfx48+vfx49+ \ vfx50+vfx51+vfx52+vfx53+vfx54+vfx55+vfx56+vfx57+vfx58+vfx59+ \ vfx60+vfx61+vfx62+vfx63+vfx64+vfx65+vfx66+vfx67+vfx68+vfx69+ \ vfx70+vfx71+vfx72+vfx73+vfx74+vfx75+vfx76+vfx77+vfx78+vfx79+ \ vfx80+vfx81+vfx82+vfx83+vfx84+vfx85+vfx86+vfx87 vfx = vfxseq.std.AssumeFPS(fpsnum=60000,fpsden=1001) # Overlay VFX on top of background logo finallogo = vsufuncs.Overlay(logo,vfx,0,0) finallogo.set_output() Any insights on this? Maybe shall I use raw code rather than Overlay() and extract different mask data for the VFX overlay? |
3rd May 2019, 03:50 | #2 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,374
|
I don't know about vsutils' Overlay , but havsfunc's Overlay works like this (basically the same as avisynth's Overlay):
Overlay using transparency requires you to specify the alpha channel mask But in vapoursynth for RGBA , the [0] is for the RGB channels , [1] is for the alpha (different than avisynth) Overlay order is the base layer first , then the overlay on top ie. overlay(base, top) . Code:
. . . import havsfunc as haf . . . final = haf.Overlay( logo, vfx[0], mask=vfx[1]) final.set_output() Last edited by poisondeathray; 3rd May 2019 at 03:58. |
3rd May 2019, 04:00 | #3 | Link | |
Chiptuner & VapourSynther
Join Date: Mar 2019
Location: Scarlet Devil Mansion, Gensōkyō
Posts: 52
|
Quote:
|
|
3rd May 2019, 04:02 | #4 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,374
|
This works on standard RGBA and RGB images or video (8bit)
It might be an alpha interpretation issue for you Can you see the alpha channel when you return [1] ? It should be black/white This should show the alpha vfx[1].set_output() This should show the RGB as what you see normally, but without transparency (black where transparent should be) vfx[0].set_output() Upload 1 image of each, logo.png, and VFX__118.PNG (or choose one that you can see something) Last edited by poisondeathray; 3rd May 2019 at 04:06. |
3rd May 2019, 04:08 | #6 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,374
|
Quote:
(Yes , I got the wrong order first, because usually "logo" is on top,like you know...a logo... but you're actually using it as the background) Check my edit above with viewing the alpha channel directly |
|
3rd May 2019, 04:11 | #7 | Link | |
Chiptuner & VapourSynther
Join Date: Mar 2019
Location: Scarlet Devil Mansion, Gensōkyō
Posts: 52
|
Quote:
Also, trying vfx[1].set_output() got me a single solid-black frame (rather than a sequence of frames). Trying vfx[0].set_output() also got me a single solid-black frame. |
|
3rd May 2019, 04:13 | #8 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,374
|
Quote:
This means you don't have a valid alpha channel. Perhaps that version of ffms2 isn't reading it correctly |
|
3rd May 2019, 04:15 | #9 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,374
|
For example, newer ffms2 versions do not read the alpha correctly in PNG or MOV
eg. ffms2-20190326 from WolfBerry does not work here on my local test with different images But really old versions work, such as ffms2-2.23-clang , or ImageMagick for PNG RGBA sequences |
3rd May 2019, 04:16 | #10 | Link | |
Chiptuner & VapourSynther
Join Date: Mar 2019
Location: Scarlet Devil Mansion, Gensōkyō
Posts: 52
|
Quote:
https://drive.google.com/open?id=1m_...0Kdx1a6MAjOXCI |
|
3rd May 2019, 04:19 | #11 | Link | |
Chiptuner & VapourSynther
Join Date: Mar 2019
Location: Scarlet Devil Mansion, Gensōkyō
Posts: 52
|
Quote:
|
|
3rd May 2019, 04:24 | #12 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,374
|
Works ok with old ffms2 (ffms2-2.23-clang)
Code:
vfx = core.ffms2.Source(r'VFX__172.PNG') logo = core.ffms2.Source(r'Logo.png') o = haf.Overlay(logo[0], vfx[0], mask=vfx[1]) o.set_output() (This is why I keep like 20 ffms2 versions around) |
3rd May 2019, 04:43 | #14 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,374
|
Each version has various quirks. About 19 other ffms2 versions don't work correctly with PNG or MOV RGBA
I can't find the original github release from way back . Looks like it was taken down and replaced with ffms2-2.23.1-msvc (which doesn't work here either) . But it might mean there are other issues with that build https://github.com/FFMS/ffms2/releases Lucky for you I have them saved on a HDD somewhere for exactly these scenarios https://www.mediafire.com/file/ug0mq...-clang.7z/file |
3rd May 2019, 04:51 | #15 | Link | |
Chiptuner & VapourSynther
Join Date: Mar 2019
Location: Scarlet Devil Mansion, Gensōkyō
Posts: 52
|
I am trying that old ffms2 and now I get some errors:
Quote:
|
|
3rd May 2019, 04:54 | #16 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,374
|
Quote:
try core.std.AssumeFPS eg. rawlogoframe = core.std.AssumeFPS(rawlogo, fpsnum=60000,fpsden=1001) Did you try the 2 test image simple script above first ? Does it look like what you expect ? |
|
3rd May 2019, 05:04 | #17 | Link | ||
Chiptuner & VapourSynther
Join Date: Mar 2019
Location: Scarlet Devil Mansion, Gensōkyō
Posts: 52
|
Quote:
Quote:
The two-test script worked fine, with vfx[0] giving me the normal image and vfx[1] giving me the alpha represented as black. Last edited by SilSinn9801; 3rd May 2019 at 05:16. Reason: I get the same error even with the alpha=TRUE edit on Wolfberry version (re: HolyWu) |
||
3rd May 2019, 05:06 | #18 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,374
|
Quote:
Confirmed for ffms2-20190326 from WolfBerry (not sure if it's the "newest") |
|
3rd May 2019, 05:06 | #19 | Link |
Chiptuner & VapourSynther
Join Date: Mar 2019
Location: Scarlet Devil Mansion, Gensōkyō
Posts: 52
|
Which of the Wolfberry versions, the one released on March 23 or 26, or the one released now on April 27? Because the April release is crashing my VirtualBox2 setup; the March release ran fine for me.
|
3rd May 2019, 05:11 | #20 | Link | ||
Registered User
Join Date: Sep 2007
Posts: 5,374
|
Quote:
Quote:
If you're loading both (it will be a "dummy" alpha) . Since you want the RGB background, it should be [0] rawlogoframe = core.std.AssumeFPS(rawlogo[0],fpsnum=60000,fpsden=1001) |
||
Tags |
overlay, transparency, transparent, vapoursynth, vsutils |
Thread Tools | Search this Thread |
Display Modes | |
|
|