FFmpeg is a complete solution to record, convert and stream audio and video. It includes libavcodec, the leading audio/video codec library. FFmpeg is developed under Linux, but it can compiled under most operating systems, including Windows.
组成部分:
相关网站:
http://ffmpeg.org/
http://www.ffmpeg.com.cn/index.php
FFMPEG包括了多种视音频的CODEC,对于每种CODEC,FFMPEG要求提供一个满足结构体AVCodec的数据结构:
/**
* AVCodec.
*/
typedef struct AVCodec {
const char *name;
enum CodecType type;
enum CodecID id;
int priv_data_size;
int (*init)(AVCodecContext *);
int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
int (*close)(AVCodecContext *);
int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
uint8_t *buf, int buf_size);
int capabilities;
#if LIBAVCODEC_VERSION_INT < ((50<<16)+(0<<8)+0)
void *dummy; // FIXME remove next time we break binary compatibility
#endif
struct AVCodec *next;
void (*flush)(AVCodecContext *);
const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0}
const enum PixelFormat *pix_fmts; ///array of supported pixel formats, or NULL if unknown, array is terminanted by -1
} AVCodec;
这个数据结构中主要包括了CODEC的标识及各种操作函数,如decode 或encode等。这样FFPMEG提供一个统一的调用接口,具体调用哪种CODEC由CODEC标识和操作函数来决定。
一般CODEC的函数调用顺序包括:
avcodec_init
avcodec_register_all
avcodec_find_encoder/decoder
avcodec_open
avcodec_encode_video/encoder_video/ encode_audio/encoder_audio
avcodec_close