A simple live video streaming service using nginx, rtmp, hls and golang (for authentication service).
RTMP (Real-time messaging protocol) is a data transmission technology developed by Macromidia, initially dedicated to transmitting data between streaming servers and the old Adobe Flash Player.
Nowadays the RTMP protocol is constantly used by services such as Facebook, Twitter, and Twitch to deliver live video to their users.
In RTMP the content is delivered in chunks, usually called "chunks", so the user can consume the content without having to wait for the complete download.
A RTMP transmission works in three-steps:
- Handshake - The client, which can be an encoder software or hardware, that wants to transmit data initiates a connection by exchanging 3 packets:
- The first packet - sent by the client is the RTMP version that is being streamed.
- The second packet - sent by the client shortly after, is a timestamp. The server replies with a copy of the two data it has just received.
- The final packet - When the duplex communication is complete, the client sends a copy of the timestamp again. The server returns the copy. When the last packet is returned from the server, the handshake is successfully completed.
- Connection - The client and server then negotiate a connection using Action Message Format (AMF) encoded messages.
- Stream - Having completed the handshake and connection steps, the streaming data can now be delivered.
This project was created with Docker and separated into 3 services:
- auth - the authetication service, which is called by Nginx to validate the access key. The service has been developed in golang.
- database - postgres database used to store the access keys. This is where the auth service queries if the supplied key is valid.
- rtmp - the rtmp server used to transmit the data.
Service | Port |
---|---|
auth | 8000 |
database | 5430 |
rtmp | 1935 |
Clone this repository:
git clone https://github.com/Philipelima/rtmp-server.git
On the project directory, run:
docker-compose build
and after:
docker-compose up