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?

  • It is not clear that you use the phrase "decentralized network." they wanted to say — you have one source (server), everything is centralized (for comparison, bittorrent or skype is less centralized in the past) ¶ Count how many bytes one frame in png format requires. How many frames per second you want, how many bytes per second. This should suggest that either the video is not needed or the stream should be compressed. To get comfortable and understand what functionality is desirable in your case, try ffmpeg + ffserver (compare with a simple example from Google ) - jfs

0