All Projects → ArtyomKozyrev8 → stream_video_server

ArtyomKozyrev8 / stream_video_server

Licence: GPL-3.0 license
demonstrates how to create video streaming server with the help of aiohttp and opencv

Programming Languages

python
139335 projects - #7 most used programming language
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to stream video server

Bolt Python
A framework to build Slack apps using Python
Stars: ✭ 190 (+1166.67%)
Mutual labels:  websockets, aiohttp, asyncio
Sockjs
SockJS Server
Stars: ✭ 105 (+600%)
Mutual labels:  websockets, aiohttp, asyncio
Aiohttp
Asynchronous HTTP client/server framework for asyncio and Python
Stars: ✭ 11,972 (+79713.33%)
Mutual labels:  aiohttp, http-server, asyncio
Python Slack Sdk
Slack Developer Kit for Python
Stars: ✭ 3,307 (+21946.67%)
Mutual labels:  websockets, aiohttp, asyncio
aioScrapy
基于asyncio与aiohttp的异步协程爬虫框架 欢迎Star
Stars: ✭ 34 (+126.67%)
Mutual labels:  aiohttp, asyncio
Ixwebsocket
websocket and http client and server library, coming with ws, a command line swiss army knife utility
Stars: ✭ 204 (+1260%)
Mutual labels:  websockets, http-server
aiohttp-json-rpc
Implements JSON-RPC 2.0 using aiohttp
Stars: ✭ 54 (+260%)
Mutual labels:  aiohttp, http-server
Pyro-FileStreamBot
Stream Telegram files to web
Stars: ✭ 38 (+153.33%)
Mutual labels:  aiohttp, http-server
trellio
Python3 asyncio based microframework for microservice architecture
Stars: ✭ 19 (+26.67%)
Mutual labels:  aiohttp, asyncio
pytest-aiohttp
pytest plugin for aiohttp support
Stars: ✭ 110 (+633.33%)
Mutual labels:  aiohttp, asyncio
tomodachi
💻 Microservice library / framework using Python's asyncio event loop with full support for HTTP + WebSockets, AWS SNS+SQS, RabbitMQ / AMQP, middleware, etc. Extendable for GraphQL, protobuf, gRPC, among other technologies.
Stars: ✭ 170 (+1033.33%)
Mutual labels:  aiohttp, asyncio
python3-concurrency
Python3爬虫系列的理论验证,首先研究I/O模型,分别用Python实现了blocking I/O、nonblocking I/O、I/O multiplexing各模型下的TCP服务端和客户端。然后,研究同步I/O操作(依序下载、多进程并发、多线程并发)和异步I/O(asyncio)之间的效率差别
Stars: ✭ 49 (+226.67%)
Mutual labels:  aiohttp, asyncio
waspy
WASP framework for Python
Stars: ✭ 43 (+186.67%)
Mutual labels:  http-server, asyncio
Http Kit
http-kit is a minimalist, event-driven, high-performance Clojure HTTP server/client library with WebSocket and asynchronous support
Stars: ✭ 2,234 (+14793.33%)
Mutual labels:  websockets, http-server
aioneo4j
asyncio client for neo4j
Stars: ✭ 29 (+93.33%)
Mutual labels:  aiohttp, asyncio
Fs2 Http
Http Server and client using fs2
Stars: ✭ 132 (+780%)
Mutual labels:  websockets, http-server
yutto
🧊 一个可爱且任性的 B 站视频下载器(bilili V2)
Stars: ✭ 383 (+2453.33%)
Mutual labels:  aiohttp, asyncio
netunnel
A tool to create network tunnels over HTTP/S written in Python 3
Stars: ✭ 19 (+26.67%)
Mutual labels:  aiohttp, asyncio
Socketshark
A WebSocket message router based on Python/Redis/asyncio
Stars: ✭ 51 (+240%)
Mutual labels:  websockets, asyncio
Postgresql2websocket
Send PostgreSQL notifications over websockets
Stars: ✭ 58 (+286.67%)
Mutual labels:  websockets, aiohttp

stream_video_server

The project demonstrates some ways how to create video streaming servers with the help of Aiohttp and OpenCV.

Ways are listed from the simplest implementations to more robust solutions.

If you would like to have more production ready solution with appropriate error handling, docker containers, docker-compose etc - take a look at the third implementation and skip the first two. If you would like to start from more tutorial-like code, start from the 1st and the 2nd implementations.

The idea of Application (The 3rd implementation):

The Aim: to create http server which can stream video to web browser data from several remote cameras

The application is composed of two services: 1. http server 2. video processing process 3. Optionally Nginx

Demo

First One: The Easiest Video Server Implementation:

How to run The Easiest Video Server Implementation:

  1. create venv

  2. install all requirement from requirement.txt

  3. python -m aiohttp.web -H 0.0.0.0 -P 7272 solution_one:create_app // python3 in Linux

PROs:

  1. Easy to implement
  2. All in one Process

CONs:

  1. The more users watch video, the more static video looks like. Note that video is a sequence of images, and in this implementation images are yielded from generator function, so part of images goes to one user, part of images goes to another user.

Second One: Easy Websocket Video Server Implementation:

How to run Easy Websocket Video Server Implementation:

  1. create venv

  2. install all requirement from requirement.txt

  3. python -m aiohttp.web -H 0.0.0.0 -P 7373 solution_two:create_app // python3 in Linux

PROs:

  1. easy to implement
  2. Use websockets which are modern solution for bidirectional communications with browser

CONs:

  1. Though websockets are faster, still the more users watch video, the more static video looks like. Note that video is a sequence of images, and in this implementation images are yielded from generator function, so part of images goes to one user, part of images goes to another user.

Third One: Websocket Video Server Implementation:

1. How to run Websocket Video Server Implementation:

  1. create venv

  2. install all requirement from requirement.txt

  3. cd solution_three

  4. python -m aiohttp.web -H 0.0.0.0 -P 7474 ws_http_server:create_app // python3 in Linux

2. How to run Video Processing Process

  1. create venv

  2. install all requirement from requirement.txt

  3. python solution_three/video_source_process/vid_s_pr.py // python3 in Linux

PROs:

  1. Can handle multiple clients (browsers) and provide all frames to all clients with small delay
  2. Can handle slow clients with nearly no negative effect on other clients
  3. Use websockets which are modern solution for bidirectional communications with browser
  4. Video Processing is done in another process = less CPU bound ops in http server, can be distributed between several nodes

Cons:

  1. Do not scale well, only one http process can work simultaneously.
How to deploy application (3rd solution) with Docker or/and Docker-Compose:

Note: you still have to run python video_source_process/vid_s_pr.py (Video Processing App) without Docker, though it is possible to run OpenCV app in docker, you need to to use --device= docker flag to use default camera by index.

  1. Create Images and run with the help of Docker-Compose:

1.1 docker build -t video_ng . // run command in solution_three/nginx folder

1.2 docker build -t video_server . // run command in solution_three/ws_http_server folder

1.3 docker-compose up -d // run command in solution_three folder

  1. Create Images and run with the help of Docker only:

2.1 docker build -t video_ng . // run command in nginx folder

2.2 docker build -t video_server . // run command in ws_http_server folder

2.3 docker network create video_server_net

2.4 docker run --name video_server --network aio_net -d video_server

2.5 docker run --name video_ng --network aio_net -p 7474:7474 -d video_ng

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].