3

我正在尝试将我VlcVideoPlayer的 VLCQt 库连接到使用rts 协议从 url 流式传输的任何视频。

目前,这是我的代码:

import QtQuick 2.0
import VLCQt 1.0
VlcVideoPlayer {
    property var first: true
    id: vidwidget
    anchors.fill: parent
    objectName: "vlcMediaPlayer"
    url: "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov" // "http://samples.mplayerhq.hu/A-codecs/AAC/ct_faac.mp4"
    volume: 100
    aspectRatio: "16:10"
    autoplay: true
}

它适用于https://,但是当我尝试将其更改为rtps://时,我的控制台只打印出来

QML debugging is enabled. Only use this in a safe environment.
VLC-Qt "1.1.0" initialised
Using libvlc version: "2.2.2 Weatherwax"
Format: chroma: I420 width: 240 height: 162 pitches: 0 lines: 0
YV12 3 0
libvlc Error: "Track identifier not found"
libvlc: Failed to change zoom
libvlc: Failed to set on top
libvlc: Failed to change source AR

什么也没有发生 - 没有视频出现。

当我尝试用 显示视频的当前时间时console.log(time),时间正在改变,所以我猜它播放视频,但没有显示。

有人有这方面的经验吗?我在哪里做错了?

谢谢你的帮助!

//编辑:

我没有先注意到,但我得到的是音频,而不是视频。

4

3 回答 3

2

因此,我在此页面上进行了一些搜索后解决了这个问题,我发现了类似的东西VlcQmlPlayer,功能几乎与 in 相同VlcQmlVideoPlayer,除了它更新并且它的源是VlcQmlVideoOutput. 所以我为 QML 注册了几种类型:

qmlRegisterUncreatableType<Vlc>("Vlc", 1, 1, "Vlc", QStringLiteral("Vlc cannot be instantiated directly"));
qmlRegisterUncreatableType<VlcQmlSource>("VlcSource", 1, 1, "VlcSource", QStringLiteral("VlcQmlSource cannot be instantiated directly"));
qmlRegisterUncreatableType<VlcTrackModel>("VlcTrackModel", 1, 1, "VlcTrackModel", QStringLiteral("VlcTrackModel cannot be instantiated directly"));
qmlRegisterType<VlcQmlVideoOutput>("VlcVideoOutput", 1, 1, "VlcVideoOutput");
qmlRegisterType<VlcQmlPlayer>("VlcPlayer", 1, 1, "VlcPlayer");

之后,我像这样在 QML 中使用它

import VlcPlayer 1.1
import Vlc 1.1
import VlcVideoOutput 1.1

VlcVideoOutput {
    source:
        VlcPlayer {
        id: vlcPlayer
        url: "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov"
    }
}
于 2018-08-13T09:01:08.930 回答
0

我的代码如下所示

主文件

#include <QtCore/QCoreApplication>
#include <QtGui/QGuiApplication>
#include <QtQuick/QQuickView>

#include <VLCQtCore/Common.h>
#include <VLCQtQml/QmlSource.h>
#include <VLCQtCore/TrackModel.h>
#include <VLCQtQml/Qml.h>
#include <VLCQtQml/QmlVideoObject.h>
#include <VLCQtCore/MediaPlayer.h>
#include <VLCQtQml/QmlPlayer.h>
#include <VLCQtQml/QmlVideoOutput.h>
#include <QtPlugin>

int main(int argc, char *argv[])
{
    QCoreApplication::setApplicationName("VLC-Qt QML Player");
    QCoreApplication::setAttribute(Qt::AA_X11InitThreads);

    QGuiApplication app(argc, argv);
    VlcCommon::setPluginPath(app.applicationDirPath() + "/plugins");
    qmlRegisterUncreatableType<Vlc>("Vlc", 1, 1, "Vlc", QStringLiteral("Vlc cannot be instantiated directly"));
    qmlRegisterUncreatableType<VlcQmlSource>("VlcSource", 1, 1, "VlcSource", QStringLiteral("VlcQmlSource cannot be instantiated directly"));
    qmlRegisterUncreatableType<VlcTrackModel>("VlcTrackModel", 1, 1, "VlcTrackModel", QStringLiteral("VlcTrackModel cannot be instantiated directly"));
    qmlRegisterType<VlcQmlVideoOutput>("VlcVideoOutput", 1, 1, "VlcVideoOutput");
    qmlRegisterType<VlcQmlPlayer>("VlcPlayer", 1, 1, "VlcPlayer");

主.qml

import VlcPlayer 1.1
import Vlc 1.1
import VlcVideoOutput 1.1

VlcVideoOutput {
    source:
        VlcPlayer {
        id: vlcPlayer
        url: "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov"
    }
}
于 2021-08-11T13:19:32.877 回答
0

作为参考,您可以将所有这些 qmlRegister() 函数替换为:

#include <VLCQtCore/Common.h>
#include <VLCQtQml/Qml.h>

int main( )
{
...
    VlcCommon::setPluginPath( app.applicationDirPath( ) + "/plugins" );
    VlcQml::registerTypes( );
...
}

import VLCQt 1.1

VlcVideoOutput {
    source:
        VlcPlayer {
            url: "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov"
    }
}
于 2021-09-21T19:37:41.857 回答