avformat_open_input
来源:互联网 发布:手机淘宝旺旺名怎么改 编辑:程序博客网 时间:2024/06/11 08:15
FFMPEG打开媒体的的过程开始于avformat_open_input,因此该函数的重要性不可忽视。
在该函数中,FFMPEG完成了:
输入输出结构体AVIOContext的初始化;
输入数据的协议(例如RTMP,或者file)的识别(通过一套评分机制):1判断文件名的后缀2读取文件头的数据进行比对;
使用获得最高分的文件协议对应的URLProtocol,通过函数指针的方式,与FFMPEG连接(非专业用词);
剩下的就是调用该URLProtocol的函数进行open,read等操作了
以下是通过eclipse+MinGW调试FFMPEG源代码获得的函数调用关系图
可见最终都调用了URLProtocol结构体中的函数指针。
URLProtocol结构是一大堆函数指针的集合(avio.h文件)参见第四章数据结构
URLProtocol功能就是完成各种输入协议的读写等操作
但输入协议种类繁多,它是怎样做到“大一统”的呢?
原来,每个具体的输入协议都有自己对应的URLProtocol。
比如file协议(FFMPEG把文件也当做一种特殊的协议)(*file.c文件)
URLProtocol ff_pipe_protocol = {
.name = "pipe",
.url_open = pipe_open,
.url_read = file_read,
.url_write = file_write,
.url_get_file_handle = file_get_handle,
.url_check = file_check,
};
或者rtmp协议(此处使用了librtmp)(librtmp.c文件)
URLProtocol ff_rtmp_protocol = {
.name = "rtmp",
.url_open = rtmp_open,
.url_read = rtmp_read,
.url_write = rtmp_write,
.url_close = rtmp_close,
.url_read_pause = rtmp_read_pause,
.url_read_seek = rtmp_read_seek,
.url_get_file_handle = rtmp_get_file_handle,
.priv_data_size = sizeof(RTMP),
.flags = URL_PROTOCOL_FLAG_NETWORK,
};
可见它们把各自的函数指针都赋值给了URLProtocol结构体的函数指针
因此avformat_open_input只需调用url_open,url_read这些函数就可以完成各种具体输入协议的open,read等操作了
- avformat_open_input
- avformat_open_input()
- FFMPEG-avformat_open_input
- FFMPEG-avformat_open_input
- FFMPEG-avformat_open_input
- ffmpeg avformat_open_input详解
- avformat_open_input 打开分析
- avformat_open_input()源码分析
- avformat_open_input超时问题
- FFmpeg图解:avformat_open_input()
- 解决avformat_open_input()不返回
- avformat_open_input函数分析
- FFMPEG函数之avformat_open_input
- ffmpeg源代码分析之avformat_open_input
- FFmpeg源代码简单分析:avformat_open_input()
- ffmpeg设置avformat_open_input( )超时 -stimeout
- FFmpeg源代码简单分析:avformat_open_input()
- FFmpeg源代码简单分析:avformat_open_input
- 关于不同数据类型之间赋值的问题
- 《精益系列丛书》精益创业 互联网创业指导
- 人脸识别经典算法(一):特征脸(Eigenface)
- C# 图形面积计算
- IoC容器配置Bean(3)
- avformat_open_input
- android 上传文件到服务器代码实例
- WebRTC源代码探索之旅——多线程篇-8
- cordova android (一)
- Java进程间通信的方法
- viewpager与viewflipper详解以及横幅轮播页Banner
- uboot 分析及移植
- 头文件
- 剑指offer|反转链表