I'm trying to implement streaming video from a веб-камеры using a decentralized network.
Figured out how to transfer pictures (webcam pictures) to a TCP server :
client
import cv2, socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('localhost', 3333)) cap = cv2.VideoCapture(0) ret, frame = cap.read() status, data = cv2.imencode('.png', frame) s.send(data) server
import socket, cv2, numpy as np s = socket.socket(socket.AF_INET, socket.SOCK_STREAM); s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 3333)) s.listen(5) while 1: conn, addr = s.accept() f = open('1.png', 'wb') while 1: recv = conn.recv(1024) f.write(recv) if not recv: break f.close() To transfer video, I redid the server to UDP . There was a problem with the transmission of images - error: message too long . I learned that the maximum number of bytes transmitted should not exceed 65535 .
Do you need to transfer data in parts? How to do it? How to actually transfer the video? Is the OpenCV library suitable for this?