Skip to content

A simple live video streaming service using nginx, rtmp, hls and golang. Made for the purpose of understanding how the RTMP protocol works.

Notifications You must be signed in to change notification settings

Philipelima/rtmp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RTMP SERVER

NGINX go

A simple live video streaming service using nginx, rtmp, hls and golang (for authentication service).


What's RTMP ?


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.


How a RTMP transmission works?


A RTMP transmission works in three-steps:

  1. 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.

  2. Connection - The client and server then negotiate a connection using Action Message Format (AMF) encoded messages.
  3. Stream - Having completed the handshake and connection steps, the streaming data can now be delivered.

How this project works?

This project was created with Docker and separated into 3 services:

  1. auth - the authetication service, which is called by Nginx to validate the access key. The service has been developed in golang.

  1. database - postgres database used to store the access keys. This is where the auth service queries if the supplied key is valid.

  1. rtmp - the rtmp server used to transmit the data.
Service ports:
Service Port
auth 8000
database 5430
rtmp 1935

How you can run this project on your pc:

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

About

A simple live video streaming service using nginx, rtmp, hls and golang. Made for the purpose of understanding how the RTMP protocol works.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages