FFMPEG 框架代码阅读简介 FFmpeg 是一个集录制、转换、音/视频编码解码功能为一体的完整的开源解决方案。 FFmpeg 的开发是基于 Linux 操作系统,但是可以在大多数操作系统中编译和使用。 FFmpeg 支持 MPEG 、DivX 、MPEG4 、AC3 、DV、FLV 等40多种编码, AVI 、MPEG 、OGG 、Matroska 、ASF 等90多种解码. TCPMP, VLC, MPlayer 等开源播放器都用到了 FFmpeg 。 FFmpeg 主目录下主要有 libavcodec 、libavformat 和libavutil 等子目录。其中 libavcodec 用于存放各个 encode/decode 模块, libavformat 用于存放 muxer/demuxer 模块, libavutil 用于存放内存操作等常用模块。以flash movie 的flv 文件格式为例, muxer/demuxer 和 文件在 libavformat 目录下, encode/decode 和 在libavcodec 目录下。 muxer/demuxer 与 encoder/decoder 定义与初始化 muxer/demuxer 和encoder/decoder 在FFmpeg 中的实现代码里,有许多相同的地方,而二者最大的差别是muxe r和demuxe r分别是不同的结构AVOutputFormat 与AVInputFormat ,而 encoder 和decoder 都是用的 AVCodec 结构。 muxer/demuxer 和encoder/decoder 在FFmpeg 中相同的地方有: 二者都是在 main() 开始的 av_register_all() 函数内初始化的。二者都是以链表的形式保存在全局变量中的。 muxer/demuxer 是分别保存在全局变量 AVOutputFormat *first_oformat 与 AVInputFormat *first_iformat 中的。 encoder/decoder 都是保存在全局变量 AVCodec *first_avcodec 中的。二者都用函数指针的方式作为开放的公共接口。 demuxer 开放的接口有: int (*read_probe)(AVProbeData *); int(*read_header)(struct AVFormatContext *,AVFormatParameters *ap); int (*read_packet)(struct AVFormatContext *,AVPacket *pkt); int (*read_close)(struct AVFormatContext *); int (*read_seek)(struct AVFormatContext *,int stream_index, int64_t timestamp, int flags); muxer 开放的接口有: int (*write_header)(struct AVFormatContext *); int (*write_packet)(struct AVForm
FFMPEG框架 来自淘豆网www.taodocs.com转载请标明出处.