Qt5 multimedia - mjpeg support



  • Hi all,

    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)));
    mediaPlayer->setMedia(QUrl("http://security.camera.local/mjpg/video.mjpg"));
    mediaPlayer->setVideoOutput(videoWidget);
    videoWidget->show();
    mediaPlayer->play();
    @

    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 x64

    Thanks:
    Rudolf



  • Hello,

    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(error(QMediaPlayer::Error)), this, SLOT(handleError()));

    In handleError method you can get the error message by this call -> mediaPlayer->errorString()

    You said:
    "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.

    Noah



  • You need to add an error handler in your code in order to get this error message:
    @connect(mediaPlayer, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(handleError()));@



  • Hi Noah,

    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.

    Rudolf



  • Hi Rudolf,

    Take a look at "this":http://code.google.com/p/qimagegrabber/ project.



  • Appears promising...

    Unfortunately now i have to go one step further. The app must support rtsp streams as well so i try to use "vlc-qt":http://qt-apps.org/content/show.php?content=133649 now


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.