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. Showing video from a rtsp ip camera
Forum Updated to NodeBB v4.3 + New Features

Showing video from a rtsp ip camera

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 3.4k Views 1 Watching
  • 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.
  • D Offline
    D Offline
    drakejest
    wrote on last edited by
    #1

    I have hit a bricked wall in trying to show a rtsp from a cctv camera. Im using qt6 and have tried both C++ and QML to no avail. Im currently trying it on windows OS . I can already confirm that in vlc my rtsp link works. I can also confirm that both programs C++ and QML has no problem playing an mp4 file that is stored locally.

    Here is my C++ attempt

        video = new QVideoWidget(this);
        video->setGeometry(80,80,this->width(),this->height());
        video->show();
    
        player = new QMediaPlayer(this);
        audio = new QAudioOutput(this);
    
        connect(player,&QMediaPlayer::errorChanged,this,&MainWindow::mediaPlayerDebugError);
        connect(player,&QMediaPlayer::mediaStatusChanged,this,&MainWindow::mediaPlayerDebugStatus);
    
        player->setVideoOutput(video);
        player->setSource(QUrl("rtsp://admin:admin@192.168.1.199:554/mpeg4/ch0/main/av_stream"));
    
        player->play();
    

    C++ qDebug show me an error

    Status Changed:  QMediaPlayer::LoadingMedia
    Status Changed:  QMediaPlayer::InvalidMedia
    Error:  QMediaPlayer::ResourceError
    

    Here is my QML attempt

    Window {
        id:mainWidow
        width: 600
        height: 600
        visible: true
        title: qsTr("Hello World")
    
        MediaPlayer {
            id: player
            source: "rtsp://admin:admin@192.168.1.199:554/mpeg4/ch0/main/av_stream"
            videoOutput: videoOutput
    
            onErrorOccurred: {
                console.log(player.errorString)
                console.log(player.mediaStatus)
            }
    
            Component.onCompleted: {mainWidow.title = qsTr("started"); player.play()}
        }
    
        VideoOutput {
            id: videoOutput
            anchors.fill: parent
            anchors.horizontalCenter: parent.horizontalCenter
        }
    
    }
    

    QML throws me an error of

    qml: Failed to load source.
    qml: 7  // QMediaPlayer::InvalidMedia
    

    Invalid media seems to be the common problem, does anyone know how to fix this? or if you have successfully played a rtsp stream can you share how you did it? If you need info concerning the ip camera just tell me ill try to look for it.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      drakejest
      wrote on last edited by
      #2

      I have solved the C++ project and now im able to show the stream, but it really delayed around 10 seconds of delay compared to 4-5seconds of delay in VLC

      The problem was i did not include QUrl

      All includes in mainwindow.h

      #include <QMainWindow>
      #include <QMediaPlayer>
      #include <QVideoWidget>
      #include <QAudioOutput>
      #include <QPushButton>
      #include <QUrl>
      #include <QDebug>
      
      1 Reply Last reply
      0
      • Y YANL referenced this topic on
      • R Offline
        R Offline
        rtek1000
        wrote on last edited by
        #3

        I found an onvif client that plays rtsp streams with practically no delay, the library written in c++ with visual studio 2019 is available, but the program's source code is paid, it's expensive, the installed program has qt6 dll.

        https://www.happytimesoft.com/products/onvif-client/index.html

        Another open source alternative is ffplay from ffmpeg, very little delay. Supports H.264 and H265.

        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