没有合适的资源?快使用搜索试试~ 我知道了~
ffmpeg结构体以及函数介绍
需积分: 9 15 下载量 182 浏览量
2012-07-08
16:59:47
上传
评论 2
收藏 141KB DOC 举报
温馨提示
试读
30页
本文对在使用ffmpeg进行音视频编解码时使用到的一些函数做一个简单介绍,我当前使用的ffmpeg版本为:0.8.5,因为本人发现在不同的版本中,有些函数名称会有点小改动,所以在此有必要说明下ffmpeg的版本号。
资源推荐
资源详情
资源评论
本文对在使用 ffmpeg 进行音视频编解码时使用到的一些函数做一个简
单介绍,我当前使用的 ffmpeg 版本为:0.8.5,因为本人发现在不同的版本
中,有些函数名称会有点小改动,所以在此有必要说明下 ffmpeg 的版本
号。
ffmpeg 本人也是刚接触,本文将采用累加的方法逐个介绍我使用到
的函数,如有不妥之处,还望谅解!
头文件引入方法:
extern"C"
{
#include"libavcodec/avcodec.h"
#include"libavformat/avformat.h"
#include"libavutil/avutil.h"
#include"libavutil/mem.h"
#include"libavutil/fifo.h"
#include"libswscale/swscale.h"
};
1 avcodec_init()
/**
* Initialize libavcodec.
* If called more than once, does nothing.
*
* @warning This function must be called before any other
libavcodec
* function.
*
* @warning This function is not thread-safe.
*/
voidavcodec_init(void);
// 初始化 libavcodec,一般最先调用该函数
//引入头文件:\#include"libavcodec/avcodec.h"
// 实现在: \ffmpeg\libavcodec\utils.c
// 该函数必须在调用 libavcodec 里的其它函数前调用,一般在程序
启动或模块初始化时调用,如果你调用了多次也无所谓,因为后面的
调用不会做任何事情.从函数的实现里你可以发现,代码中对多次调
用进行了控制.
// 该函数是非线程安全的
2 av_register_all()
/**
* Initialize libavformat and register all the muxers, demuxers
and
* protocols. If you do not call this function, then you can select
* exactly which formats you want to support.
*
* @see av_register_input_format()
* @see av_register_output_format()
* @see av_register_protocol()
*/
voidav_register_all(void);
// 初始化 libavformat 和注册所有的 muxers、demuxers 和
protocols,
// 一般在调用 avcodec_init 后调用该方法
// 引入头文件:#include"libavformat/avformat.h"
// 实现在:\ffmpeg\libavformat\allformats.c
// 其中会调用 avcodec_register_all()注册多种音视频格式的编解
码器,并注册各种文件的编解复用器
// 当然,你也可以不调用该函数,而通过选择调用特定的方法来
提供支持
3 avformat_alloc_context()
/**
* Allocate an AVFormatContext.
* avformat_free_context() can be used to free the context and
everything
* allocated by the framework within it.
*/
AVFormatContext *avformat_alloc_context(void);
// 分配一个 AVFormatContext 结构
// 引入头文件:#include"libavformat/avformat.h"
// 实现在:\ffmpeg\libavformat\options.c
// 其中负责申请一个 AVFormatContext 结构的内存,并进行简单初
始化
// avformat_free_context()可以用来释放该结构里的所有东西以及
该结构本身
// 也是就说使用 avformat_alloc_context()分配的结构,需要使用
avformat_free_context()来释放
// 有些版本中函数名可能为: av_alloc_format_context();
4 avformat_free_context()
/**
* Free an AVFormatContext and all its streams.
* @param s context to free
剩余29页未读,继续阅读
资源评论
Elva330
- 粉丝: 2
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功