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

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st January 2012, 12:50   #1  |  Link
DrPhill
Registered User
 
Join Date: Dec 2011
Location: West Somerset, UK
Posts: 130
Watermark?

Is there a filter/function for 'watermarking' a video?

By 'watermarking' I mean writing text by deforming the video - an effect like placing glass lettering on top of a picture. Or anything similar would do - adding text without hiding too much of the video.

I imagine that this has already been done, but do not know what to search for.

Thanks in advance for any help you may be able to give.

Phill
DrPhill is offline   Reply With Quote
Old 21st January 2012, 13:22   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 5,157
Try search on "logo watermark" perhaps limiting to the Avisynth Usage forum.

EDIT: or to find those words including CODE blocks in search, google

logo watermark site:forum.doom9.org
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but are any of them infinitely bigger ???

Last edited by StainlessS; 21st January 2012 at 13:26.
StainlessS is offline   Reply With Quote
Old 21st January 2012, 15:43   #3  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 12,826
Maybe the standard Overlay filter will work for this:
http://avisynth.org/mediawiki/Overlay

If you have a 32-Bit PNG file with proper Alpha (transparency) information, it can be applied like this:

Code:
Image = ImageSource("C:\Your Overlay.png", pixel_type="RGB32")
Overlay(Image, mask=Image.showAlpha())
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 21st January 2012 at 16:23.
LoRd_MuldeR is offline   Reply With Quote
Old 24th January 2012, 11:32   #4  |  Link
DrPhill
Registered User
 
Join Date: Dec 2011
Location: West Somerset, UK
Posts: 130
Quote:
Originally Posted by LoRd_MuldeR View Post
Maybe the standard Overlay filter will work for this:
http://avisynth.org/mediawiki/Overlay

If you have a 32-Bit PNG file with proper Alpha (transparency) information, it can be applied like this:

Code:
Image = ImageSource("C:\Your Overlay.png", pixel_type="RGB32")
Overlay(Image, mask=Image.showAlpha())
That does a basic subtitle, which could be semi-opaque. I was hoping for something a bit more slick. Imagine putting a caption made of glass - you would still see the image, and the image on the flat top of the text would be simply displaced. The image around the vertical sides of the glass text would be stretched and compressed depending upon where it was. I just thought that it would be a neat effect.

Maybe I need to work up an algorithm.....

But thanks anyway for the suggestions.

Phill
DrPhill is offline   Reply With Quote
Old 24th January 2012, 13:11   #5  |  Link
ajk
Registered User
 
Join Date: Jan 2006
Location: Finland
Posts: 123
You could probably achieve something like that by using the mask to cut out the corresponding area of the image and shrink/expand/displace it by a little. Do this a couple of times and then overlay them all on top of each other on the original image. Add a bit of blur if needed.
ajk is offline   Reply With Quote
Old 24th January 2012, 13:17   #6  |  Link
pandy
Registered User
 
Join Date: Mar 2006
Posts: 1,035
sounds like perfect task for http://forum.doom9.org/showthread.php?t=161852
pandy is offline   Reply With Quote
Old 24th January 2012, 13:20   #7  |  Link
DrPhill
Registered User
 
Join Date: Dec 2011
Location: West Somerset, UK
Posts: 130
Quote:
Originally Posted by ajk View Post
You could probably achieve something like that by using the mask to cut out the corresponding area of the image and shrink/expand/displace it by a little. Do this a couple of times and then overlay them all on top of each other on the original image. Add a bit of blur if needed.
Indeed, ajk, that is the sort of thing I imagined doing, but maybe in a filter, as there might be a lot of processor cycles wasted. I am not if I would need 'transparency' in the recombination. For example, the flat top would merely be a displaced image.

But it is certainly worth kicking these ideas arround as I have not thought them out well enough yet.

Phill
DrPhill is offline   Reply With Quote
Old 24th January 2012, 13:27   #8  |  Link
DrPhill
Registered User
 
