Log in

View Full Version : Overlaying an image


vlada
20th September 2006, 13:13
Hello,

in AviSynth I'd like to overlay an image over a video. The image is a .png with alpha channel. I wnat to use a fade-in and fade-out effect for the image. I created aother image, which contains alpha channel converted to greyscale (using GIMP). I made a script that works, but I think it is unnecessary complicated. The script looks like this:


video=AviSource("movie.avi")
image=ImageSource("image.png",fps=25).ConvertToRGB32
image_mask=ImageSource("image_mask.png",fps=25).ConvertToRGB32
image2=Mask(image,image_mask)
image3=Trim(image2,0,340)
image4=FadeIO(image3,25)
video1=Trim(video2,0,999)
video2=Trim(video2,1000,1339)
video3=Trim(image2,1340,2000)
video2b=Overlay(video2,image3,mask=ShowAlpha(image4),mode="blend")
video1++video2b++video3


Can I make it somehow easier? Thank you.

Guest
20th September 2006, 13:45
You create video2b and then don't use it. Is it a typo?

vlada
20th September 2006, 14:02
You create video2b and then don't use it. Is it a typo?

Sure, there should be video2b on the last line. I'll fix it.

Wilbert
20th September 2006, 21:36
The image is a .png with alpha channel.
Use pixel_type = RGB32 in ImageSource. By default the png is opened as RGB24, thus without the alpha channel:

http://www.avisynth.org/mediawiki/wiki/ImageSource

vlada
21st September 2006, 22:08
Of course I read the docs and I tried pixel_type=RGB32, but if I use it in my code
(ImageSource("grafika\plz.png",pixel_type = RGB32,fps=25)), I get this error:

http://img74.imageshack.us/img74/5230/errorsr4.png

I have AviSynth 2.57, is it possible there is a bug in this version? Or is there something wrong in my code?

Wilbert
21st September 2006, 22:20
Try

ImageSource("grafika\plz.png", pixel_type="RGB32", fps=25)

vlada
21st September 2006, 23:54
Thanks, this works. I thought I have tried it too, I apparently haven't. Anyway it works now and it makes my video processing much easier.