SINETStream Github websit: https://github.com/nii-gakunin-cloud/sinetstream.
Testing tutorial: video streaming from Raspberry Pi to edge & cloud server with SINETStream combined with EdgeVPN.
Writer: Jeston TX2, Raspberry Pi.Reader: MacOS.Broker: docker container on MacOS or other device.
Camera on Jeston TX2 can capture video stream, and publish each frame with SINETStream through broker to MacOS (of course, other device is OK) as Reader.
video_producer.py as Writer on Jeston TX2.
producer class:
def producer(service, video, preview=False):
with MessageWriter(service, value_type='image') as writer:
image = next_frame(video)
print(image.shape)
while image is not None:
writer.publish(image)
if preview and show_preview(image):
break
image = next_frame(video)In the mode of video stream from camera, Jeston TX2 can use gstreamer to open its onboard or USB camera, and use cv2 library to capture the video stream.
# open its onboard or USB camera with parameters
pipeline = gstreamer_pipeline(capture_width=args.width, capture_height=args.height, framerate=args.fps, flip_method=0,
display_width=args.width, display_height=args.height)
# capture the video stream from camera, and finally input to producer class
cap = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)video_consumer.py as Reader on MacOS (or other devices).
consumer class:
def consumer(service):
with MessageReader(service, value_type='image') as reader:
for message in reader:
if show_image(message):
sys.exit()As the reader side, user only needs to define service name same as the Writer. MessageReader can subscribe each frame as message, and show each frame of video with function show_image(message).
Here for details of input parameters.
Details for input parameters
In the terminal for Reader:
python3 video_consumer.py -s video-kafka-sservice name
For Jestson TX2, you can run video_producer.py.
In the terminal for Writer:
python3 video_producer.py -s video-kafka -c 0 -p-sservice name (same asReaderprogram)-cwebcam source id (usually 0)-pshow preview locally (optional)--widthresize video width (default value: 320)--heightresize video height (default value: 240)--fpsset video frame rate (default value: 30)
For Raspberry Pi, you can run rasp_video_producer.py.
In the terminal for Writer:
python3 rasp_video_producer.py -s video-kafka-sservice name (same asReaderprogram)-pshow preview locally (optional)--widthresize video width (default value: 320)--heightresize video height (default value: 240)--fpsset video frame rate (default value: 30)