I am trying to stream the video from an IP camera using Qt multimedia (Qt 5). A similar question could be found here: Play a Live video Stream using Qt but I try to avoid using an other library such as LibVLC. I manage to display the video from a locally stored file but not to display the stream from the IP camera.
Here is my code:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMediaPlayer>
#include <qvideowidget.h>
#include <QVideoWidget>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this-> resize(1000,1000);
QMediaPlayer *mp = new QMediaPlayer(0,0);
QMediaContent *mc = new QMediaContent(QUrl("http://96.10.1.168/mjpg/video.mjpg"));
//QMediaContent *mc = new QMediaContent(QUrl::fromLocalFile("/Users/userName/Desktop/marsUni.mp4"));
mp->setMedia(*mc);
QVideoWidget *vw = new QVideoWidget(this);
vw->setMaximumSize(704, 576);
vw->setMinimumSize(704, 576);
mp->setVideoOutput(vw);
this->setCentralWidget(vw);
vw->show();
mp->play();
}
MainWindow::~MainWindow()
{
delete ui;
}
If I uncomment the line containing QUrl::fromLocalFile, I can display the local file. If I open a network connection in VLC pointing to http://96.10.1.168/mjpg/video.mjpg, I can display the camera stream. I am on Mac OS 10.9.
Why cant I stream the video from the IP camera? Any comments or debugging suggestion would be appreciated.