使用 Qt MultiMedia 和 Widgets 播放网络流视频 [英] Playing a network streaming video using Qt MultiMedia and Widgets

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

问题描述

我正在尝试构建一个简单的 qt 应用程序,它将播放实时视频流.流媒体视频未在我的应用中播放.我已经使用 qt 播放了本地文件,但无法播放实时视频流.我找到了这个链接,但他们没有帮助我:-

I am trying to build a simple qt application which will play a live video stream. The streaming video is not playing in my app. I have played a local file using qt but i can't play the live video stream. I have found this links but they didn't help me :-

使用 Qt 播放实时视频流

Qt Stream IP 摄像机视频

代码如下:-

#include <QApplication>
#include <QtMultimediaWidgets/QVideoWidget>
#include <QtMultimedia/QMediaPlayer>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QMediaPlayer *player = new QMediaPlayer;
    QMediaContent *mc=new QMediaContent(QUrl("http://192.168.42.129:8080/video"));
    player->setMedia(*mc);
    player->setVolume(50);
    QVideoWidget *videoWidget = new QVideoWidget;
    videoWidget->resize(700,700);
    videoWidget->show();
    player->setVideoOutput(videoWidget);
    player->play();

    qDebug()<<player->availableMetaData()<<player->currentMedia().canonicalUrl();
    qDebug()<<player->errorString();

    return a.exec();
}

我在我的 Android 手机中使用一个应用程序来流式传输视频.流式视频正在 VLC 媒体播放器、Opera 浏览器、Mozilla 浏览器上播放.我尝试过不同的格式,如 MOV、MKV、WEBM(该应用程序说我手机中的硬件渲染器不支持 MP4).请帮忙,坚持一段时间.

I am using an app in my android phone to stream the video. The streamed video is playing on VLC media player, Opera Browser, Mozilla Browser. I have tried different formats like MOV, MKV, WEBM (The app says MP4 is not supported by the hardware renderer in my phone). Please help, stuck on it for a while.

编辑 - 我不想使用任何其他库,如 libVLC,因为我注意到流视频在 vlc 媒体播放器中滞后.它可能存在一些性能问题.

EDIT - I don't want to use any other library like libVLC because I noticed the streaming video is lagging in vlc media player. It may have some performance issues.

推荐答案

我想出了一个办法.我无法使用 QMultimedia 小部件.我不得不使用外部库,例如 libvlcvlc-qt.它们具有良好的 API,并且通常没有性能问题(正如我之前所想的那样).它们很容易与 Qt(及其小部件)集成.

I figured out a way around. I was not able to do with QMultimedia widgets. I had to use external libraries like libvlc or vlc-qt. They have good APIs and generally have no performance issues (as I thought previously). They are very easy to integrate with Qt(and its widgets).

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

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