dimanche 14 juillet 2019

How can I access a tcp server from a website?

I stream a live video feed from my raspberry pi on a socket server which was created with python. How can I access from my website the tcp scoket server? Or is there any way to stream directly​ to the webpage with python. (I use the module picamera to connect to the camera and stream)

import socket
import time
import picamera

with picamera.PiCamera() as camera:
    camera.resolution = (640, 480)
    camera.framerate = 60
    camera.rotation = 180

    server_socket = socket.socket()
    server_socket.bind(("192.168.178.39", 8081))
    server_socket.listen(0)

    connection = server_socket.accept()[0].makefile('wb')
    try:
        camera.start_recording(connection, format = 'h264')
        camera.wait_recording(60)
        camera.stop_recording()
    finally:
        connection.close()
        server_socket.close()

`

So is there any way I can show the stream through this or stream directly to the webpage?




Aucun commentaire:

Enregistrer un commentaire