簡體   English   中英

在C ++中使用Qt VLC庫播放RTSP視頻

[英]Play RTSP video with Qt VLC libary in C++

我正在嘗試將VlcVideoPlayer庫中的VlcVideoPlayer連接到使用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)顯示視頻的當前時間console.log(time) ,時間在改變,因此我猜它正在播放視頻,但沒有顯示。

有人對此有經驗嗎? 我在哪里做錯了?

謝謝你的幫助!

//編輯:

我最初沒有注意到,但是我得到的是音頻,但不是視頻。

所以,我經過一番搜索上解決它這個頁面 ,我發現類似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"
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM