FFmpeg + VS 开发环境搭建

1 篇文章 0 订阅

概述

下载 FFmpeg build

  • FFmpeg build 分三个版本
    • static 为静态链接. 有 ffmpeg.exe, ffplay.exe, ffprobe.exe
    • shared 为动态链接. 有 exe 和 dll.
    • dev 中有 include 和 lib
  • https://ffmpeg.zeranoe.com/builds/win32/下载. 我们需要shared 版本和dev 版本.

搭建环境

  • 新建文件夹 FFMPEGSDK, 将 dev 中的 include 和 lib, shared 中的 dll 都拷贝过来.
  • 将 FFMPEGSDK 文件夹拷贝到你平时放置 SDK 的位置. eg: E:/FFMPEGSDK. 设置环境变量FFMPEGDIR, 并指定该路径.
  • 新建一个工程. 配置该工程:
    • 头文件检索目录: C/C++-常规-附加包含目录 增加: $(FFMPEGDIR)\include
    • 链接:
      • 链接器-常规-附加库目录 增加: $(FFMPEGDIR)\lib
      • 链接器-输入-附加依赖性 增加:

        $(FFMPEGDIR)\lib\avcodec.lib;$(FFMPEGDIR)\lib\avformat.lib;$(FFMPEGDIR)\lib\avutil.lib;$(FFMPEGDIR)\lib\avdevice.lib;$(FFMPEGDIR)\lib\avfilter.lib;$(FFMPEGDIR)\lib\postproc.lib;$(FFMPEGDIR)\lib\swresample.lib;$(FFMPEGDIR)\lib\swscale.lib;
    • 运行时动态加载: 将各 DLL 复制到exe同级目录.
  • 修改 main.cpp
#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif


#ifdef __cplusplus
extern "C" {
#endif
    /*Include ffmpeg header file*/
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>

#include <libavutil/imgutils.h> 
#include <libavutil/opt.h>    
#include <libavutil/mathematics.h>  
#include <libavutil/samplefmt.h>

    //----代码区---
#ifdef __cplusplus
}
#endif

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    MainWindow w;
    w.show();

    //使用 FFmpeg 功能
    qDebug() << avcodec_configuration();

    return a.exec();
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值