I've built a python project that open cameras using RTSP protocol using OpenCV and format each frame to .jpg and to base64 string and finally publish it to Redis Q.
There I have a NodeJS application that subscribes to each Q and sends it to the client using socket.io.
here is my python code:
while(video_capture.isOpened()):
ret, frame = video_capture.read()
retval, buffer_img1 = cv2.imencode('.jpg', frame)
jpg_as_text = base64.b64encode(buffer_img1)
print('len1', len(buffer_img1))
queue.publish('Camera_1Q', jpg_as_text)
but... it's very slow!
in the client (ReactJs) it seems like 2 frames in a second. and I think it because of the long string that going through the Redis.
3 questions:
1. is .jpg the best format for that?
2. how can I compress each frame in order to help the Redis to be faster?
3. how can I send only the pixels that changed (frame1 - frame2).
If I have a problem with the architecture let me know. If I've got to false conclusion let me know.
thanks.