QT5.14.2 compiling and deploying QTAV player environment

1, Compilation environment and QTAV introduction

QTAV is an open source cross platform player framework. The framework is developed based on QT and can be compiled, deployed and run on Android, IOS, WINDOWS and Linux platforms.

Introduction to QTAV official website: http://www.qtav.org/

QTAV source code download address GitHub: https://github.com/wang-bin/QtAV


Just download the latest source code directly from GitHub.

The QT environment I currently use is QT5.14.2. The compilers are minGW and VS2017. Both use 32-bit compilers.

QT download address: https://download.qt.io/archive/qt/5.14/5.14.2/

At the time of current compilation, the version of ffmpeg I use is 4.2.2, and the latest version can also be used. As described in the description of QTAV, it is best to use the latest version of ffmpeg.

ffmpeg4.2.2 library address: https://download.csdn.net/download/xiaolong1126626497/13328939

You can also download ffmpeg directly: http://www.ffmpeg.org/download.html

2, Compiling QTAV source code

On GitHub, the author also introduced how to compile and deploy QTAV.
Address: https://github.com/wang-bin/QtAV/wiki/Build-QtAV

The author recommends two methods for compiling under windows:

The first method: directly copy the ffmpeg header file and library file to the compiler directory under the QT installation directory, which is simple and rough.

The second: open the QTAV source code project, modify the qmake.conf file, and specify the header file and library file path of ffmpeg
Let QT compiler find out where ffmpeg library and header file are.

The second method I use here is to directly specify the path without polluting the files in the QT installation directory.

INCLUDEPATH += C:/FFMPEG/ffmpeg_x86_4.2.2/include
LIBS += -LC:/FFMPEG/ffmpeg_x86_4.2.2/lib

After setting the path, click build directly.

If there is no problem with the build, there will be an automatic installation script in the generated directory. Double click Run to automatically copy the files to the QT installation directory.

You can build QTAV source code with VS2017 compiler and minGW compiler respectively, so that both compilers can reference QTAV for player development.

After compiling, QTAV can be used next.

When using the QTAV framework, if the VS2017 compiler is used, an error may be reported during compilation, indicating that the max function cannot be recognized.

The solution is as follows:

QTAV framework library needs to be referenced in QT pro project file:

#LIBS     += -L$$quote(C:\Qt\Qt5.14.2\5.14.2\mingw73_32\lib) -lQtAV1 -lQtAVWidgets1
LIBS     += -L$$quote(C:\Qt\Qt5.14.2\5.14.2\msvc2017\lib) -lQtAV1 -lQtAVWidgets1
LIBS += -lopengl32 -lglu32

3, Developing player using QTAV

3.1 mainwindow.cpp source code

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    Widgets::registerRenderers();
    VideoOutput *m_vo;
    AVPlayer *m_player;
    m_player = new AVPlayer(this);
    m_vo = new VideoOutput(this);
    m_player->setRenderer(m_vo);
    setCentralWidget(m_vo->widget());
    m_player->play("D:/test1080.flv");
}

MainWindow::~MainWindow()
{
    delete ui;
}

3.2 mainwindow.h source code

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include <QtAV>
#include <QtAVWidgets>

using namespace QtAV;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H

3.3 operation effect

Tags: Qt

Posted on Mon, 08 Nov 2021 08:38:27 -0500 by kodstationen