1 avformat_open_input
作用:打开媒体文件并获取媒体文件信息,可以是本地文件,也可以时网络流。
函数原型:
int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options);
ps:输入文件的AVFormatContext,会将获取的信息填充进去;
url:流地址,可以是本地文件、RTMP、RTP协议流地址;
fmt:一般为NULL,表示自动检测流格式,否则会使用提供的值作为流格式;
options:一般为NULL;
返回值:0表示成功,负值表示失败。
注意:需要调用avformat_close_input关闭AVFormatContext。
2 avformat_find_stream_info
作用:读取音视频包来获取流信息,常用于avformat_open_input函数之后。像flv这种头很简单的格式,从头中只知道是否存在音视频流,但不知道流的编解码信息,该函数会去读音视频包来获取流的编解码信息。
函数原型:
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options);
ic:输入文件的AVFormatContext;
options:用户自定义选项,一般为NULL;
返回值:>= 0表示成功。
3 av_dump_format
作用:用于将AVFormatContext中媒体格式的信息进行格式化输出。
函数原型:
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output);
ic:输入文件的AVFormatContext;
index:输出音视频流的索引,-1表示输出所有音视频流信息;
url:媒体流地址;
is_output:0表示输入上下文,1表示输出上下文;
4 avformat_alloc_output_context2
作用:初始化一个用于输出的AVFormatContext结构体,需要调用avformat_free_context进行释放。
函数原型:
int avformat_alloc_output_context2(AVFormatContext **ctx, const AVOutputFormat *oformat, const char *format_name, const char *filename);


2845

被折叠的 条评论
为什么被折叠?



