FFmpeg API

农民  金牌会员 | 2024-10-21 10:52:15 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 882|帖子 882|积分 2646

1. 快速打开媒体文件检察信息

  1. #include "mainwindow.h"
  2. #include <QApplication>
  3. #include <iostream>
  4. #include <QDebug>
  5. #undef main             // 不加这句会直接报错
  6. #include "SDL.h"
  7. extern "C"
  8. {
  9.     #include <libavcodec/avcodec.h>
  10.     #include <libavformat/avformat.h>
  11.     #include <libswscale/swscale.h>
  12.     #include <libavdevice/avdevice.h>
  13.     #include <libavformat/version.h>
  14.     #include <libavutil/time.h>
  15.     #include <libavutil/mathematics.h>
  16.     #include <libavutil/imgutils.h>
  17. }
  18. int main(int argc, char *argv[])
  19. {
  20.     const char *input_file = "test.mp4";
  21.     AVFormatContext *pFormatCtx = nullptr;
  22.     int ret = avformat_open_input(&pFormatCtx, input_file, NULL, NULL);
  23.     if(ret != 0)
  24.     {
  25.         // av_log(nullptr, AV_LOG_ERROR, "Open Input File: %s failed: %s \n", input_file, av_err2str(ret));
  26.         return -1;
  27.     }
  28.     av_dump_format(pFormatCtx, 0, input_file, 0);
  29.     avformat_close_input(&pFormatCtx);
  30.     qDebug() << "Finished! ";
  31.     return 0;
  32. }
复制代码



  • 重要结构体说明
        (1)AVFormatContext :容器大概媒体文件的抽象条理。
        (2)AVStream:音频、视频大概字幕流。
        (3)AVCodecContext与AVCodec:编码格式和编码器的抽象。
        (4)AVPackge:数据包的抽象(未解码的数据)。
        (5)AVStream:数据帧的抽象。


  • 上边用到了SDL,可以解释掉。




免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

农民

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表