logo.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
#include "common.h"
#include "avformat.h"
#include "avcodec.h"
#include "allformats.h"
#include "framehook.h"
#include "cmdutils.h"

Data Structures

struct  RGBA
struct  RECT
struct  ContextInfo

Defines

#define MAX_FILEPATH   2048
 Max filepath length.
#define min(a, b)   ((a < b) ? a : b)
 Return the smaller of 2 values.
#define max(a, b)   ((a > b) ? a : b)
 Return the larger of 2 values.

Functions

int Configure (void **ctxp, int argc, char *argv[])
void Release (void *ctx)
void Process (void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int src_width, int src_height, int64_t pts)
int load_image (ContextInfo *ci)
void release_image (ContextInfo *ci)
void calc_bounds (ContextInfo *ci, int vid_width, int vid_height)
int alpha_merge (int back, int fore, double alpha)

Detailed Description

Composite an alpha-channel logo with optional drop-shadow onto video.

Sponsored by Fabrik Inc. - bfree(at)fabrikinc.com

Author:
Bob (grafman) Free - bfree(at)graphcomp.com
This vhook demonstrates the use of av_read_image to load still images with alpha/transparency and composite them on video.

Note: PNG support requires that FFMPEG be built with the PNG codec registered/enabled.

EXAMPLE USAGE:

ffmpeg -i INFILE -vhook 'PATH/logo.so -f logo.gif' OUTFILE

Note: the entire vhook argument must be single-quoted.

REQUIRED ARGS:

-f <FILEPATH>

Specifies the image to use for the logo. GIF is supported in normal FFMPEG builds; PNG is supported if enabled in libavcodec and libavformat.

OPTIONAL ARGS:

-x <INT>

Defines a logo offset from the left side of the frame. A negative value (including -0) offsets from the right side.

-y <INT>

Defines a logo offset from the top of the frame. A negative value (including -0) offsets from the bottom.

-w <INT>

Defines a drop shadow to the right of the logo. A negative value shifts the shadow to the left.

-h <INT>

Defines a drop shadow to the bottom of the logo. A negative value shifts the shadow upward.

-d <INT>

Defines the percent opacity of the drop shadow (0 - 100); 100 is opaque. Defaults to 75.

Sample logos and additional notes available at http://graphcomp.com/ffmpeg#plugins

LICENSE:

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA


Function Documentation

int alpha_merge ( int  back,
int  fore,
double  alpha 
)

Merges a pixel component onto another using and alpha-channel value.

Parameters:
back Background pixel value.
fore Foreground pixel value.
alpha Alpha-channel value - from 0.0 (transparent) to 1.0 (opaque).
Returns:
Merged component value.

void calc_bounds ( ContextInfo ci,
int  vid_width,
int  vid_height 
)

Calculates bounding info for video frame, logo and drop-shadow.

Parameters:
ci Context pointer.
vid_width Video frame width in pixels.
vid_height Video frame height in pixels.

int Configure ( void **  ctxp,
int  argc,
char *  argv[] 
)

Allocate context block and capture user parameters. Called by FFMPEG pipeline.

Parameters:
ctxp A handle to receive alloacted context pointer.
argc vhook's argument count.
argv vhook's argument pointers.
Returns:
0 for success; otherwise failure.

int load_image ( ContextInfo ci  ) 

Load and cache an image.

Parameters:
ci Context pointer.
Returns:
0 for success; otherwise failure.

void Process ( void *  ctx,
AVPicture *  picture,
enum PixelFormat  pix_fmt,
int  src_width,
int  src_height,
int64_t  pts 
)

Main video frame proc. Called by FFMPEG pipeline.

Parameters:
ctx Context pointer.
picture Pointer to video frame.
pix_fmt Video frame format constant.
src_width Video frame width in pixels.
src_heigth Video frame height in pixels.
pts Presentation timestamp.

void Release ( void *  ctx  ) 

Release context block. Called by FFMPEG pipeline.

Parameters:
ctx Context pointer.

void release_image ( ContextInfo ci  ) 

Release an image cache.

Parameters:
ci Context pointer.


Generated on Mon Aug 7 20:54:15 2006 for FFMPEG Logo VHook by  doxygen 1.4.7