linux下qt5引用ffmpeg

首先保证linux已经成功安装ffmpeg,测试下面的命令有输出表示已经成功安装ffmpeg

[root@localhost bin]# ./ffmpeg
ffmpeg version 4.4.git Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-44)
  configuration: --prefix=/usr/local/ffmpeg --enable-debug=3 --disable-static --enable-shared --enable-sdl2
  libavutil      57. 23.100 / 57. 23.100
  libavcodec     59. 23.100 / 59. 23.100
  libavformat    59. 18.101 / 59. 18.101
  libavdevice    59.  5.100 / 59.  5.100
  libavfilter     8. 27.100 /  8. 27.100
  libswscale      6.  5.100 /  6.  5.100
  libswresample   4.  4.100 /  4.  4.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

其次保证已经安装了qt5和qt-creator,不会的看我的另一篇文章,有介绍怎么安装
新建一个普通的c++工程
在这里插入图片描述
一路下一步就建好了

在建好的项目目录下面新建一个lib目录,把装好的ffmpeg目录拷贝到这个目录下。

修改xxx.pro文件,加入下面代码



unix{

INCLUDEPATH += $$PWD/lib/ffmpeg/include

LIBS += -L$$PWD/lib/ffmpeg/lib -lavcodec -lavdevice -lavfilter -lavformat -lavutil -lswresample -lswscale

}

如图
在这里插入图片描述

修改mian.cpp,代码如下

#include <iostream>

using namespace std;

extern "C"
{
    #include "libavcodec/avcodec.h"
    #include "libavformat/avformat.h"
    #include "libswscale/swscale.h"
    #include "libavdevice/avdevice.h"
}

int main(int argc, char *argv[])
{
    cout << "Hello ffmpeg!" << endl;
    avdevice_register_all();
    unsigned version=avcodec_version();
    cout<< "version is :"<<version;
    return 0;
}

如图:
在这里插入图片描述

编译执行如图,表示集成ffmpeg成功
在这里插入图片描述

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

reg183

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值