Playing RTSP URL with QMediaPlayer
-
wrote on 7 Sept 2023, 23:08 last edited by
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.
-
wrote on 7 Sept 2023, 23:33 last edited by
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.
-
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.
wrote on 9 Sept 2023, 12:17 last edited by gusarg81 9 Sept 2023, 12:19@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/3