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. How to record and play RTSP stream from ip camera
Forum Updated to NodeBB v4.3 + New Features

How to record and play RTSP stream from ip camera

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 5 Posters 4.2k Views 3 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.
  • S Offline
    S Offline
    Stuhalsky Alex
    wrote on last edited by Stuhalsky Alex
    #1

    I have an ip camera that allows me to see live stream over some url: rtsp://192.168...
    I want to display that stream and at the same time record it to local file.

    The main question is how to do it?

    I implemented stream display via QVideoWidget and QMediaPlayer.
    As i can see over qt docs QMediaRecorder is used to record and store video as shown in example. QMediaRecorder uses a QMediaContent* as a source and QMediaPlayer inherits QMediaContent.

    So may be it is possible to record video from QMediaPlayer?

    I can't find any example of how it can be done except this one. I tried it. It compiles and runs, but it doesn't work. May be i miss something?

    Or from the other hand may be it is possible to create a QCamera instance that is connected to my rtsp url?

    I'm using Qt 5.12.8. OS Kubuntu 20.04

    Thanks in advance.

    jsulmJ 1 Reply Last reply
    0
    • S Stuhalsky Alex

      I have an ip camera that allows me to see live stream over some url: rtsp://192.168...
      I want to display that stream and at the same time record it to local file.

      The main question is how to do it?

      I implemented stream display via QVideoWidget and QMediaPlayer.
      As i can see over qt docs QMediaRecorder is used to record and store video as shown in example. QMediaRecorder uses a QMediaContent* as a source and QMediaPlayer inherits QMediaContent.

      So may be it is possible to record video from QMediaPlayer?

      I can't find any example of how it can be done except this one. I tried it. It compiles and runs, but it doesn't work. May be i miss something?

      Or from the other hand may be it is possible to create a QCamera instance that is connected to my rtsp url?

      I'm using Qt 5.12.8. OS Kubuntu 20.04

      Thanks in advance.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @Stuhalsky-Alex said in How to record and play RTSP stream from ip camera:

      but it doesn't work

      Did you try to find out what exactly does not work? Is the recorded file created? Does it contain anything?...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      1
      • B Offline
        B Offline
        Bonnie
        wrote on last edited by Bonnie
        #3

        What platform?
        AFAIK Qt doesn't support rtsp urls on Windows.
        I don't think it is possible to create a QCamera connected to some live stream url.
        But QMediaRecorder accepts all QMediaObject classes, not only QCamera, so it may be possible to record if Qt can play the url.

        S 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Stuhalsky-Alex said in How to record and play RTSP stream from ip camera:

          but it doesn't work

          Did you try to find out what exactly does not work? Is the recorded file created? Does it contain anything?...

          S Offline
          S Offline
          Stuhalsky Alex
          wrote on last edited by
          #4

          Hi @jsulm. Yes, i tried.

          In the first case i created file for writing manually and made sure it can be opened. The files were indeed created, but 0 bytes were written. I checked QMediaRecorder state. It have not been changed at all. Corresponding singnal was not emitting. Actual location was invalid and output location was empty string.

          In the second case i tried simply to set output location in QMediaRecorder instance, but file was not created at all. Actual location was invalid, but output location contained correct QUrl path to local file.

          I may miss something, because i tried many solutions during last couple of days. I can reimplement any solution that is supposed to work and check what happens.

          jsulmJ 1 Reply Last reply
          0
          • S Stuhalsky Alex

            Hi @jsulm. Yes, i tried.

            In the first case i created file for writing manually and made sure it can be opened. The files were indeed created, but 0 bytes were written. I checked QMediaRecorder state. It have not been changed at all. Corresponding singnal was not emitting. Actual location was invalid and output location was empty string.

            In the second case i tried simply to set output location in QMediaRecorder instance, but file was not created at all. Actual location was invalid, but output location contained correct QUrl path to local file.

            I may miss something, because i tried many solutions during last couple of days. I can reimplement any solution that is supposed to work and check what happens.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Stuhalsky-Alex Can you play the stream in your Qt app?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            S 1 Reply Last reply
            0
            • B Bonnie

              What platform?
              AFAIK Qt doesn't support rtsp urls on Windows.
              I don't think it is possible to create a QCamera connected to some live stream url.
              But QMediaRecorder accepts all QMediaObject classes, not only QCamera, so it may be possible to record if Qt can play the url.

              S Offline
              S Offline
              Stuhalsky Alex
              wrote on last edited by
              #6

              Hi @Bonnie

              • "What platform?"
                Kubuntu 20.04.
                Forgot to mention it in the topic. I will add it there too.

              • "I don't think it is possible to create a QCamera connected to some live stream url."
                Ok. Minus one option.

              • "But QMediaRecorder accepts all QMediaObject classes, not only QCamera, so it may be possible to record if Qt can play the url."
                Well. I will try again. May be i missed some minor mistake that breaks everything.

              1 Reply Last reply
              0
              • jsulmJ jsulm

                @Stuhalsky-Alex Can you play the stream in your Qt app?

                S Offline
                S Offline
                Stuhalsky Alex
                wrote on last edited by
                #7

                @jsulm

                • "Can you play the stream in your Qt app?"
                  Yes, i can. Simply passing rtsp url as media for QMediaPlayer and setting video output into QVideoWidget.
                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  AlexRNL
                  wrote on last edited by
                  #8

                  @Stuhalsky-Alex

                  Hello, I've stumbled upon your topic after running into the same issue. I'd like to dispaly and record a stream from a camera on the network. But, while I can display effortlessly the stream with a MediaPlayer widget, QMediaRecorder does not appear to support the recording of the stream from QMediaPlayer even though it implements QMediaContent.

                  Did you ever find a way to make it work? Or have you used a workaround?

                  Thanks,
                  Alex.

                  S 1 Reply Last reply
                  0
                  • A AlexRNL

                    @Stuhalsky-Alex

                    Hello, I've stumbled upon your topic after running into the same issue. I'd like to dispaly and record a stream from a camera on the network. But, while I can display effortlessly the stream with a MediaPlayer widget, QMediaRecorder does not appear to support the recording of the stream from QMediaPlayer even though it implements QMediaContent.

                    Did you ever find a way to make it work? Or have you used a workaround?

                    Thanks,
                    Alex.

                    S Offline
                    S Offline
                    Stuhalsky Alex
                    wrote on last edited by
                    #9

                    @AlexRNL Hi.
                    I haven't found a solution and skipped this task. I will turn back to it later, but not soon i guess :)

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Hi,

                      Did you check with Qt 6.2 ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      S 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Hi,

                        Did you check with Qt 6.2 ?

                        S Offline
                        S Offline
                        Stuhalsky Alex
                        wrote on last edited by
                        #11

                        @SGaist Hi.
                        No i haven't. I can't switch to Qt6 for now so i didn't try that option.

                        A 1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          You can try to cheat by using a custom GStreamer pipeline that does both.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • S Stuhalsky Alex

                            @SGaist Hi.
                            No i haven't. I can't switch to Qt6 for now so i didn't try that option.

                            A Offline
                            A Offline
                            AlexRNL
                            wrote on last edited by
                            #13

                            @Stuhalsky-Alex I can't switch to Qt 6 yet, I'm stuck with 5.12

                            I have alternatives ways to record the stream, but using a QMediaRecorder seemed easy enough to set-up and as it is well-integrated into Qt it made everything easier.

                            I'll try to have a look at GStreamer to see if it can workaround this issue.

                            Thanks for your answer anyway :)

                            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