解复用器(解封装)的相关函数
◼ avformat_alloc_context();
负责申请一个AVFormatContext结构的内存,并进行简单初始化
◼ avformat_free_context();
释放该结构里的所有东西以及该结构本身
◼ avformat_close_input();
关闭解复用器。关闭后就不再需要使用avformat_free_context 进行释放。
◼ avformat_open_input();
打开输入视频文件
◼ avformat_find_stream_info();
获取视频文件信息
◼ av_read_frame();
读取音视频包
◼ avformat_seek_file();
定位文件
◼ av_seek_frame():
定位帧
流程
测试
#include <iostream>
#include <thread>
using namespace std;
extern "C"
{
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
}
#pragma comment(lib,"avformat.lib")
#pragma comment(lib,"avutil.lib")
#pragma comment(lib,"avcodec.lib")
static double r2d(AVRational r)
{
return r.den == 0 ? 0 : (double)r.num / (double)r.den;
}
void XSleep(int ms)
{
//C++ 11
chrono::milliseconds du(ms);//延迟ms
this_thread::sleep_for(du);
}
int main(int argc, char* argv[])
{
//解封装
cout << " test Demux FFmpeg club" << endl;
const char