Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Playing RTSP URL with QMediaPlayer

Playing RTSP URL with QMediaPlayer

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 2 Posters 1.2k 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.
  • G Offline
    G Offline
    gusarg81
    wrote on 7 Sept 2023, 23:08 last edited by
    #1

    When I try to play RTSP, loading the URL, output shows :

    [rtsp @ 0x55bee46a3940] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size
    Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
    qt.multimedia.ffmpeg.mediadataholder: AVStream duration -9223372036854775808 is invalid. Taking it from the metadata
    qt.multimedia.ffmpeg.mediadataholder: AVStream duration -9223372036854775808 is invalid. Taking it from the metadata
    

    Then of course on play:

    "Invalid parameter"

    Simple example code:

    ...
    self.video_widget = QVideoWidget()
    self.media_player = QMediaPlayer()
    self.media_player.setVideoOutput(self.video_widget)
    self.media_player.setSource(QUrl('rtsp://XXXX:XXXX@181.47.57.235:554/live/ch00_0'))
    self.media_player.play()
    ...
    

    As far as I know, QMediaPlayer is using FFmpeg here (Ubuntu 22.04). If I test with FFmpeg in a terminal, same things happens. But, it does work If I add the option: -rtsp_transport tcp

    Any ideas how to solve this?

    Thanks in advance.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      Lahearle
      wrote on 7 Sept 2023, 23:33 last edited by
      #2

      A live stream has no set duration, you'll have to instead use the web browser and set the qurl in the web browser to the livestream, then make the screen fullsize.

      I think what you are using is the embedded mediaplayer, which plays media files, not livestreams. I doubt it supports livestream format. mediaplayers by themselves also do not connect to the internet. using the internets media player to play a livestream which format is not supported will not work.

      You can either do what I said or you can try and tweak the settings in the module to allow the format of livestreams to be played.

      Livestreams have an indefinite amount of time, that's why it says it has a --9223372036854775808

      However, it may work with some livestreams. Try another one and see if it works and try to tweak that one to match.

      :)

      G 1 Reply Last reply 9 Sept 2023, 12:17
      0
      • L Lahearle
        7 Sept 2023, 23:33

        A live stream has no set duration, you'll have to instead use the web browser and set the qurl in the web browser to the livestream, then make the screen fullsize.

        I think what you are using is the embedded mediaplayer, which plays media files, not livestreams. I doubt it supports livestream format. mediaplayers by themselves also do not connect to the internet. using the internets media player to play a livestream which format is not supported will not work.

        You can either do what I said or you can try and tweak the settings in the module to allow the format of livestreams to be played.

        Livestreams have an indefinite amount of time, that's why it says it has a --9223372036854775808

        However, it may work with some livestreams. Try another one and see if it works and try to tweak that one to match.

        G Offline
        G Offline
        gusarg81
        wrote on 9 Sept 2023, 12:17 last edited by gusarg81 9 Sept 2023, 12:19
        #3

        @Lahearle Hi!

        I did manage to achieve this by using OpenCV, but since I have to do a conversion to embed in Qt, it does takes some CPU.

        By the way, I used to stream webcams (connected to USB) in the past with Qt, by using Phonon in that era (with PyQt5). A webcam also have a indefinite amount of time.

        But the problem here is not that. The problem is that I need to set TCP transport for RTSP (I already exposed that the same happens in FFmpeg if I do no set TCP as transport).

        So, the behavior in Qt or FFmpeg is the same (which the difference that with FFmpeg I can set TCP transport).

        So I think this has nothing to do with "indefinite stream time".

        As a side note, when using FFmpeg command line directly (without setting TCP transport), I got the same output as with Qt... So.

        1 Reply Last reply
        0

        1/3

        7 Sept 2023, 23:08

        • Login

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