Join Date: Dec 2011
Location: West Somerset, UK
Posts: 130
Quote:
Originally Posted by pandy View Post
It may well be, pandy, but is that OpenGL stuff a steep learning curve? I have never been near it before, but it may make a useful diversion.

(I started with leaning to play the whistle, then recording and mastering the tunes, then on to making videos, followed by video editing, writing AVISynth plugins in C, now OpenGL? 'What a long strange trip its been....)
DrPhill is offline   Reply With Quote
Old 25th January 2012, 17:21   #9  |  Link
DrPhill
Registered User
 
Join Date: Dec 2011
Location: West Somerset, UK
Posts: 130
Turns out that it is relatively simple - I have attached a zip with the DLL and a sample script. I left out the example mpg as it was fairly large and I am sure you all have some samples.

I will tidy up the code and documentation if there is enough interest. Let me know what you think.

Thanks

Phill
Attached Files
File Type: zip Release.zip (39.7 KB, 48 views)
DrPhill is offline   Reply With Quote
Old 25th January 2012, 20:09   #10  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 644
Virtualdub says "Access violation in watermark.dll" and collapses.
WinXPSP3, Graphic card GTX7950.
__________________
Die toten Augen von Friedrichshain: "Data reduction ? Yep, Sir. We're working on that issue. Synce invntoin uf lingöage..."
"To bypass shortcuts and find suffering"...no, it was somehow different...

Last edited by Emulgator; 25th January 2012 at 20:51. Reason: Mistyped a " as 2
Emulgator is offline   Reply With Quote
Old 25th January 2012, 20:19   #11  |  Link
DrPhill
Registered User
 
Join Date: Dec 2011
Location: West Somerset, UK
Posts: 130
Thanks Emulgator (I think!). And sorry for any wasted time.

Seemed to work alright in AVISynth. I am not sure what to do now - I have no idea how to debug a plugin. I cannot see me mustering the enthusiasm to learn what I need to build an industrial strength solution - at least not while it is doing what I want. I can make the source code available to anyone interested.

The effect of the filter is to deform the clip as if there are lumps behind the screen. The lumps are defined by a black-and-white clip.

Phill
DrPhill is offline   Reply With Quote
Old 25th January 2012, 21:46   #12  |  Link
librarian
Registered User
 
Join Date: Nov 2011
Posts: 63
No problem here (win 7 home premium 64). Good work!

Last edited by librarian; 25th January 2012 at 21:58.
librarian is offline   Reply With Quote
Old 25th January 2012, 22:24   #13  |  Link
DrPhill
Registered User
 
Join Date: Dec 2011
Location: West Somerset, UK
Posts: 130
Quote:
Originally Posted by librarian View Post
No problem here (win 7 home premium 64). Good work!
Thanks for the reassurance, Librarian. I have probably messed up slightly with my pointer arithmetic, but in a way that does not show on our platform. I have a couple of mods to sort out, then I will tidy the source code and publish it.

Maybe someone will give it the once-over for mistakes.

Phill
DrPhill is offline   Reply With Quote
Old 25th January 2012, 22:32   #14  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 644
Looks good !
The GTX7950Go supports up to Open GL 2.0, maybe this is not enough...
I will try my luck later on...
__________________
Die toten Augen von Friedrichshain: "Data reduction ? Yep, Sir. We're working on that issue. Synce invntoin uf lingöage..."
"To bypass shortcuts and find suffering"...no, it was somehow different...
Emulgator is offline   Reply With Quote
Old 26th January 2012, 07:38   #15  |  Link
DrPhill
Registered User
 
Join Date: Dec 2011
Location: West Somerset, UK
Posts: 130
Quote:
Originally Posted by Emulgator View Post
Looks good !
The GTX7950Go supports up to Open GL 2.0, maybe this is not enough...
I will try my luck later on...
I do not use OpenGL - I never got as far as investigating it. I hand-coded this in C..... (which is probably why you get access violations).

I am grateful to Librarian for posting a pic. Some notes:
- the width of the border around the watermark is parameterised.
- the maximum intensity of lightening/darkening of the border is parameterised
- the lightening/darkening is graded from watermark to background
- the offset of the image in the watermark is parameterised

This means that the effect can be altered from very subtle to very not-subtle.
DrPhill is offline   Reply With Quote
Old 26th January 2012, 13:06   #16  |  Link
DrPhill
Registered User
 
Join Date: Dec 2011
Location: West Somerset, UK
Posts: 130
I am tidying up the code.

I have added some features:
- Specify light direction
- Specify light amount
- soft or hard edges
- depth
- image displacement

Are there any other features that might be useful?

I wondered whether making it dynamic would be good - the watermark could move/change. This may slow processing down a bit but should be simple to implement.

I also wondered if using a grey scale to indicate the height/displacement might be effective. I am not sure how I would calculate the lighting though. Any thoughts?

Would a colour shift be useful in the watermarked area?

Any thoughts appreciated.

Phill
Attached Files
File Type: zip Release.zip (41.7 KB, 19 views)
DrPhill is offline   Reply With Quote
Old 26th January 2012, 16:14   #17  |  Link
DrPhill
Registered User
 
Join Date: Dec 2011
Location: West Somerset, UK
Posts: 130
OK, dynamic watermarking was simple. New DLL attached.

I have a new filter for testing called moveIt which can be used to move the watermark in a fairly boring fashion to illustrate that this works dynamically. Details in example.avs in the zip.

Feedback welcome, as are offers of help to make the C code up to 'platform independent' quality.

Thanks

Phill
Attached Files
File Type: zip Release.zip (42.3 KB, 37 views)
DrPhill is offline   Reply With Quote
Old 26th January 2012, 17:54   #18  |  Link
librarian
Registered User
 
Join Date: Nov 2011
Posts: 63
Nice effect!
I'm wrong (my eyes aren't so good and my monitor is worse) or during horizontal motion there are jaggy edges on watermark?
Platform independence for an Avisynth plugin?
librarian is offline   Reply With Quote
Old 26th January 2012, 18:31   #19  |  Link
DrPhill
Registered User
 
