RTSP Video Writer

class RtspVideoWriter(port=5000, num_streams=1, image_width=640, image_height=480, fps=30, **kwargs)

Host an RTSP video streaming server on the device.

The RTSP video stream is H264 encoded and can be consumed by third-party apps such as VLC.

RtspVideoWriter can be instantiated as a context manager:

with edgeiq.RtspVideoWriter() as video_writer:
    ...
    video_writer.write_frame(frame)
    ...

To use RtspVideoWriter directly, use the start() and close() functions:

video_writer = edgeiq.RtspVideoWriter().start()
...
video_writer.write_frame(frame)
...
video_writer.close()

To capture the stream with VLC:

vlc -v rtsp://<device IP address>:<port>/video<stream idx>
Parameters:
  • port (integer) – The port to use for the RTSP server.

  • num_streams (integer) – The number of RTSP streams.

  • image_width (integer) – The width of the images provided.

  • image_height (integer) – The height of the images provided.

  • fps (integer) – The framerate of the RTSP stream in frames per second.

start()

Start the RtspVideoWriter server.

Returns:

self

write_frame(frame, stream_idx=0)

Send frame to the RTSP server.

Parameters:
  • frame (numpy array) – The frame to be written to the video stream.

  • stream_idx (integer) – The stream index to write the frame to.

Raises:

Any exception that occurs in RtspVideoWriter process

close()

Stop the RtspVideoWriter server.

Raises:

Any exception that occurs in RtspVideoWriter process