[FFmpeg-devel] sending RTSP keep alive even when paused

Tmc Tmc tmcjj2001 at gmail.com
Sun Aug 27 17:43:13 EEST 2023


Hi All,
I found a bug in ffmpeg's RTSP implementation.

The workflow is as follows:

1. Have a RTSP server that supports Pause.
2. Have ffmpeg play a video from that server (rtsp://<ipaddr>:...).
3. Pause the video in ffmpeg.
4. ffmpeg does NOT properly send the keep alive when Paused
(either "GET_PARAMETER" or "OPTIONS"). This is the bug.
5. Since the RTSP server expects the keep alive, after the specified
timeout (usually 60s) it closes the connection.

The bug is in libavformat/rtspdec.c, rtsp_read_packet method.

This method first does ff_rtsp_fetch_packet, which fails when the server is
Paused, causing it to never send the "GET_PARAMETER" or "OPTIONS" which is
placed after this call.

The fix is to simply move that block of code before ff_rtsp_fetch_packet.
That is, move the entire if block:
if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN)) { ... }
just before the call to:
ret = ff_rtsp_fetch_packet(s, pkt);

I have tested this and it seems to work well for our cases.

Your thoughts and comments on this are welcome.

Thanks.


More information about the ffmpeg-devel mailing list