使用Qt播放实时视频流 [英] Play a Live video Stream using Qt

查看:2770
本文介绍了使用Qt播放实时视频流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是使用Qt播放视频文件的代码。而不是播放视频,我想播放来自IP摄像机的实时视频流。另一种方法是在Qt中嵌入VLC Player,并在此处提供项目的链接。问题是我不知道如何将播放器包含在Qt中。那么如何继续呢?

Given below is the code for playing a video file using Qt. Instead of playing the video I want to play a live video stream from an IP Camera. Another approach is to embed the VLC Player in Qt and a link for the project is provided here. The problem is I do not know how to include the player in 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();
}


推荐答案

您可以使用有效的窗口ID将窗口小部件嵌入另一个窗口小部件。
如何显示输出Qt中其他应用程序的视频?
您可以使用qx11embedwidget和qx11embedwidgetcontainer
QX11EmbedWidget和QX11EmbedContainer

follow this code . you can embed a widget inside another widget using a valid window id . How to show output video of other application in Qt? you can use the qx11embedwidget and qx11embedwidgetcontainer QX11EmbedWidget and QX11EmbedContainer

这篇关于使用Qt播放实时视频流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