Compile qtav source package (qt5.15+msvc2019), use vlc media player to generate rtsp url and open it through qtav in qml client

QTAV source package compilation

download source code

Download dependent libraries (with ffmepg and other content in it)
https://sourceforge.net/projects/qtav/files/depends/QtAV-depends-windows-x86+x64.7z/download
Download the source package
https://github.com/wang-bin/QtAV
  • update submodule
cd QtAV && git submodule update --init

Decompress the QTAV source code and dependent libraries in the same root directory, otherwise the content of .qmake.conf may need to be changed later .

Configuration Environment

Copy the lib\x64, bin\x64, and include files of the dependent library to the Qt installation directory (Qt\5.15.2\msvc2019_64).

Open the .qmake.conf file

add two lines

INCLUDEPATH += $$PWD/../QtAV-depends-windows-x86+x64/include
#这里我们要注意 如果我们编译器是64位的 填以下路径
#LIBS += -L$$PWD/../QtAV-depends-windows-x86+x64/lib/x64
#这里我们要注意 如果我们编译器是32位的 填以下路径
LIBS += -L$$PWD/../QtAV-depends-windows-x86+x64/lib

Construct

Ah, open QtAV.pro, and then build, I chose the release version. You will encounter an error in the middle: XXX is the usage in C++17. I chose to include it in the pro file CONFIG += C++17. Then the construction is completed, and then the qml project in the examples can be run normally. lib_win_x86_64The .lib and .dll library files inside are the compiled QTAV third-party libraries we need. Refer to [Qt open source audio and video framework module QtAV] 01: Introduction, compilation and simple use.

install qtav

Find sdk_install.bat under the compilation directory of QTAV and click Install, then it is installed.

Using QTAV in QML

Qt may not recognize qtav in QML, so it can be added in the pro file QML_IMPORT_PATH += [QtAVSourceCodeDir]/qml. Refer to Use QtAV In Your Projects .

  • test.pro
QT       += qml quick

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp

HEADERS +=

FORMS +=

# Default rules for deployment.
qnx: target.path = /tmp/$${
    
    TARGET}/bin
else: unix:!android: target.path = /opt/$${
    
    TARGET}/bin
!isEmpty(target.path): INSTALLS += target

RESOURCES += \
    qrc.qrc

QML_IMPORT_PATH += [QtAVSourceCodeDir]/qml


  • main.cpp
#include<QQmlEngine>
#include<QQmlContext>
#include<QQmlApplicationEngine>
#include<QApplication>

int main(int argc, char *argv[])
{
    
    
    QApplication a(argc, argv);
    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

    if (engine.rootObjects().isEmpty())
        return -1;
    return a.exec();
}

  • main.qml
import QtQuick 2.9
import QtQuick.Window 2.2
import QtAV 1.6


Window {
    
    
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    Video {
    
    
        id: video
        anchors.fill: parent   
        source: "D://test.mp4"
    }
    MouseArea {
    
    
        anchors.fill: parent
        onClicked: video.play()
    }

}

Push and pull streams using vlc media player

Download VLC media player

Go to the official website to download

push stream

Menu -> Media -> Stream. Click Add, add an MP4 video, click Stream.
insert image description here
Click Next
insert image description here
to select RTSP, click Add,
insert image description here
the port defaults, and the path can be entered by yourself.
insert image description here
This can be kept as the default
insert image description here
Click Stream
insert image description here
Don't close this window at this time!

open in qml

  • main.qml
import QtQuick 2.9
import QtQuick.Window 2.2
import QtAV 1.6

//修改后
Window {
    
    
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    Video {
    
    
        id: video
        anchors.fill: parent    //跟随父节点大小 全屏
         source:"rtsp://127.0.0.1:port//xxx"
    }
    MouseArea {
    
    
        anchors.fill: parent
         onClicked: video.play()

    }

}

Then the video can be played, but sometimes it is stuck, sometimes the screen is black, and sometimes the picture is very unclear, which may be a network problem. This issue remains to be resolved.

Use vlc for camera capture, RTSP streaming, playback

At present, this problem has not been studied. You can first refer to using vlc for camera capture, RTSP streaming, and playback .

Guess you like

Origin blog.csdn.net/qaaaaaaz/article/details/131538398