简体   繁体   English

使用Qt播放实时视频流

[英]Play a Live video Stream using Qt

Given below is the code for playing a video file using Qt. 下面给出的是使用Qt播放视频文件的代码。 Instead of playing the video I want to play a live video stream from an IP Camera. 我不想播放视频,而是想播放IP摄像机的实时视频流。 Another approach is to embed the VLC Player in Qt and a link for the project is provided here . 另一种方法是将VLC Player嵌入Qt,并在此处提供该项目的链接。 The problem is I do not know how to include the player in Qt. 问题是我不知道如何在Qt中包含播放器。 So how do I proceed? 那么我该如何进行呢?

#include <QApplication>
#include <QtMultimediaWidgets/QVideoWidget>
#include <QtMultimedia/QMediaPlayer>
#include <QtMultimedia/QMediaPlaylist>
#include <QFile>
#include <QHBoxLayout>
#include "DemoPlayer.h"
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QWidget *widget=new QWidget;
    widget->resize(400,300);

    QMediaPlayer *player=new QMediaPlayer;
    QVideoWidget *vw= new QVideoWidget;
    QHBoxLayout *layout=new QHBoxLayout;

    layout->addWidget(vw);
    widget->setLayout(layout);
    player->setVideoOutput(vw);
    player->setMedia(QUrl::fromLocalFile("C:/Users/Administrator/Desktop/1minute.mp4"));
    player->play();
    widget->show();
    qDebug()<<player->availableMetaData()<<player->currentMedia().canonicalUrl();

    return a.exec();
}

follow this code . 遵循此代码。 you can embed a widget inside another widget using a valid window id . 您可以使用有效的窗口ID将一个小部件嵌入另一个小部件内。 How to show output video of other application in Qt? 如何在Qt中显示其他应用程序的输出视频? you can use the qx11embedwidget and qx11embedwidgetcontainer QX11EmbedWidget and QX11EmbedContainer 您可以使用qx11embedwidget和qx11embedwidgetcontainer QX11EmbedWidget和QX11EmbedContainer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM