• QtAV环境配置


    本文章主要是使用MSVC编译器,因为QtAV是依赖FFmpeg的,所以需要下载QtAV源码和QtAV-depends-windows-x86+x64;
    官网地址:http://www.qtav.org/
    Github 地址:https://github.com/wang-bin/QtAV

    1,解压
    将文件解压到同一个文件夹下:
    在这里插入图片描述
    2,修改.qmake.conf配置文件
    在这里插入图片描述

    INCLUDEPATH += $$PWD/../QtAV-depends-windows-x86+x64/include
    LIBS += -L$$PWD/../QtAV-depends-windows-x86+x64/lib/x64
    
    • 1
    • 2

    3.打开项目
    在这里插入图片描述
    在这里插入图片描述
    4、分别构建Debug和Release
    在这里插入图片描述
    在这里插入图片描述
    5.分别双击执行Debug和Release下的sdk_install.bat文件,会将QtAV编译的库和头文件,模块等都拷贝到Qt内部模块种。
    在这里插入图片描述
    在这里插入图片描述
    6.这里需要 release下的prl文件拷贝到lib下
    在这里插入图片描述

    7、新建工程
    添加三个环境变量,主要是配置FFmpeg库的路径设置 CPATH 到 H:\QtCode\CSOI\CSOI\VisualizationSafety\VisualizationAVCell\QtAV-depends-windows-x86+x64\include
    设置 LD_LIBRARY_PATH 到 H:\QtCode\CSOI\CSOI\VisualizationSafety\VisualizationAVCell\QtAV-depends-windows-x86+x64\bin\x64
    设置 LIBRARY_PATH 到 H:\QtCode\CSOI\CSOI\VisualizationSafety\VisualizationAVCell\QtAV-depends-windows-x86+x64\lib\x64
    在这里插入图片描述
    .pro 文件中添加模块
    在这里插入图片描述

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../qtav/build-QtAV-Desktop_Qt_5_12_4_MSVC2015_64bit-Release/lib_win_x86_64/ -lQtAV1
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../qtav/build-QtAV-Desktop_Qt_5_12_4_MSVC2015_64bit-Release/lib_win_x86_64/ -lQtAV1d
    
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../qtav/build-QtAV-Desktop_Qt_5_12_4_MSVC2015_64bit-Release/lib_win_x86_64/ -lQtAVWidgets1
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../qtav/build-QtAV-Desktop_Qt_5_12_4_MSVC2015_64bit-Release/lib_win_x86_64/ -lQtAVWidgets1d
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    .h
    
    ```cpp
    #include 
    #include 
    #include 
    
    using namespace QtAV;
    
    class VisualizationAVCell : public QLabel
    {
        Q_OBJECT
    public:
        explicit VisualizationAVCell(QWidget *parent = nullptr);
        ~VisualizationAVCell();
    
    signals:
    
    public slots:
        void slot_play();
    
        void slot_pause();
    
        void slot_stop();
    
    private:
        QtAV::VideoOutput *m_vo;
        QtAV::AVPlayer *m_player;
    };
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30

    .cpp

    #include 
    #include 
    
    VisualizationAVCell::VisualizationAVCell(QWidget *parent) : QLabel(parent)
    {
        QtAV::Widgets::registerRenderers();
    
        m_player = new QtAV::AVPlayer(this);
        m_vo = new QtAV::VideoOutput(this);
    
        if(nullptr == m_vo->widget())
            return;
    
        QGridLayout *grid = new QGridLayout;
        grid->addWidget(m_vo->widget());
        this->setLayout(grid);
        m_player->setRenderer(m_vo);
    }
    
    VisualizationAVCell::~VisualizationAVCell()
    {
    
    }
    
    void VisualizationAVCell::slot_play()
    {
        m_player->play("H:/QtCode/CSOI/CSOI/testfile/av.mp4");
    }
    
    void VisualizationAVCell::slot_pause()
    {
        m_player->pause();
    }
    
    void VisualizationAVCell::slot_stop()
    {
        m_player->stop();
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
  • 相关阅读:
    【openGauss】一种可能是目前最快的从ORACLE同步数据到MogDB(openGauss)的方式
    C++ 类的声明笔记
    防火墙部署模式 -- 单臂路由模式
    Scrapy框架介绍
    AI算法工程师 | 03人工智能基础-Python科学计算和可视化(二)Matplotlib
    设计模式——外观模式
    热点参数流控(Sentinel)
    手写RPC框架-注册中心实现
    推荐算法在商城系统实践
    c++单例模式包括懒汉模式和饿汉模式(优劣势分析和改进方法)
  • 原文地址:https://blog.csdn.net/weixin_41349971/article/details/127973858