Log in

View Full Version : PNG image how to enable transparency ?


xbox360
8th July 2008, 08:53
I have a .PNG with transparency that I am overlaying on my video, using this script:

SetMemoryMax(256)

LoadPlugin("c:\Program Files (x86)\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("c:\Program Files (x86)\AviSynth 2.5\plugins\kerneldeint.dll")
Import("c:\Program Files (x86)\AviSynth 2.5\plugins\LimitedSharpen.avsi")

C = mpeg2source("D:\EncodingStuff\VR_MOVIE.d2v")
c.KernelDeint(order=0)
Letterbox(2,2,0,0,0)
LimitedSharpen( ss_x=2.0, ss_y=2.0, Smode=2)
FFT3DFilter(sigma=3)

logo = JDL_ImageSource("d:/assrender.png", fps=c.FrameRate())

Overlay(logo, x=0, y=0)

but the script outputs an image overlay with no transparency. How do I enable image transparency for my PNG overlay ?

Wilbert
8th July 2008, 09:06
You need to modify JDL_ImageSource (to include pixel_type), or use ImageSource.

xbox360
8th July 2008, 09:09
ImageSource does not work !

Gavino
8th July 2008, 09:26
Overlay does not use the alpha channel explicitly. You need to use

Overlay(logo, x=0, y=0, mask=logo.ShowAlpha)

xbox360
8th July 2008, 09:39
Im using:

SetMemoryMax(256)

LoadPlugin("c:\Program Files (x86)\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("c:\Program Files (x86)\AviSynth 2.5\plugins\kerneldeint.dll")
Import("c:\Program Files (x86)\AviSynth 2.5\plugins\LimitedSharpen.avsi")

C = mpeg2source("D:\EncodingStuff\VR_MOVIE.d2v")
c.KernelDeint(order=0)
Letterbox(2,2,0,0,0)
LimitedSharpen( ss_x=2.0, ss_y=2.0, Smode=2)
FFT3DFilter(sigma=3)

logo = ImageSource("d:/dtsrender.png", fps=c.FrameRate()).converttorgb32

Overlay(logo, x=0, y=0, mask=logo.ShowAlpha)

still no diference

Gavino
8th July 2008, 10:08
logo = ImageSource("d:/dtsrender.png", fps=c.FrameRate()).converttorgb32

You are throwing away the transparency and putting an opaque image in its place. Do this:

logo = ImageSource("d:/dtsrender.png", fps=c.FrameRate(), pixel_type="RGB32")

stickboy
8th July 2008, 10:12
You need to modify JDL_ImageSource (to include pixel_type), or use ImageSource.JDL_ImageSource automatically sets pixel_type="rgb32" (and falls back if it's unsupported).

Anyway,
video = ColorBars()
logo = JDL_ImageSource("avisynth-logo-gears-mod.png")
Overlay(video, logo, x=0, y=0, mask=logo.ShowAlpha())works for me with the AviSynth logo image (http://avisynth.org/images/avisynth-logo-gears-mod.png).

If it's still not working for you, please post the PNG you're trying to use.

xbox360
8th July 2008, 10:36
Im using:

SetMemoryMax(256)

LoadPlugin("c:\Program Files (x86)\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("c:\Program Files (x86)\AviSynth 2.5\plugins\kerneldeint.dll")
Import("c:\Program Files (x86)\AviSynth 2.5\plugins\LimitedSharpen.avsi")

C = mpeg2source("D:\EncodingStuff\VR_MOVIE.d2v")
c.KernelDeint(order=0)
Letterbox(2,2,0,0,0)
LimitedSharpen( ss_x=2.0, ss_y=2.0, Smode=2)
FFT3DFilter(sigma=3)

logo = ImageSource("d:/assrender.png", pixel_type="RGB32")

Overlay(logo, x=0, y=0, mask=logo.ShowAlpha())

& It Works Perfectly ! Thank You for helping !

xbox360
9th July 2008, 06:22
I have a problem. My script is this:

SetMemoryMax(256)

LoadPlugin("c:\Program Files (x86)\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("c:\Program Files (x86)\AviSynth 2.5\plugins\kerneldeint.dll")
Import("c:\Program Files (x86)\AviSynth 2.5\plugins\LimitedSharpen.avsi")

C = mpeg2source("D:\EncodingStuff\VR_MOVIE.d2v")
c.KernelDeint(order=0)
Lanczos4Resize(720,576,0,72,-0,-72)
LimitedSharpen( ss_x=2.0, ss_y=2.0, Smode=2)
FFT3DFilter(sigma=3)

logo = ImageSource("d:/assrender.png", pixel_type="RGB32")

Overlay(logo, x=0, y=0, mask=logo.ShowAlpha())

Now when I encode with 16:9 flag the logo's height get's compressed, how to avoid this ?

IanB
9th July 2008, 08:26
You will need to resize your logo to match the pixel aspect ratio of your source....
logo = logo.Spline36Resize(logo.Width(), logo.Height()*4/3)
...

Hint :- If you click the Edit button there is an option to delete your duplicate post.

NerdWithNoLife
9th July 2008, 14:40
ImageSource doesn't work for a png? What does it say? Because I would do something like:
SetMemoryMax(256)

LoadPlugin("c:\Program Files (x86)\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("c:\Program Files (x86)\AviSynth 2.5\plugins\kerneldeint.dll")
Import("c:\Program Files (x86)\AviSynth 2.5\plugins\LimitedSharpen.avsi")

C = mpeg2source("D:\EncodingStuff\VR_MOVIE.d2v").\
KernelDeint(order=0).Letterbox(2,2,0,0,0).\
LimitedSharpen( ss_x=2.0, ss_y=2.0, Smode=2).FFT3DFilter(sigma=3).ConvertToRGB32()

logo = ImageSource("d:/assrender.png",pixel_type="RGB32").AssumeFPS(c)

Layer(c,logo,"add",255)
And yes, you may need to resize to make them have the same properties.

Edit: Well, I see you resolved it after reading more carefully. There's more than one way to skin a cat, I suppose... maybe this could help someone though.