media server logo

How to create a Video Streaming Server in minutes

Oct 23, 2023

Who is this article for?

This article is written for both beginners who want to learn how to organize video distribution and streaming, and for professionals who want to develop their own applications using Callaba’s video streaming server.

What is a video streaming server?

A video streaming server, as the name suggests, is a server application that allows you to receive real-time video or audio streams and distribute them to an online audience. When you run a server with such an application, you can configure your preferred video data transmission technology. Typically, SRT or RTMP is used for real-time streaming. In Callaba, you can configure SRT, RTMP, RTSP, HLS, RIST.

To set up a video streaming server and enable video playback in your browser, follow these steps:

  1. Launch the Callaba video streaming server console.
  2. Add a stream via SRT or RTMP in the Streams section.
  3. Add a web player in the Web Players section.
  4. Configure CDN (Content Delivery Network).
  5. Share the link with your audience or embed it on your website.

📖 How to launch Callaba on AWS
📖 How to set up a Load Balancer on AWS

How does the video streaming server work?

When you initiate an instance with Callaba and create a stream, the server enters a waiting state, ready to receive video streams. Once an actual video stream arrives, the video streaming server begins distributing fragments automatically to audience members' browsers. 

Video data is transmitted in packets, which can either be unordered (in the case of SRT) or ordered (for RTMP). These packets are then divided into short video fragments and sent to the viewers.

Recommendations for setting up your video streaming server

  • Send videos in a way that the bitrate is not more than 50% of the network channel width.
  • To avoid buffering and maintain video quality, send videos with a resolution of 1920x1080 and a bitrate of 4500-6000.
  • If necessary, you can configure adaptive bitrate.
  • Use a CDN (Content Delivery Network).

How adaptive bitrate works

When adaptive bitrate is enabled, the video streaming server simultaneously generates video fragments in various resolutions, ranging from the original resolution to the lowest acceptable quality. For instance, if you upload a 1080p video, Callaba's streaming server will automatically create fragments for 720p, 480p, and 360p resolutions respectively.

Users will receive video in a resolution that aligns with their internet connection capabilities. They can also adjust the video resolution through the player settings if they want to.

Learn more :

📚 Adaptive bitrate streaming: How it works and why it's important

What is CDN?

A CDN (Content Delivery Network) stores and delivers media files by caching them in various locations worldwide. By doing so, it prevents the “main” video streaming server from being overwhelmed with user requests. 

When users request video fragments, the fragments are delivered from the nearest caches, reducing latency. This is possible due to edge caching technology.

Is there a free CDN?

Yes. Callaba supports CloudFlare, which is free and reliable. In addition, you get DDoS protection. You can start your project using CloudFlare. To cache video fragments, you just need to register and add your project. If necessary, you can add a cache rule for .ts files.

How CDN works in conjunction with the video streaming server

When a user starts watching your video, their browser sends requests for new video chunks. These requests first go to the CDN web server. If the CDN server does not find the new fragment in its cache, it sends a request to your video streaming server to get this chunk and caches it in its memory. The next user will get this chunk from the edge cache. This way, the video streaming server is not burdened with video distribution-related load.

Embedding video from the video streaming server on a website

After creating a web player, you can copy the HTML5 code and embed it on your website. 

In Callaba, you can find the embedding code in the “Web Players” listing. Just click the Info (i) button. 

Callaba provides two types of embedding : video only and video player. 

When embedding a video player, you get the opportunity to embed a customizable player using your background and/or logo.

Is the video streaming server suitable for creating an OTT/VOD platform?

Yes, you can create a video library using the API.

When developing a mobile application for an OTT/VOD platform, you can use ExoPlayer for Android and AVPlayer for iOS. These are standard technologies for producing mobile video applications. 

If you want to create a cross-platform application using React Native, you can use react-native-video. It implements the native players mentioned above.

How to create an SRT or RTMP gateway via an API

Copy the token in the General Settings section and make a /create request. Here is the link to the documentation on working with streaming modules.

API Documentation :

🔧 Create SRT video streaming server via API
🔧 Create RTMP video streaming server va API

How to create a Web Player via API

Make a creation request using the API token as instructed here:

🔧 API Documentation : Video Players

How to get HLS Player Link via API

After creating the player, you can request the manifest file from the web server using a GET request with the following pattern: 

https://your-domain-under-cdn/hls/Player-ID/Player-ID/index.m3u8

In-Depth Analysis: Is a cluster needed for a video streaming server?

If you are organizing a live broadcast for a really big audience, you may encounter a situation where the resources for processing your broadcast turn out to be insufficient. In such a situation, it is necessary to launch multiple Callaba instances and then configure them in a load balancer.

How to add Callaba Instances to the Load Balancer

This article provides instructions on how to add instances on AWS : 

📖 How to set up a Load Balancer on AWS

How to launch Callaba instances via API

Depending on your hosting or cloud provider, you can manage nodes using the API.

Let's consider an example and boilerplate of working with the AWS API:

📔 GitLab aws-react-nodejs-example

Conclusion

In this post, we demonstrated how to set up a video streaming server from scratch, even if you are a beginner. We also discussed the key nuances when developing your own application based on the Callaba video streaming server. If you have any questions, feel free to reach out to us via [email protected]