FFmpeg API

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

#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,可以注释掉。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值