PR #22496 opened by davidebeatrici URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22496 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22496.patch
While recording from a remote camera running Thingino, I encountered a big issue. With an average of 2 or 3 times per day the video stream would just stop with FFmpeg seemingly still going. In fact, the file's reported duration kept increasing but seeking to that point would result in a stuck player. Turns out every time that happens the remote RTSP server suddenly resets CSeq to zero, possibly due to a spurious crash/restart: ``` [rtsp @ 0x55d4980b39c0] CSeq reset to 0 from 1418. [rtsp @ 0x55b21e96d9c0] CSeq reset to 0 from 9. [rtsp @ 0x557d59baa9c0] CSeq reset to 0 from 9. ``` I'm not sure whether the behavior is caused by a buggy streamer (prudynt) or occasional network instability. However, I ensured that with this change FFmpeg exits with code 0, allowing my script to start a new recording. >From 6e608c8c56237818b9d4216bf34e57a7a5807be6 Mon Sep 17 00:00:00 2001 From: Davide Beatrici <[email protected]> Date: Fri, 13 Mar 2026 22:54:48 +0100 Subject: [PATCH] avformat/rtsp: Handle CSeq reset to 0 While recording from a remote camera running Thingino, I encountered a big issue. With an average of 2 or 3 times per day the video stream would just stop with FFmpeg seemingly still going. In fact, the file's reported duration kept increasing but seeking to that point would result in a stuck player. Turns out every time that happens the remote RTSP server suddenly resets CSeq to zero, possibly due to a spurious crash/restart: [rtsp @ 0x55d4980b39c0] CSeq reset to 0 from 1418. [rtsp @ 0x55b21e96d9c0] CSeq reset to 0 from 9. [rtsp @ 0x557d59baa9c0] CSeq reset to 0 from 9. I'm not sure whether the behavior is caused by a buggy streamer (prudynt) or occasional network instability. However, I ensured that with this change FFmpeg exits with code 0, allowing my script to start a new recording. --- libavformat/rtsp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 6da03d26fe..4c13cce412 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1359,8 +1359,12 @@ start: } if (rt->seq != reply->seq) { - av_log(s, AV_LOG_WARNING, "CSeq %d expected, %d received.\n", - rt->seq, reply->seq); + if (reply->seq != 0) + av_log(s, AV_LOG_WARNING, "CSeq %d expected, %d received.\n", rt->seq, reply->seq); + else { + av_log(s, AV_LOG_WARNING, "CSeq reset to 0 from %d.\n", rt->seq); + rt->state = RTSP_STATE_IDLE; + } } /* EOS */ -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
