From 1d10d9fa3abcbe76722b471650d46315fdfdc00b Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Wed, 24 Feb 2021 15:27:57 -0800 Subject: [PATCH] Update RTSP server and examples to work with FFPLAY --- .../examples/OpenMV/36-Web-Servers/rtsp_video_server.py | 2 ++ scripts/libraries/rtsp.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/scripts/examples/OpenMV/36-Web-Servers/rtsp_video_server.py b/scripts/examples/OpenMV/36-Web-Servers/rtsp_video_server.py index 8de8d8165..c91b60145 100644 --- a/scripts/examples/OpenMV/36-Web-Servers/rtsp_video_server.py +++ b/scripts/examples/OpenMV/36-Web-Servers/rtsp_video_server.py @@ -11,6 +11,8 @@ import network, omv, rtsp, sensor, time # Not all programs (e.g. VLC) implement the full JPEG standard for decoding any JPEG image # in RTP packets. Images JPEG compressed by the OpenMV Cam internally may not display. +# FFPLAY will correctly handle JPEGs produced by OpenMV software. + sensor.reset() sensor.set_pixformat(sensor.JPEG) # Only supported by the OV2640/OV5640. diff --git a/scripts/libraries/rtsp.py b/scripts/libraries/rtsp.py index 346dc5343..70a1698f1 100644 --- a/scripts/libraries/rtsp.py +++ b/scripts/libraries/rtsp.py @@ -94,6 +94,13 @@ class rtsp_server: if self.__pathname != '/' and self.__pathname.endswith('/'): self.__pathname = self.__pathname[:-1] if line0[2] == "RTSP/1.0": + if len(s) >= 3 and s[1].split(' ')[0] != "CSeq:": + for i in range(2, len(s)): + if s[i].split(' ')[0] == "CSeq:": + temp = s[i] + s[i] = s[1] + s[1] = temp + break line1 = s[1].split(' ') if line1[0] == "CSeq:": seq = int(line1[1]) @@ -134,6 +141,7 @@ class rtsp_server: if self.__setup_cb: self.__setup_cb(self.__pathname, self.__session) return elif request == "PLAY": + s = list(filter(lambda x: x and not x.startswith("Range"), s)) if len(s) >= 3: m = re.match("Session: (\d+)", s[2]) if m: