PDA

View Full Version : Overlay swapping


j2c
10th September 2004, 11:31
I'm wondering if there's a way to change the overlay to a different image every 30 seconds(back and forth). Heres my script right now(overlays come on at the same time)

source = "test.avi"
lo1 = .3
lo2 = .2


src = DirectShowSource(source)

logo1 = ImageReader("logo1.png", 0, 0, 1, true).BilinearResize(src.Width() - 12,src.Width() / 2 - 12)
x1 = src.Width() / 2 - logo1.Width() / 2
y1 = src.Height() / 2 - logo1.Height() / 2

logo2 = ImageReader("logo2.png", 0, 0, 1, true).BilinearResize(src.Width() , src.Height())

Overlay(src, logo1, x1, y1, mask=logo1, opacity=lo1)
#Overlay(logo2, 0, 0, mask=logo2, opacity=lo2)

sh0dan
10th September 2004, 14:30
Simple, rather untested:
source = "test.avi"
lo1 = .3
lo2 = .2


src = DirectShowSource(source)

logo1 = ImageReader("logo1.png", 0, 0, 1, true).BilinearResize(src.Width() - 12,src.Width() / 2 - 12)
x1 = src.Width() / 2 - logo1.Width() / 2
y1 = src.Height() / 2 - logo1.Height() / 2

logo2 = ImageReader("logo2.png", 0, 0, 1, true).BilinearResize(src.Width() , src.Height())

ov1 = Overlay(src, logo1, x1, y1, mask=logo1, opacity=lo1)
ov2 = Overlay(logo2, 0, 0, mask=logo2, opacity=lo2)
ConditionalFilter(ov1, ov1, ov2, "current_frame % 250", "<", "125")

"250" is the number of frames between a logo shift back and forth. "125" is the number of frames the first logo should be shown.

If I made this correct, the thing above should show logo 1 in frame 0->124 and logo 2 in frame 125->249 and then switch back to logo 1 and so on.

Didée
10th September 2004, 15:14
or, more simple
source = ...
logo1 = ...
logo2 = ...

switchtime = 30 # in seconds

slength=framecount(source)
srate=framerate(source)

logo = \
interleave(logo1,logo2).loop().assumefps(1) \
.changefps(srate*switchtime).assumefps(srate).trim(0,slength)

# ... now simply overlay "logo"

complete it by yourself ;)

edit: "\"

j2c
10th September 2004, 20:50
source = "test.avi"
lo1 = .3
lo2 = .2



src = DirectShowSource(source)

logo1 = ImageReader("logo1.png", 0, 0, 1, true).BilinearResize(src.Width() - 12,src.Width() / 2 - 12)
x1 = src.Width() / 2 - logo1.Width() / 2
y1 = src.Height() / 2 - logo1.Height() / 2

logo2 = ImageReader("logo2.png", 0, 0, 1, true).BilinearResize(src.Width() , src.Height())
x2 = src.Width() / 2 - logo2.Width() / 2
y2 = src.Height() / 2 - logo2.Height() / 2

ov1 = Overlay(src, logo1, x1, y1, mask=logo1, opacity=lo1)
ov2 = Overlay(src, logo2, 0, 0, mask=logo2, opacity=lo2)


ConditionalFilter(ov1, ov1, ov2, "current_frame % 1800", "<", "900")This one worked with my different opacity & position settings. Is there a way to change the frames used dynamically like in Didée's example to use in ConditionalFilter?

Vectrangle
10th September 2004, 21:01
what exactly do you mean by change the frames used dynamically?

btw if you don't understand the % symol, here (http://www.intellidimension.com/default.rsp?topic=/pages/rdfgateway/reference/script/mod.rsp) is an explaination

j2c
10th September 2004, 21:07
Originally posted by Vectrangle
what exactly do you mean by change the frames used dynamically?

btw if you don't understand the % symol, here (http://www.intellidimension.com/default.rsp?topic=/pages/rdfgateway/reference/script/mod.rsp) is an explaination i meant to say for it to take the framerate of the source and multiply by 30 and put it instead of 900 and where it says 1800 to do the same but multiply by 2

"current_frame % 1800", "<", "900"

Vectrangle
11th September 2004, 03:53
"current_frame % "+string(framerate*60), "<", string(framerate*30)

:readguid: :sly:

j2c
11th September 2004, 22:20
thanks everyone! :D

Vectrangle - i'll take a look at the ScriptFunctions page ;)