This example illustrates how to read frames from a webcam and send them to a browser.
First install the required packages:
$ pip install aiohttp aiortc opencv-python
When you start the example, it will create an HTTP server which you can connect to from your browser:
$ python webcam.py
You can then browse to the following page with your browser:
Once you click Start the server will send video from its webcam to the browser.
If you want to play a media file instead of using the webcam, run:
$ python server.py --play-from video.mp4
The original idea for the example was from Marios Balamatsias.