]> git.sesse.net Git - ffmpeg/blob - doc/hooks.texi
remove ps option and rename rtp_payload_size AVOption to ps
[ffmpeg] / doc / hooks.texi
1 \input texinfo @c -*- texinfo -*-
2
3 @settitle Video Hook Documentation
4 @titlepage
5 @sp 7
6 @center @titlefont{Video Hook Documentation}
7 @sp 3
8 @end titlepage
9
10
11 @chapter Introduction
12
13
14 The video hook functionality is designed (mostly) for live video. It allows
15 the video to be modified or examined between the decoder and the encoder.
16
17 Any number of hook modules can be placed inline, and they are run in the
18 order that they were specified on the ffmpeg command line.
19
20 Three modules are provided and are described below. They are all intended to
21 be used as a base for your own modules.
22
23 Modules are loaded using the -vhook option to ffmpeg. The value of this parameter
24 is a space separated list of arguments. The first is the module name, and the rest
25 are passed as arguments to the Configure function of the module.
26
27 @section null.c
28
29 This does nothing. Actually it converts the input image to RGB24 and then converts
30 it back again. This is meant as a sample that you can use to test your setup.
31
32 @section fish.c
33
34 This implements a 'fish detector'. Essentially it converts the image into HSV
35 space and tests whether more than a certain percentage of the pixels fall into
36 a specific HSV cuboid. If so, then the image is saved into a file for processing
37 by other bits of code.
38
39 Why use HSV? It turns out that HSV cuboids represent a more compact range of
40 colors than would an RGB cuboid.
41
42 @section imlib2.c
43
44 This module implements a text overlay for a video image. Currently it
45 supports a fixed overlay or reading the text from a file. The string
46 is passed through strftime so that it is easy to imprint the date and
47 time onto the image.
48
49 You may also overlay an image (even semi-transparent) like TV stations do.
50 You may move either the text or the image around your video to create
51 scrolling credits, for example.
52
53 Text fonts are being looked for in a FONTPATH environment variable.
54
55 Options:
56 @multitable @columnfractions .2 .8
57 @item @option{-c <color>}     @tab The color of the text
58 @item @option{-F <fontname>}  @tab The font face and size
59 @item @option{-t <text>}      @tab The text
60 @item @option{-f <filename>}  @tab The filename to read text from
61 @item @option{-x <expresion>} @tab X coordinate of text or image
62 @item @option{-y <expresion>} @tab Y coordinate of text or image
63 @item @option{-i <filename>}  @tab The filename to read a image from
64 @end multitable
65
66 Expresions are functions of these variables:
67 @multitable @columnfractions .2 .8
68 @item @var{N} @tab frame number (starting at zero)
69 @item @var{H} @tab frame height
70 @item @var{W} @tab frame width
71 @item @var{h} @tab image height
72 @item @var{w} @tab image width
73 @item @var{X} @tab previous x coordinate of text or image
74 @item @var{Y} @tab previous y coordinate of text or image
75 @end multitable
76
77 You may also use the constants @var{PI}, @var{E}, and the math functions available at the
78 FFmpeg formula evaluator at (@url{ffmpeg-doc.html#SEC13}), except @var{bits2qp(bits)}
79 and @var{qp2bits(qp)}.
80
81 Usage examples:
82
83 @example
84    # Remember to set the path to your fonts
85    FONTPATH="/cygdrive/c/WINDOWS/Fonts/"
86    FONTPATH="$FONTPATH:/usr/share/imlib2/data/fonts/"
87    FONTPATH="$FONTPATH:/usr/X11R6/lib/X11/fonts/TTF/"
88    export FONTPATH
89
90    # Bulb dancing in a Lissajous pattern
91    ffmpeg -i input.avi -vhook \
92      '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' \
93      -acodec copy -sameq output.avi
94
95    # Text scrolling
96    ffmpeg -i input.avi -vhook \
97      'vhook/imlib2.dll -c red -F Vera.ttf/20 -x 150+0.5*N -y 70+0.25*N -t Hello' \
98      -acodec copy -sameq output.avi
99 @end example
100
101 @section ppm.c
102
103 It's basically a launch point for a PPM pipe, so you can use any
104 executable (or script) which consumes a PPM on stdin and produces a PPM
105 on stdout (and flushes each frame).
106
107 Usage example:
108
109 @example
110 ffmpeg -i input -vhook "/path/to/ppm.so some-ppm-filter args" output
111 @end example
112
113 @bye