Zephyr is a simple RTSP library to stream and receive video over RTSP.
The easiest way to install Zephyr is using pip:
$ pip install zephyr-rtsp
But you can also install Zephyr from source:
$ git clone https://github.com/bpradana/zephyr.git
$ cd zephyr
$ python setup.py install
Zephyr has 2 main classes, Stream
and Client
. Stream
is used to stream video over RTSP, while Client
is used to receive video from RTSP stream.
To stream video, you need to create a Stream
object and call send
with a frame. You can also call end
to stop the stream.
import cv2
from zephyr import Stream
if __name__ == "__main__":
stream = Stream(
url="rtsp://localhost:8554/test",
resolution=(1280, 720),
fps=30,
bitrate="2M"
)
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
stream.send(frame)
To receive video, you need to create a Client
object and call read
to get the frame. You can also call release
to stop receiving video.
import cv2
from zephyr import Client
if __name__ == "__main__":
client = Client(url="rtsp://localhost:8554/test")
while True:
ret, frame = client.read()
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord("q"):
client.release()
break
Zephyr is licensed under the MIT License.