欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 产业 > FFmpeg API

FFmpeg API

2024/10/24 1:54:31 来源:https://blog.csdn.net/weixin_42130300/article/details/142978284  浏览:    关键词: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,可以注释掉。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com