Live Streaming RTMP video Through HTTPS

Abhi
3 min readFeb 27, 2021

What is RTMP Streaming?

2012, Adobe Systems started using Real-Time Messaging Protocol (RTMP) for streaming audio, video, and data over the Internet between a Flashplayer and a Media Server. RTMP had gone viral as it had several advantages over its predictors. This protocol maintains constant contact between the video player and the RTMP server. This constant contact makes an RTMP live stream very robust and reliable. It is also possible to live stream on mobile devices via RTMP ingestion to HLS. but in,

2014, HTML5 was released which encouraged online video delivered through HLS streaming and video played by inbuilt HTML5 video players. This gradually replaced Adobe’s Flash protocol. For both broadcasters and reserves, this was an advantage because, HTML5 and HLS are opensource, are more safer, more reliable, and faster than their predecessor.

HLS Basics

Step1. Cuts video content into 10sec chunks with .ts extension
Step2. HTTP server creates manifest files (M3U8 playlist file) which act as an index table for video chunks.
Step3. HTTP server stores and delivers these short clips to viewers
Step4. Browsers will play video encoded with H.264 or HEVC/H.265 codecs.
Step5. Ok, It’s working, Now playback quality !!
user’s video player software (HTML5 default player) detects network conditions and reads the quality-specific index file to determine which chunk of video corresponds to the current network bandwidth.

Deploy live Streaming service over HTTPS server

Install FFmpeg to broadcast from a file (or can use OBS for live camera/screen streaming). also, install DOCKER to run a custom Nginx container

now we need to setup HLS ingest with Nginx web server functionalities. have to build Docker containers

Get SSL certificates for your domain (Letsencrypt.org provides free SSL). and copy and paste “cert” and “pem” files in example.com.crt and example.com.key files respectively. then add rules in Dockerfile to copy these certificates into the container

Then uncomment lines from 50 to53 & 61 to 63 in “nginx.conf” file.
then build and run Docker by

the docker ps command shows the running Nginx conatainer

Then let’s start the FFmpeg service,

when u run this, FFmpeg reads the video file and sends it to Nginx (“rtmp” service in nginx.conf file) it’s then encoded by H.264 and send through HTTP/HTTPS along with manifest files.

open in browser>> https://domain.com/player.html?url=https://domain.com/key01/value01.m3u8

Success!!

How to set up an enterprise-grade Live streaming service with AWS?
(link)

--

--

Abhi

Hello world, Basically a Linux evangelist, Working as a DevOps engineer — ♥ www.abhinand.in/