All my current optimization patches for watermark.c have been moved to
another vhook plugin (PiP) for ffmpeg (it doesn't exist yet in the ffmpeg
source tree)
In that way i'm not braking "TEH development policy" of ffmpeg or w/e.
A lot new features have been added to PiP - see below.
Development Notes:
* pip.c is using ffmpegs rescaling/resampling instead of calculating the
nearest pixel when using PiP source with different dimensions than the main
source
* initializations, cleanup and get_frame() are splitted in pip.c
* pip.c requires main source width/height (internal, not as command line
option)
* when the PiP source is multi-frame and it ends before the main source -
PiP will stop changing the main source pixels
-----------------------------
Options to PiP:
-m nbr = nbr is 0 or 1. 0 is the default mode, see below.
-t nbr = nbr is threshold (six digit hex)
-c nbr = nbr is contrast percent over the original pixels, see below.
-s nbr = nbr is the frame on which the PiP will start
-e nbr = nbr is the frame on which the PiP will stop
-d nbr = nbr is the number of frames used for fade in & fade out process
-x nbr = nbr is the x coord on which the PiP drawing will start
-y nbr = nbr is the y coord on which the PiP drawing will start
-w nbr = nbr is the desired width of the PiP
-h nbr = nbr is the desired height of the PiP
-f file = file is the filename of the PiP image/video. You must specify
this!
Working with MODE 0:
Let's assume that the threshold is the default one - 0x80 hex (128 dec)
Per color (for each pixel) do this:
If the PiP color is exactly 0x80, no change to the original color.
If the PiP color is > 0x80 the new color is equal to the original color +
the abs difference between the PiP color and the threshold.
If the PiP color is < 0x80 the new color is equal to the original color -
the abs difference between the PiP color and the threshold.
If result is greater than 0xff (255), result will be 0xff (255). Same for 0
Example: ffmpeg -i infile -vhook '/path/pip.so -f wm.gif' outfile
Working with MODE 1:
If all PiP colors (for each pixel) > threshold color, the PiP pixel will
replace the original pixel.
Example: ffmpeg -i infile -vhook '/path/pip.so -f wm.gif -m 1' outfile
Working with MODE 2:
The PiP picture is applied over the movie source without any transperancy.
A.k.a. "pure PiP"
Example: ffmpeg -i infile -vhook '/path/pip.so -f wm.gif -m 2' outfile
Options -x, -y, -w & -h. PiP positioning (usable in all modes):
The default behaviour of PiP is to stretch the PiP source to the size of the
main source and apply the selected mode (0, 1 or 2).
By using the -x & -y options you can specify the x,y coordinate at which the
PiP source drawing will start. With -w & -h you can specify thedesired PiP
source width, height.
Let's assume that you want to draw an image (or video) in the bottom-right
part of a movie source with dimensions 608x336 pixels.
You want the PiP to have dimensions 150x130 pixel and to position it's
top-left corner on coordinates x400/y180 over the movie source (that's the
bottom-right part)
Example: ffmpeg -i infile -vhook '/path/pip.so -f wm.gif -x 400 -y 180 -w
150 -h 130' outfile
Use the different modes (0, 1 or 2) to make the PiP transparent, partially
transparent or fully applied over the main source
Example mode 1: ffmpeg -i infile -vhook '/path/pip.so -f wm.gif -x 400 -y
180 -w 150 -h 130 -m 1' outfile
Example mode 2: ffmpeg -i infile -vhook '/path/pip.so -f wm.gif -x 400 -y
180 -w 150 -h 130 -m 2' outfile
Option -t. Threshold (usable in all modes):
You can change the threshold (default 0x80) with the -t flag.
If threshold is 000000 the color values of picture is added to destination.
This way in MODE 0, a mask that is visible both in light pictures and in
dark can be made (fex by using a picture generated by gimp and the bump map
tool).
Example: ffmpeg -i infile -vhook '/path/pip.so -f wm.gif -t 222222' outfile
Options -s & -d. PiP duration (usable in all modes):
With -s, -d switches you can specify the start and the end of the PiP
effects using frame duration.
Let's assume we have movie source with 25fps.
The example will start the PiP process on 50th frame (-s 50) of the movie
source (2nd second) and will stop it on the 250th frame (-e 250), or 10th
second.
Example: ffmpeg -i infile -vhook '/path/pip.so -f wm.gif -s 50 -e 250'
outfile
Option -d. Fade In/Fade Out effects (usable in all modes with -s and -e):
With -d switch you can make TV-like fade-in/fade-out effects.
The PiP will make the same thing as using -s and -e (see PiP duration) with
the only difference that it will produce a fade in and fade out effect with
duration 25 frames (or 1 second)
Example: ffmpeg -i infile -vhook '/path/pip.so -f wm.gif -s 50 -e 250 -d 25'
outfile
Option -c. Contrast mask (usable only in MODE 0):
In mode 0 the pixel calculation formula without contrast is: new_pixel_color
= orig_pixel_color + (pip_image_color - threshold)
It is applied to Red, Green, Blue channels of the pixel.
When using the -c option the formula changes to: new_pixel_color =
orig_pixel_color + (pip_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 option is similar to
applying contrast ONLY over that PiP 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)
Example: ffmpeg -i infile -vhook '/path/pip.so -f wm.gif -c -20' outfile
Complex Example: ffmpeg -i infile -vhook '/path/pip.so -f wm.avi -x 400 -y
180 -w 150 -h 130 -s 50 -e 500 -d 25 -m 0 -c -20' outfile
Meaning (on 25dps video): Draw a PiP with dimensions 150x130 pixels, using
mode 2, starting on coordinates 400x180 (of the main source), start drawing
it at frame 50 (2nd second), stop drawing it at frame 500 (20th second), use
fade-in & fade-out effects with duration 25 frames for the process
(1 second) and add contrast mask -20%
-----------------------------
P.S. 2 patches attached. The first is for Makefile, the other is pip.c
itself
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pip.patch
Type: application/octet-stream
Size: 40501 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20061023/d3621d17/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: makefile.patch
Type: application/octet-stream
Size: 428 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20061023/d3621d17/attachment-0001.obj>