'OBS live to TCP python server

I had an issue when I tried to live stream from OBS studio to a python socket TCP server.

My OBS settings:

  1. Server: "tcp://x.x.x.x:1234"
  2. Stream key: ""

My Python script:

import socket, cv2, numpy

host = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host.bind(("x.x.x.x", 1234))
host.listen(1)

while True:
    client, address = host.accept()

    try:
        cv2.imshow("Window", cv2.imdecode(numpy.frombuffer(client.recv(3500)), cv2.IMREAD_COLOR))
        cv2.waitKey(1)
    except:
        pass

Please help me to finish that and share all your scripts. Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source