JacobP36
Posts: 4
Joined: Sat Jan 25, 2020 2:31 pm

RTSP stream cutting out

Sun May 16, 2021 12:58 pm

Hi,

I'm trying to run an RTSP stream from the camera module v2 and a RPi Zero W.

I run it using this command, to rtsp://ip:8080/stream

Code: Select all

raspivid -o - -t 0 -n -w 1280 -h 720 -fps 24 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8080/stream}' :demux=h264 --h264-fps=24
This broadcasts over my local network, but it seems to cut out every (exactly) 1 minute.
Whichever player I use (VLC, OBS, ffmpeg), it kicks me from the stream exactly a minute after I started viewing. cvlc outputs nothing unusual, and I can re-join the stream straight away, but it won't let me view for any longer than 1 minute in a session.

Listening through ffmpeg ends after 1 minute and outputs that 'No more output streams to write to, finishing.'.

RanGrey
Posts: 5
Joined: Thu May 20, 2021 10:00 pm

Re: RTSP stream cutting out

Thu May 20, 2021 10:07 pm

I'm having the same issue here. We may have even followed the same tutorial.
Does your stream also have a hefty (3-4 seconds) lag?

JacobP36
Posts: 4
Joined: Sat Jan 25, 2020 2:31 pm

Re: RTSP stream cutting out

Fri May 21, 2021 3:38 pm

It does, yes.

RanGrey
Posts: 5
Joined: Thu May 20, 2021 10:00 pm

Re: RTSP stream cutting out

Fri May 21, 2021 5:22 pm

I haven't been able to get an answer about this issue anywhere. I'm starting to think it might be something really basic and few have time for absolute beginners.

I came across a suggested fix for Pi Zeros locking up entirely after 30 minutes of camera use, involving updating the config.txt file, but I don't think that's related to our issue, sadly.

Sorry I can't help, I need help myself.

Ind3x
Posts: 1
Joined: Sat May 22, 2021 8:48 am

Re: RTSP stream cutting out

Sat May 22, 2021 8:57 am

I'm having the exact same issue. I tried dozens combinations of v4l2, vlc settings etc. It's driving me crazy.

According to some other, cutting out after around 1 minute may have something to do with the RTCP Sender Reports. I used Wireshark and found that the last packet before the connections drops gets marked as "Malformed Packet". Maybe it has something to do with that. But I'm not sure what to make out of that.

The VLC player reports:

Code: Select all

live555 error: keep-alive failed: recvfrom() error: An existing connection was forcibly closed by the remote host
main debug: EOF reached
Here is that packet copied from Wireshark:

Code: Select all

RTCP Sender Report Source description [Malformed Packet]

Code: Select all

0000   60 45 cb 9c 41 d7 b8 27 eb 04 3c 74 08 00 45 00   `E..A..'..<t..E.
0010   00 64 2b 98 40 00 40 11 29 68 c0 a8 b2 22 c0 a8   .d+.@.@.)h..."..
0020   b2 15 be 3a d1 a5 00 50 9a 6a 80 c8 00 06 16 18   ...:...P.j......
0030   8a bb e4 53 40 bd 56 db 71 8d 2f 5b 75 1c 00 00   ...S@.V.q./[u...
0040   2e a6 00 e6 e8 7a 81 ca 00 08 16 18 8a bb 01 0e   .....z..........
0050   31 39 32 2e 31 36 38 2e 31 37 38 2e 33 34 06 0a   192.168.178.34..
0060   76 6c 63 20 33 2e 30 2e 31 32 81 cb 00 01 16 18   vlc 3.0.12......
0070   8a bb                                             ..
rtcp-dump.jpg
rtcp-dump.jpg (221.95 KiB) Viewed 337 times
Last edited by Ind3x on Sat May 22, 2021 9:15 am, edited 6 times in total.

RanGrey
Posts: 5
Joined: Thu May 20, 2021 10:00 pm

Re: RTSP stream cutting out

Sat May 22, 2021 10:54 pm

Yes, I had a few people suggest that it was a failing keepalive and a few workarounds to try (essentially setting vlc to RTP over RTSP on both pi and viewer pc) but they didn't work.
The general consensus seems to be that it's a bug in VLC, but you mentioned that you have the same issue with other players, so perhaps that's not the case.

Edit: I've checked OBS and the same thing happens, so I don't think it's a VLC bug.

BeauSlim
Posts: 127
Joined: Mon Jul 31, 2017 10:02 am

Re: RTSP stream cutting out

Sun May 23, 2021 7:56 pm

I use motioneyeOS on a pi zero w to send video from a v2 camera via the RTSP streaming feature. I view with vlc on both mac and linux. The only timeout issues I experience seem to be related to wifi dropping. A stream can go for hours.
I do recall upping the buffer size in VLC.
Beyond that, maybe look at what motioneyeOS is doing differently that you are. You might have to dig a bit in forums. It isn't well documented.

RanGrey
Posts: 5
Joined: Thu May 20, 2021 10:00 pm

Re: RTSP stream cutting out

Sun May 23, 2021 10:23 pm

BeauSlim makes an excellent point! I've used MotionEyeOS as well and, while the quality of the stream is generally much worse than the rtsp stream, the webviewer does not drop the stream after 60 seconds.

This makes me think that the issue lies with VLC on the pi.

Could someone please show me how to set "RTP over RTSP" on VLC on the pi via command line?

RanGrey
Posts: 5
Joined: Thu May 20, 2021 10:00 pm

Re: RTSP stream cutting out

Tue May 25, 2021 3:07 am

There was an update for VLC this evening and while it hasn't fixed the stream dropping issue, I am getting an error which wasn't being thrown before after about 30 seconds:

ES_OUT_SET_(GROUP)PCR is called too late (pts_delay increased to 1001ms)

then the buffering begins again and the stream continues uninterrupted.
Then, after about 55 seconds, the error is thrown again and this time the stream gets dropped.
If I leave the Pi streaming, it will continue to throw the error and increase the pts delay every time.

Return to “Camera board”