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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 28th May 2018, 18:29   #1  |  Link
color
Registered User
 
color's Avatar
 
Join Date: May 2016
Posts: 235
Merge transparent background image on some frames?

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.

__________________
Automatic Colorization

Last edited by color; 28th May 2018 at 20:33.
color is offline   Reply With Quote
Old 28th May 2018, 19:21   #2  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
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
poisondeathray is offline   Reply With Quote
Old 28th May 2018, 20:28   #3  |  Link
color
Registered User
 
color's Avatar
 
Join Date: May 2016
Posts: 235
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?
__________________
Automatic Colorization

Last edited by color; 28th May 2018 at 20:32.
color is offline   Reply With Quote
Old 28th May 2018, 22:59   #4  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Quote:
Originally Posted by color View Post
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

Code:
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.

Last edited by poisondeathray; 28th May 2018 at 23:04.
poisondeathray is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 22:17.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.