1

I trying to use a example of the Picamera2 the capture_stream_udp.py to create a client, but a dont know how to create a server script to capture a udp stream via socket.

Can you guys help?

#!/usr/bin/python3

import socket
import time

from picamera2 import Picamera2
from picamera2.encoders import H264Encoder
from picamera2.outputs import FileOutput

picam2 = Picamera2()
video_config = picam2.create_video_configuration({"size": (1280, 720)})
picam2.configure(video_config)
encoder = H264Encoder(1000000)

with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
    sock.connect(("REMOTEIP", 10001))
    stream = sock.makefile("wb")
    picam2.start_recording(encoder, FileOutput(stream))
    time.sleep(20)
    picam2.stop_recording()
stateMachine
  • 5,227
  • 4
  • 13
  • 29
zuzu
  • 11
  • 1
  • 2

0 Answers0