rtsp — rtsp library
The rtsp module on the OpenMV Cam allows you to stream video from your OpenMV Cam to any
compatible RTSP client (like VLC).
Example usage:
server = rtsp.rtsp_server(network_if)
server.stream(lambda pathname, session: sensor.snapshot())
See the example scripts in OpenMV IDE under Web Servers.
class rtsp_server – rtsp_server class
The rtsp_server class creates a single connection RTSP web server on your OpenMV Cam.
- class rtsp.rtsp_server(network_if: Any, port: int = 554)
Creates an RTSP server bound to
network_if.network_ifis the network module interface created fromnetwork.LAN(),network.WLAN(), or similar.portis the TCP port to listen on. The default RTSP port is 554.- register_setup_cb(cb: Callable[[str, int], None]) None
Bind a callback
cbto be invoked when a client sets up an RTSP connection.The callback receives
pathname(the requested stream resource path, defaults to"/") andsession(a random session id).
- register_play_cb(cb: Callable[[str, int], None]) None
Bind a callback
cbto be invoked when a client starts streaming.The callback receives
pathnameandsessionas described inregister_setup_cb().
- register_pause_cb(cb: Callable[[str, int], None]) None
Bind a callback
cbto be invoked when a client pauses streaming.Note: VLC’s pause button does not actually notify the server.
The callback receives
pathnameandsessionas described inregister_setup_cb().
- register_teardown_cb(cb: Callable[[str, int], None]) None
Bind a callback
cbto be invoked when a client tears down the RTSP connection.The callback receives
pathnameandsessionas described inregister_setup_cb().
- stream(image_callback: Callable[[str, int], image.Image], quality: int = 90) None
Starts running the
rtsp_serverlogic and does not return.image_callbackis invoked to produce each frame and must return animage.Imageobject. It receivespathnameandsessionas described inrtsp_server.register_setup_cb().qualityis the JPEG compression quality used while streaming.