您的位置:首页 > 其它

使用VHook为视频添加水印

2009-12-30 20:51 453 查看
imlib2.c

# Remember to set the path to your fonts

FONTPATH="/cygdrive/c/WINDOWS/Fonts/"

FONTPATH="$FONTPATH:/usr/share/imlib2/data/fonts/"

FONTPATH="$FONTPATH:/usr/X11R6/lib/X11/fonts/TTF/"

export FONTPATH

# Bulb dancing in a Lissajous pattern

ffmpeg -i input.avi -vhook \

'vhook/imlib2.dll -x W*(0.5+0.25*sin(N/47*PI))-w/2 -y H*(0.5+0.50*cos(N/97*PI))-h/2 -i /usr/share/imlib2/data/images/bulb.png' \

-acodec copy -sameq output.avi

# Text scrolling

ffmpeg -i input.avi -vhook \

'vhook/imlib2.dll -c red -F Vera.ttf/20 -x 150+0.5*N -y 70+0.25*N -t Hello' \

-acodec copy -sameq output.avi

# Date and time stamp, security-camera style:

ffmpeg -r 29.97 -s 320x256 -f video4linux -i /dev/video0 \

-vhook 'vhook/imlib2.so -x 0 -y 0 -i black-260x20.png' \

-vhook 'vhook/imlib2.so -c white -F VeraBd.ttf/12 -x 0 -y 0 -t %A-%D-%T' \

output.avi

In this example the video is captured from the first video capture card as a

320x256 AVI, and a black 260 by 20 pixel PNG image is placed in the upper

left corner, with the day, date and time overlaid on it in Vera Bold 12

point font. A simple black PNG file 260 pixels wide and 20 pixels tall

was created in the GIMP for this purpose.

# Scrolling credits from a text file

ffmpeg -i input.avi -vhook \

'vhook/imlib2.so -c white -F VeraBd.ttf/16 -x 100 -y -1.0*N -f credits.txt' \

-sameq output.avi

In this example, the text is stored in a file, and is positioned 100

pixels from the left hand edge of the video. The text is scrolled from the

bottom up. Making the y factor positive will scroll from the top down.

Increasing the magnitude of the y factor makes the text scroll faster,

decreasing it makes it scroll slower. Hint: Blank lines containing only

a newline are treated as end-of-file. To create blank lines, use lines

that consist of space characters only.

# Scrolling credits with custom color from a text file

ffmpeg -i input.avi -vhook \

'vhook/imlib2.so -C rgb.txt -c CustomColor1 -F VeraBd.ttf/16 -x 100 -y -1.0*N -f credits.txt' \

-sameq output.avi

This example does the same as the one above, but specifies an rgb.txt file

to be used, which has a custom-made color in it.

# Variable colors

ffmpeg -i input.avi -vhook \

'vhook/imlib2.so -t Hello -R abs(255*sin(N/47*PI)) -G abs(255*sin(N/47*PI)) -B abs(255*sin(N/47*PI))' \

-sameq output.avi

In this example, the color for the text goes up and down from black to

white.

# Text fade-out

ffmpeg -i input.avi -vhook \

'vhook/imlib2.so -t Hello -A max(0,255-exp(N/47))' \

-sameq output.avi

In this example, the text fades out in about 10 seconds for a 25 fps input

video file.

# scrolling credits from a graphics file

ffmpeg -sameq -i input.avi \

-vhook 'vhook/imlib2.so -x 0 -y -1.0*N -i credits.png' output.avi

In this example, a transparent PNG file the same width as the video

(e.g. 320 pixels), but very long, (e.g. 3000 pixels), was created, and

text, graphics, brushstrokes, etc, were added to the image. The image

is then scrolled up, from the bottom of the frame.

drawtext.c

# Remember to set the path to your fonts

FONTPATH="/cygdrive/c/WINDOWS/Fonts/"

FONTPATH="$FONTPATH:/usr/share/imlib2/data/fonts/"

FONTPATH="$FONTPATH:/usr/X11R6/lib/X11/fonts/TTF/"

export FONTPATH

# Time and date display

ffmpeg -f video4linux2 -i /dev/video0 \

-vhook 'vhook/drawtext.so -f VeraBd.ttf -t %A-%D-%T' movie.mpg

This example grabs video from the first capture card and outputs it to an

MPEG video, and places "Weekday-dd/mm/yy-hh:mm:ss" at the top left of the

frame, updated every second, using the Vera Bold TrueType Font, which

should exist in: /usr/X11R6/lib/X11/fonts/TTF/

watermark.c

ffmpeg -i infile -vhook '/path/watermark.so -f wm.gif' -an out.mov

ffmpeg -i infile -vhook '/path/watermark.so -f wm.gif -m 1 -t 222222' -an out.mov
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: