Link to home
Start Free TrialLog in
Avatar of dharm0us
dharm0us

asked on

Vhooks with ffmpeg

Hi,
I want to watermark my video using an image, so I built ffmpeg with vhook support enabled.
Then I used the following command :

./ffmpeg.exe -i input.flv -vhook 'vhook/watermark.dll -f usa.gif' out4.mpg

but this command superimposes the image file all over the video frame.
I want to know :
1. How to put the watermark only in a give portion of the video frame, and not on the
entire frame?
2. Or if that's not possible what is the best way to make the video look as clutter free as possible?
As of now it's impossible to distinguish the watermark from the original video frame.
3. Is there any other "free" tool/software to programmatically watermark a video file?
Avatar of hadimhd
hadimhd

1. You need to create a gif image with the size of the target video frame. For example, I need one in 320x640 , so i create a transparent gif image in 320x240 and add the text or image to the place where it should appear in the new video created.
I think its better to specify a target video size also.
there are many programs if u want to use in GUI, but this is commonly used via command line for web servers
Avatar of dharm0us

ASKER

Hi hadimhd,
There are 2 problems :

1. A user on my site has to input an image, which I would use as a watermark image.
2. Suppose I take only text input as watermark, I used the attached php code for generating a transparentgif image with the same size as that of my video.
But the output video is very subdued in colors as compared to the original video.

You can download the video I am using, here :
http://fundooquotes.com/pigeons_in_noida.flv

And the image file here :
http://fundooquotes.com/abc.gif

<?php
// Set the content-type
header("Content-type: image/gif");
 
$fontsize = 18;
if(@$_GET['fontsize']) {
    $fontsize = $_GET['fontsize'];
}
$font = 'ArialN.TTF';
//$text = @$_GET['text'];
$text = "checkT";
// Create the image
$size = imagettfbbox($fontsize, 0, $font, $text);
//$width = $size[2] + $size[0] + 8;
//$height = abs($size[1]) + abs($size[7]);
$width = 320;
$height = 240;
$im = imagecreate($width, $height);
 
$colourBlack = imagecolorallocate($im, 255, 255, 255);
imagecolortransparent($im, $colourBlack);
 
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
 
// Add the text
imagefttext($im, $fontsize, 0, 0, abs($size[5]), $black, $font, $text);
 
// Using imagepng() results in clearer text compared with
imagegif($im);
imagedestroy($im);
?>

Open in new window

Avatar of Merete
Paintshop pro 7 will add a water mark to your still image,
Nero Vison 4 or maybe even Nero Vision Express if you have it or some other video authoring tool can add TEXT over your selected frame in your video using video track then export the movie as mpeg.
Open Nero Vision make a movie then drop your video onto the work panel then onto the video tyrack select from the many text options, i chose the floor scroller as it's called to show
I selected a colour that's almost transparent and reduced the font size.Nero Vision has many other Text tools.

Here's a snap I made for you to show this effect

text-over-frame.jpg
what do u mean by subdued ? can u gimme url of watermarked video ? did u mean, the color of video changed ? usually an extra white layer appears.. or is it pixelated with lot of squares ? (try specifying required video bit rate)
ASKER CERTIFIED SOLUTION
Avatar of hadimhd
hadimhd

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The command I used :
./ffmpeg.exe -i pigeons_in_noida.flv -vhook 'vhook/watermark.dll -f abc.gif' out4.mpg

Here is the watermarked video :
http://fundooquotes.com/out4.mpg
yes, this -m 1 -t 000000 thing works.
I saw its documentation, but couldn't figure out what exactly does it do?
it specifies the threshold...
HI hadimhd,
I accept your solution.
Could you explain a bit about how does this -m 1 -t 000000 thing work?
-m 1 , sets the mode to specify threshold. -t 000000 specifies the watermark threshold, u can modify 0000000 with different color codes, so u can see a small layer up of ur watermarked video.. i used 000000 because the background was nothing (transparent)
Hi hadimhd,
what threshold?
doc says:
"If mask color > threshold color then the watermark pixel is used."
what is mask color?
and what does it mean by "watermark pixl is used"?
does it mean the original pixel will be replaced with the watermark pixel
or something else?
i am not 100% sure about their technical terms.. but i think mask color is the color in the water mark. #000000 is for black, we used it in threshold. so it took only pixels with #000000 color (black) to overlay the old video. yeah, the original video's pixel will be replaced with the watermark pixels if that watermark pixels color is #000000.