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 :-
Play a Live video Stream using Qt
Here is the code:-
#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();
}
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.
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.
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).