Join Date: Dec 2011
Location: West Somerset, UK
Posts: 130
Quote:
Originally Posted by librarian View Post
Nice effect!
Thanks - and with motion it goes beyond my initial goal, and opens up some interesting posibilities. I am now investigating tools to create animated 'watermarks'. Floating music notes and the like...... Gimp is a contender.
Quote:
Originally Posted by librarian View Post
I'm wrong (my eyes aren't so good and my monitor is worse) or during horizontal motion there are jaggy edges on watermark?
There seem to be some interesting effects, but I think it is the way the combination of movement and distortion* is interpreted. The distortion* is the deliberate distortion blending from background to watermark with increasing/decreasing image offset.
Quote:
Originally Posted by librarian View Post
Platform independence for an Avisynth plugin?
Certainly. It functions as a plugin on at least two machines (thine and mine) so it is on the way to being useful. I really just bashed together an algorithm in C without worrying too much about portability and the like. I have been spoilt by Java I guess. And this shows in as much as Emulgator had problems - and I have neither the knowledge nor the tools to do much about it.

I have commented the code and will create a SourceForge project for it.

Phill
DrPhill is offline   Reply With Quote
Old 27th January 2012, 00:02   #20  |  Link
librarian
Registered User
 
Join Date: Nov 2011
Posts: 63
Portability

A (not too quick) experiment. I created a virtual machine with Virtual Box (latest available version, freshly downloaded) and installed Windows XP SP3 professional, Avisynth 2.5.8 and Xvid 1.3.2.
I run your script, the result is the expected one (see linked image)
Therefore there are at least 3 machines which can run your plugin:yours,mine,a virtual XP (but I think there are many more):-)
If I find the time I'll try with linux and wine.
librarian is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 03:29.


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