You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
4.3KB

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