Node.js Streaming Script
Budget: $30 – $250 USD
We can use Strapi or any other good ready made CMS.
Below is some basic server structure of this script,
Web Server: Where we will host node based streaming script
Encode Server : This server will attached with Web Server with FTP Details, where we will upload videos in Ftp directory and node script will scan ftp directory and add details in database and move them to encode directory, where ffmpeg will encode videos in various qualities, after encode these files will be moved on cloud storage, (i will use my own ffmpeg script)
Stream Server/s : We will call this Stream Server/Servers where we will stream videos from the cloud, and have the ability to add multiple streaming servers.
At this point when we have multiple Streaming Servers, we have to use load balancer to know which server has less load and redirect to that Streaming Server.
We have to use player URL from Web Server, and this URL inside have other supporting domains that are pointed to Stream Server/s , These domain are hidden from public,
Example of Streaming URL.
https.webserver.com/video/filename/master.m3u8
This will be a stream URL but this domain is not pointed to Streaming Server/s, where we have a video file to play. But when we open this link, one other domain/s that is pointed to Streaming Server will help the main stream URL to play video, we will call them supporting domains.
Supporting Domains : Every Streaming Server have multiple supporting domains to play video from Streaming Server, For Example
Stream1.com
Stream2.com
Stream3.com
Stream4.com
Stream5.com
When someone request a video URL like i explain above, using it again in below,
https.webserver.com/video/filename/master.m3u8
And load balancer redirects to Streaming Server that has less load, then aap has to choose randomly one of supporting domains to play video from Streaming Server, these supporting domains should not be saved in the database and can be replaced anytime. Purpose of using multiple supporting domains is Cloudflare, we have to add these supporting domains in Cloudflare for better performance, so we are dividing traffic on multiple supporting domains to avoid Cloudflare ban.
Cache
Very important to have all type of cache to make player faster and reduce server loads, We can use internal cache like Database Cache, or Redis etc
We will also use CloudFlare cache that decreases server load a lot and increases performance.
Load Balancing & GEO IP
There are two concepts
Load Balancing: If we have two or more streaming servers in the same location then we will redirect any new user to a server which has less load.
GEO IP: If we have two servers in different locations, we have to redirect users to the nearest server , and if the nearest location has two servers then also have to check which server has less load to redirect users to that server.
Below is some basic server structure of this script,
Web Server: Where we will host node based streaming script
Encode Server : This server will attached with Web Server with FTP Details, where we will upload videos in Ftp directory and node script will scan ftp directory and add details in database and move them to encode directory, where ffmpeg will encode videos in various qualities, after encode these files will be moved on cloud storage, (i will use my own ffmpeg script)
Stream Server/s : We will call this Stream Server/Servers where we will stream videos from the cloud, and have the ability to add multiple streaming servers.
At this point when we have multiple Streaming Servers, we have to use load balancer to know which server has less load and redirect to that Streaming Server.
We have to use player URL from Web Server, and this URL inside have other supporting domains that are pointed to Stream Server/s , These domain are hidden from public,
Example of Streaming URL.
https.webserver.com/video/filename/master.m3u8
This will be a stream URL but this domain is not pointed to Streaming Server/s, where we have a video file to play. But when we open this link, one other domain/s that is pointed to Streaming Server will help the main stream URL to play video, we will call them supporting domains.
Supporting Domains : Every Streaming Server have multiple supporting domains to play video from Streaming Server, For Example
Stream1.com
Stream2.com
Stream3.com
Stream4.com
Stream5.com
When someone request a video URL like i explain above, using it again in below,
https.webserver.com/video/filename/master.m3u8
And load balancer redirects to Streaming Server that has less load, then aap has to choose randomly one of supporting domains to play video from Streaming Server, these supporting domains should not be saved in the database and can be replaced anytime. Purpose of using multiple supporting domains is Cloudflare, we have to add these supporting domains in Cloudflare for better performance, so we are dividing traffic on multiple supporting domains to avoid Cloudflare ban.
Cache
Very important to have all type of cache to make player faster and reduce server loads, We can use internal cache like Database Cache, or Redis etc
We will also use CloudFlare cache that decreases server load a lot and increases performance.
Load Balancing & GEO IP
There are two concepts
Load Balancing: If we have two or more streaming servers in the same location then we will redirect any new user to a server which has less load.
GEO IP: If we have two servers in different locations, we have to redirect users to the nearest server , and if the nearest location has two servers then also have to check which server has less load to redirect users to that server.