FFmpeg API

1. 快速打开媒体文件查看信息

cpp 复制代码
#include "mainwindow.h"
#include <QApplication>
#include <iostream>
#include <QDebug>

#undef main             // 不加这句会直接报错
#include "SDL.h"

extern "C"
{
    #include <libavcodec/avcodec.h>
    #include <libavformat/avformat.h>
    #include <libswscale/swscale.h>
    #include <libavdevice/avdevice.h>
    #include <libavformat/version.h>
    #include <libavutil/time.h>
    #include <libavutil/mathematics.h>
    #include <libavutil/imgutils.h>
}


int main(int argc, char *argv[])
{
    const char *input_file = "test.mp4";

    AVFormatContext *pFormatCtx = nullptr;

    int ret = avformat_open_input(&pFormatCtx, input_file, NULL, NULL);
    if(ret != 0)
    {
        // av_log(nullptr, AV_LOG_ERROR, "Open Input File: %s failed: %s \n", input_file, av_err2str(ret));
        return -1;
    }

    av_dump_format(pFormatCtx, 0, input_file, 0);
    avformat_close_input(&pFormatCtx);

    qDebug() << "Finished! ";
    return 0;
}
  • 重要结构体说明

(1)AVFormatContext :容器或者媒体文件的抽象层次。

(2)AVStream:音频、视频或者字幕流。

(3)AVCodecContext与AVCodec:编码格式和编码器的抽象。

(4)AVPackge:数据包的抽象(未解码的数据)。

(5)AVStream:数据帧的抽象。

  • 上边用到了SDL,可以注释掉。
相关推荐
席万里7 分钟前
Go语言企业级项目使用dlv调试
服务器·开发语言·golang
jerry60924 分钟前
c++流对象
开发语言·c++·算法
fmdpenny24 分钟前
用python写一个相机选型的简易程序
开发语言·python·数码相机
虾球xz29 分钟前
游戏引擎学习第247天:简化DEBUG_VALUE
c++·学习·游戏引擎
海盗强1 小时前
Babel、core-js、Loader之间的关系和作用全解析
开发语言·前端·javascript
猿榜编程1 小时前
python基础-requests结合AI实现自动化数据抓取
开发语言·python·自动化
我最厉害。,。1 小时前
PHP 反序列化&原生类 TIPS&字符串逃逸&CVE 绕过漏洞&属性类型特征
android·开发语言·php
爱编程的鱼1 小时前
C# 类(Class)教程
开发语言·c#
2301_817031651 小时前
C语言-- 深入理解指针(4)
c语言·开发语言·算法
superior tigre2 小时前
C++学习:六个月从基础到就业——模板编程:模板特化
开发语言·c++·学习