[FFmpeg-devel] fix:?==?utf-8?q? rtsp/transport parser should accept comma for parameters

abalam abalam at aewd.net
Fri May 1 21:52:55 EEST 2020


I needed this fix to make [Shinobi](https://github.com/ShinobiCCTV/Shinobi) works with recent chinese cameras.

We can read that FFmpeg is perfectly following the [RTSP specs](https://tools.ietf.org/html/rfc2326#page-58) : 
`Transports are comma separated, listed in order of preference. Parameters may be added to each transport, separated by a semicolon.`
But considering:
- VLC is working smart with not perfect cameras ;
- RTSP module in FFmpeg is not programmed to handle more than one transport ; 
=> this fix could be useful to anyone

I also think this fix might be improved by a better scan of parameters if ffmpeg wants to handle more than one transport.

Details: 
I'm using [Shinobi](https://github.com/ShinobiCCTV/Shinobi) to record cameras rtsp streams
For several cameras, cheap chinese ones, VLC is working to get stream but FFmpeg always crashes after it receives the RTSP transports parameters available.

`Transport: RTP/AVP;unicast;mode=PLAY;source=192.168.66.164;client_port=11658-11659;server_port=40000-40001,ssrc=FFFFCCCC`

After debugging the source code, it appears that FFmpeg is not considering that a comma `,` before `ssrc` is a correct separator and think it's a second transport.
Then it crashes because RTSP don't want to accept more than one transport.

( This was closed PR https://github.com/FFmpeg/FFmpeg/pull/336 )

Thank you for having read,
Keep good work and have a nice day!

---
 libavformat/rtsp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index b2b3f32011..f77de10119 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1001,11 +1001,9 @@ static void rtsp_parse_transport(AVFormatContext *s,

             while (*p != ';' && *p != '\0' && *p != ',')
                 p++;
-            if (*p == ';')
+            if (*p == ';' || *p == ',')
                 p++;
         }
-        if (*p == ',')
-            p++;

         reply->nb_transports++;
         if (reply->nb_transports >= RTSP_MAX_TRANSPORTS)
--
2.21.1 (Apple Git-122.3)


More information about the ffmpeg-devel mailing list