我正在尝试将我的VlcVideoPlayer
从VLCQt库连接到使用 rts协议从网址流式传输的任何视频。
当前,这是我的代码:
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)
显示视频的当前时间时,时间在变化,因此我猜它正在播放视频,但没有显示。
有人对此有经验吗?我在哪里做错了?
感谢您的帮助!
//编辑:
我没有首先注意到,但是我得到的是音频,而不是视频。
答案 0 :(得分:0)
因此,我在this page上进行搜索后解决了该问题,发现了类似VlcQmlPlayer
的函数,其功能与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"
}
}
答案 1 :(得分:0)
我的代码如下图
Main.cpp
#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");
Main.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"
}
}