Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt5 multimedia - mjpeg support
Forum Update on Monday, May 27th 2025

Qt5 multimedia - mjpeg support

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 12.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vwinnie
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • N Offline
      N Offline
      noah.k
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • N Offline
        N Offline
        noah.k
        wrote on last edited by
        #3

        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()));@

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vwinnie
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • N Offline
            N Offline
            noah.k
            wrote on last edited by
            #5

            Hi Rudolf,

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

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vwinnie
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved