View Full Version : Merge transparent background image on some frames?


color
28th May 2018, 18:29
I got a clip I want to add an intro-text on but only for a few frames, lets say frame 156-256. the image is a png with transparent background (same resolution as the video). I want the image to show only the text in it (bland and white is used with transparent background) over the video (moving images). :)

I have tried to search but I only finds how to add a transparent logo for a full clip and that is not what I am looking for.

:thanks:

poisondeathray
28th May 2018, 19:21
You can mix and match versions with Trim()

e.g.

Let's say "A" is original "B" has the overlay

A.Trim(0,155) ++ B.Trim(156,256) ++ A.Trim(257,0)

There are other ways too, such has helper functions like ReplaceFrames, ReplaceFramesSimple, ClipClop etc... They would be easier depending on how many sections you are doing

color
28th May 2018, 20:28
I feel stupid.

A=DirectShowSource("thefile.mkv")
B=ImageSource("01.png")
Overlay(A, B.Trim(1852, 1986), mode="difference")

I don't know what mode to try, I did try the most of them but no one worked. And trim don't seems to work as I think it does, the first isn't that the start frame and the last one the end?

poisondeathray
28th May 2018, 22:59
I feel stupid.

A=DirectShowSource("thefile.mkv")
B=ImageSource("01.png")
Overlay(A, B.Trim(1852, 1986), mode="difference")

I don't know what mode to try, I did try the most of them but no one worked. And trim don't seems to work as I think it does, the first isn't that the start frame and the last one the end?

Does your PNG image have an embedded alpha channel (transparency)? Is it the same dimensions as the video ?

It would look something like this


A=DirectShowSource("thefile.mkv")
B=ImageSource("01.png", start=0, end=A.framecount-1, fps=A.framerate, pixel_type="RGB32")
C=Overlay(A,B, mask=B.showalpha())

A.Trim(0,155) ++ C.Trim(156,256) ++ A.Trim(257,0)



I would avoid using DirectShowSource, because it is prone to many problems, including seek/frame accuracy

Think of it like this:
A is the original

B is the image itself, made into a "video", with the parameters of "A" in terms of framecount, fps

C is the original with the image overlaid with alpha channel on the entire video

You're mixing and matching parts of A with C.