RTSP-Server crashing with IndexError when accessing with mplayer

I tried to run the RTSP Video Server from examples,
I am using the OV5640 and modified the sensor settings to::
sensor.set_quality(80 )
The decie is set to work in AP mode
When accessing with VLC it works fine (with a high delay). But when accessing the stream with mplayer on a raspberry I get an IndexError…
Error on serial terminal:
Traceback (most recent call last):
File “”, line 121, in
File “rtsp.py”, line 360, in stream
File “rtsp.py”, line 136, in __parse_rtsp_request
IndexError: list index out of range
OpenMV 66d4e6b; MicroPython fff2e1f; OpenMV IMXRT1060-MIMXRT1062DVJ6A

mplayer command: mplayer rtsp://
It seems the player opens: tcp://

If I understood it correctly modifications, on rtsp.py are not straight forward. Or am I wrong?

Thanks for any hint.

Hi, uh, it’s actually easy to modify the script on your own.

Grab the library from here and copy it to your OpenMV Cam disk:

openmv/scripts/libraries/rtsp.py at master · openmv/openmv (github.com)

You can then edit it and it will replace the internal script. You can put a print statement in the code for example to see what is actually happening. Once you have a fix it would be appreciated if you send a PR with that fix to our repo so everyone can benefit.

You are definitely running into an issue where I’m not handling something mplayer is sending. Typically, if you use wireshark to look at the traffic for setting up the RSTP stream it’s pretty easy to see what’s going wrong and fix it.

You have to lower the buffering time in VLC if you want the delay to be lower. That’s not from the camera.

The error you are getting implies mplayer didn’t follow the RSTP spec: openmv/scripts/libraries/rtsp.py at master · openmv/openmv (github.com)

The first line of text we expect to see should be “command path RTSP/1.0”

Is mplayer sending “command path”?

See RFC 2326: Real Time Streaming Protocol (RTSP) (rfc-editor.org)

10.4 SETUP

The SETUP request for a URI specifies the transport mechanism to be
used for the streamed media. A client can issue a SETUP request for a
stream that is already playing to change transport parameters, which
a server MAY allow. If it does not allow this, it MUST respond with
error “455 Method Not Valid In This State”. For the benefit of any
intervening firewalls, a client must indicate the transport
parameters even if it has no influence over these parameters, for
example, where the server advertises a fixed multicast address.

Since SETUP includes all transport initialization information,
firewalls and other intermediate network devices (which need this
information) are spared the more arduous task of parsing the
DESCRIBE response, which has been reserved for media

The Transport header specifies the transport parameters acceptable to
the client for data transmission; the response will contain the
transport parameters selected by the server.

C->S: SETUP rtsp://example.com/foo/bar/baz.rm RTSP/1.0
CSeq: 302
Transport: RTP/AVP;unicast;client_port=4588-4589

S->C: RTSP/1.0 200 OK
CSeq: 302
Date: 23 Jan 1997 15:35:06 GMT
Session: 47112344
Transport: RTP/AVP;unicast;

The server generates session identifiers in response to SETUP
requests. If a SETUP request to a server includes a session
identifier, the server MUST bundle this setup request into the

You are getting an error on it parsing that line of code in bold. mplayer may not be opening the stream in rtsp mode.