View Full Version : Reading colour from frames and watermarking
EuropeanMan
5th September 2010, 18:43
For argument's sake I have a movie and wish to watermark ONLY a few scenes...let's say 24 frames per 1 hour...thus, basically one second.
I'd like to concentrate on a 25x25 pixel square where some filter could READ the colour in that particular spot. Take THAT colour into memory, and then write the world BOX using a lighter shade of the original into that 25x25 pixel square on top of it's background.
Is this possible? Or must I manually find the frames where that 25x25 box would be the same colour throughout and add the watermark specifically for those frames using a colour i specify?
I only ask so that I could randomise those 24 consecutive frames on different occasions.
Thanks in advance.
J_Darnley
6th September 2010, 10:00
You can probably achieve "using a lighter shade of the original" with the correct mode of overlay or the right transparency.
You can also randomise the frames you want to mark with a bit of rand() to the frame numbers of trim.
EuropeanMan
7th September 2010, 18:46
^ it's correct that I'd like to overlay a transparency with a lighter shade of the original...but my problem is the HOW. i'm in unfamiliar waters here and was hoping someone could help me with the script... thanks again.
Guest
7th September 2010, 19:18
loadplugin("c:\dgmpgdec\dgdecode.dll")
mpeg2source("roses.d2v")
square=blankclip(last,width=64,height=64,color=$ffffff)
overlay(square, x=420, y=140, mode="blend", opacity=0.3)
Use the opacity to adjust the amount of lightening.
EuropeanMan
7th September 2010, 19:24
^ Will try this out...thanks a bunch neuron!
although, trying to figure out where placing the text "box" would go in all of this!
Guest
7th September 2010, 19:38
Here's a better version because you can crank the contrast as well to prevent it looking washed out. I also added a text string that you can position as needed.
loadplugin("c:\dgmpgdec\dgdecode.dll")
mpeg2source("roses.d2v")
square=crop(420,140,-64,-64).tweak(bright=25,cont=3).subtitle("Hi!")
overlay(square, x=420, y=140, mode="blend", opacity=0.5)
x and y specify where the overlaid box goes. The first two crop values should match those. The second two crop values determine how big the box is. You can use variables if you prefer or if you want to make a function out of it.
Guest
7th September 2010, 19:47
Another variant that looks better:
loadplugin("c:\dgmpgdec\dgdecode.dll")
mpeg2source("roses.d2v")
square=crop(420,140,-64,-64).tweak(bright=15,cont=1.5).subtitle("Hi!")
overlay(square, x=420, y=140, mode="blend", opacity=1.0)
EuropeanMan
8th September 2010, 01:11
square=crop(420,140,-64,-64).tweak(bright=15,cont=1.5).subtitle("Hi!")
---------
with this line above...obviously i know that we're cropping to get a certain box size...i'm wondering if there is a function that could automatically place "hi!" on the bottom right hand of my framing...no matter what my height/width may be.
i'm thinking (just as an example) if i had to do it manually:
...crop(last.width-420,last.height-140,-(last.width-64),-(last.height-64))...
? am i close ?
as for the automatic...i guess i'd ideally want the bottom right 25x25 box all the time...so i wouldn't have to manually enter the proper cropping figures...
will think as to how to achieve that myself in the meantime as well
Guest
8th September 2010, 04:12
Something like this:
mpeg2source("roses.d2v")
src_w=last.width
src_h=last.height
margin=32 # space between box and frame edge
box_w=64 # box width
box_h=64 # box height
offset_x=last.width - (box_w + margin)
offset_y=last.height - (box_h + margin)
right=src_w-(offset_x+box_w)
right = (right % 2 == 0) ? right : right + 1 # force mod 2
bottom=src_h-(offset_y+box_h)
bottom = (bottom % 2 == 0) ? bottom : bottom + 1 # force mod 2
square=crop(offset_x,offset_y,-right,-bottom).tweak(bright=15,cont=1.5).subtitle("Hi!")
overlay(square, x=offset_x, y=offset_y, mode="blend", opacity=1.0)
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.