[Ffmpeg-devel] [PATCH] watermark.c MOD4 (old patches + fade in/out)

Mihail Stoyanov screamer
Sun Oct 22 14:00:14 CEST 2006

1. Start and/or stop watermarking on particular frames (+ fade in/out)
-s nbr = nbr is the frame on which the watermarking will start
-e nbr = nbr is the frame on which the watermarking will stop
-d nbr = nbr is the number of frames used for fade in & fade out process
With -s, -e and -d switches you can make TV-like fade-in/fade-out effects.
 ffmpeg -i infile -vhook '/path/watermark.so -f wm.gif -s 50 -e 250 -d
25' -an out.mov
On a movie source with 25fps this will fade-in the watermark after the first 
(-s 50) seconds and keep the watermark until the 10th (-e 250) second.
The time for fade-in/fade-out will be 1 second (-d 25).
Switches -s and -d are usable in MODE 1 too. But it won't produce any fade

2. Contrast control
The pixel calculation formula in the default case (without -c) is:
  new_pixel_color = orig_pixel_color + (water_mark_image_color - threshold)
It is applied to Red, Green, Blue channels.
Using the -c changes the formula to:
  new_pixel_color = orig_pixel_color + (water_mark_image_color - threshold)
     + ((orig_pixel_color - threshold) * contrast_percent)
In that way you have control over the difference between the movie source
(a.k.a "orig") pixel color and the threshold (or contrast).
If using the default threshold (without -t) the -c switch is similar to
 applying contrast ONLY over that watermark pixels that aren't equal to
the threashold (like contast-mask).
When using positive values for -c, the dark pixels of the movie source will
become even more dark, the light ones will become even more light.
When using negative values for -c, the dark pixels of the movie source will
become more light, the light ones will become even more dark.
Note that the -c switch is in percents (-100 to 100)

3. Optimizations
a. Checks if the current pixel RGB (of the input image) is equal to the
threshold before doing any other calculations, thus skipping useless
b. When using single-frame watermark input...
- Checks the starting & ending coordinates (actually rectangle) of the
actual watermark (inside the watermark input) using threshold comparison.
- In that way only the area which contains the actual watermark is applied
over the movie source reducing the itterations - "for (y...)" & "for (x...)"
and greatly improving the covert times.
- It also have checks if the watermark source is multi-frame and disables
the optimization

NOTE: These optimizations are applied BOTH for mode 0 and mode 1

P.S. There was a bug in MOD3 when using mode 0 and contrast option - the
green channel was mixed with blue. It's fixed in this one
-------------- next part --------------
A non-text attachment was scrubbed...
Name: watermark_mod4.patch
Type: application/octet-stream
Size: 15863 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20061022/4b6c055c/attachment.obj>

More information about the ffmpeg-devel mailing list