PyRTMP: Pure Python RTMP server
After using this package for years in production server. It runs flawlessly without any problem. So I decided to switch the development status from Beta to Production since version 0.2.0. Also, I share my configuration at Deployment section below.
If you have any problems. Feel free to create issue on GitHub.
Install from PyPI:
pip install pyrtmpInstall from source:
pip install pyrtmp@git+https://github.com/Eittipat/pyrtmp.gitLet say we want to create a simple RTMP server that can save all incoming stream to FLV file. We can do it by creating a subclass of Simple RTMP controller and override some methods. Here is the example:
…Next, we can test our server by executing the following command:
ffmpeg -i my_test_file.flv -c:v copy -c:a copy -f flv rtmp://127.0.0.1:1935/test/sampleYour flv file will be saved in the same directory as your python script.
In production environment, You should run multiple instances of RTMP server and use load balancer to distribute incoming
stream.
I recommend to use Nginx as a load balancer and Supervisord to manage your RTMP server instances.
Also, uvloop or pypy can be used to boost your performance.
Here is nginx configuration example:
stream {
upstream stream_backend {
127.0.0.1:1936;
127.0.0.1:1937;
}
server {
listen 1935;
proxy_pass stream_backend;
}
}Coming soon.
No open issues yet, or sync has not completed.