Qt5 multimedia - mjpeg support
i’m trying to capture mjpeg stream arriving from a ip camera and display the “video” using QMediaPlayer and QVideoWidget.
The code is very basic:
- mediaPlayer = new QMediaPlayer;
- connect(mediaPlayer, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(currentMediaStatus(QMediaPlayer::MediaStatus)));
Unfortunately the one and only status i can receive is QMediaPlayer::LoadingMedia with QMediaPlayer::StoppedState .
The videoWidget doesn’t display anything.
Does QMediaPlayer support mjpeg at all?
Although i do not receive neither QMediaPlayer::InvalidMedia status nor any other error.
Of course i could use QDesktopServices to display the stream with a web browser but i’d prefer using my own video widget…
Env: Qt5.0.1 mingw47, Windows7 ×64
I am facing the same problem but I get an error when loading the ip camera stream http://../mjpeg.cgi
—>“Error: Failed to load source.”
You need to add an error handler in your code in order to get this error message:
connect(mediaPlayer, SIGNAL), this, SLOT));
In handleError method you can get the error message by this call
“Of course i could use QDesktopServices to display the stream with a web browser but i’d prefer using my own video widget…”
Could you be more explicit about this solution, please ? I am really interested.
thanks for your reply!
QMediaPlayer has a static member hasSupport. I called it with the appropriate mime type (video/x-motion-jpeg) to determine whether it is supported or not.
The function returned the QMultimedia::MaybeSupported enum which is quite funny…
I’ll check the error signal tomorrow.
QDesktopServices offers methods for accessing common desktop services on different desktop environments.
The static bool QDesktopServices::openUrl(const QUrl& url) method will open your http://../mjpeg.cgi with your default web browser.