Remote streaming live video with Flask
Description
This an implementation on how to get a remote streaming live video connection between 2 different processes using websockets. The video image is captured through OpenCV on one machine and video is served in another machine. This approach serves best the scenario where the Webserver is located in a different network than the machine that is producing the video streaming.
The streaming process can be summed into the following steps:
- Capturing video image
- For each frame, serialize the image
- Flush the data to the Webserver listening socket
- Deserialize the data into a jpeg image
- Serve the result in the web page
The web framework used for the webserver is Flask. For example purposes, we will be using laptop's webcam image straight away.
Install
This project runs with Python. Also install the following Python dependencies (pip makes it dead simple):
- opencv-python
- flask
Usage
- Start the server.py and go to "http://<address>:<port>/video_feed"
- Start the client.py
- See the result in the browser
Credits
The approach on how to serve the video on a webpage is taken from this blog.
License
Code and documentation released under the MIT License