[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1. Introduction

The video hook functionality is designed (mostly) for live video. It allows the video to be modified or examined between the decoder and the encoder.

Any number of hook modules can be placed inline, and they are run in the order that they were specified on the ffmpeg command line.

A few modules are provided and are described below. They are all intended to be used as a base for your own modules.

Modules are loaded using the -vhook option to ffmpeg. The value of this parameter is a space separated list of arguments. The first is the module name, and the rest are passed as arguments to the Configure function of the module.

The modules are dynamic libraries: They have different suffixes (.so, .dll, .dylib) depending on your platform. And your platform dictates if they need to be somewhere in your PATH, or in your LD_LIBRARY_PATH. Otherwise you will need to specify the full path of the vhook file that you are using.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.1 null.c

This does nothing. Actually it converts the input image to RGB24 and then converts it back again. This is meant as a sample that you can use to test your setup.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.2 fish.c

This implements a 'fish detector'. Essentially it converts the image into HSV space and tests whether more than a certain percentage of the pixels fall into a specific HSV cuboid. If so, then the image is saved into a file for processing by other bits of code.

Why use HSV? It turns out that HSV cuboids represent a more compact range of colors than would an RGB cuboid.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.3 imlib2.c

This module implements a text overlay for a video image. Currently it supports a fixed overlay or reading the text from a file. The string is passed through strftime so that it is easy to imprint the date and time onto the image.

This module depends on the external library imlib2, available on Sourceforge, among other places, if it is not already installed on your system.

You may also overlay an image (even semi-transparent) like TV stations do. You may move either the text or the image around your video to create scrolling credits, for example.

Text fonts are being looked for in a FONTPATH environment variable.

Options:

-c <color>

The color of the text

-F <fontname>

The font face and size

-t <text>

The text

-f <filename>

The filename to read text from

-x <expresion>

X coordinate of text or image

-y <expresion>

Y coordinate of text or image

-i <filename>

The filename to read a image from

Expresions are functions of these variables:

N

frame number (starting at zero)

H

frame height

W

frame width

h

image height

w

image width

X

previous x coordinate of text or image

Y

previous y coordinate of text or image

You may also use the constants PI, E, and the math functions available at the FFmpeg formula evaluator at (ffmpeg-doc.html#SEC13), except bits2qp(bits) and qp2bits(qp).

Usage examples:

 
   # 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

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.4 ppm.c

It's basically a launch point for a PPM pipe, so you can use any executable (or script) which consumes a PPM on stdin and produces a PPM on stdout (and flushes each frame).

Usage example:

 
ffmpeg -i input -vhook "/path/to/ppm.so some-ppm-filter args" output

[Top] [Contents] [Index] [ ? ]

About This Document

This document was generated by OEM lpia Buildd on March, 31 2011 using texi2html 1.78.

The buttons in the navigation panels have the following meaning:

Button Name Go to From 1.2.3 go to
[ < ] Back Previous section in reading order 1.2.2
[ > ] Forward Next section in reading order 1.2.4
[ << ] FastBack Beginning of this chapter or previous chapter 1
[ Up ] Up Up section 1.2
[ >> ] FastForward Next chapter 2
[Top] Top Cover (top) of document  
[Contents] Contents Table of contents  
[Index] Index Index  
[ ? ] About About (help)  

where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:


This document was generated by OEM lpia Buildd on March, 31 2011 using texi2html 1.78.