Live Video Streaming Servers
“We just need a URL that we can give to our user base to watch live video from a camera.” Sounds like an easy request, right? Unfortunately, no, there are many steps needed to achieve this. Below I summarized some basic principles of how to organize live video streaming.
Video sources, players and formats.
First question, where do you want to watch video? If it’s in a mobile app then you have more flexibility with formats. If you need to see video in web browsers then you are limited to formats supported by browsers. Let’s assume that you would like to make it working for a maximum audience, including those who will watch it using a web browser (For example, you can watch Periscope videos from your mobile device or from your desktop computer).
The most popular live streaming formats supported by web browsers are WebRTC, HLS and RTMP. However, RTMP requires a Flash plug-in. Sadly, browsers are actively phasing plug-ins out. This means your best bets are WebRTC and HLS.
This might be sounding easy, again. However, some video sources don’t support WebRTC or HLS, which means you’ll have to transform the stream to WebRTC or HLS. Depending on input video codec, it could be from a relatively simple reformatting to a complete video/audio transcoding.
Video sources can be divided in two types; push and pull video sources. Push video sources is when video source streams (pushes, publishes) video to the streaming server, most common protocols are RTMP push, RTSP push and HLS publish. Pull video sources is when a streaming server pulls video using standard streaming protocol, such as RTSP or RTMP.
To watch live video you’ll need a streaming server. Very often video sources have streaming servers on board, for example IP cameras. As a rule “on board” streaming servers have limited performance and are good only if you have few watchers. If the goal is to broadcast video or, in other words, to make it available for a large audience, you’ll need a streaming server or multiple servers with the capability to handle all your watchers. (Sometimes you will see a live stream ‘crash’ because their servers can’t handle the number of watchers).
The last step is to define the network configuration for your streaming solution. The goal is to make sure that your users can access the streams either using direct connection to your video source or through connection to a streaming server. There are 3 types of connection:
- Direct connection.
- Point-to-point connection.
- Connection through a streaming server.
Direct connection means that your video source has an onboard streaming server and the player connects to it by IP address. It means that the player and the video source should be in one local network or video source should have a public IP address.
Point-to-point connection is type of connection between a player and a video source when peers could be in different local networks. From the protocols in consideration, only WebRTC supports it. In WebRTC the peers establish a connection using external STUN (Session Traversal Utilities for NAT) server or use TURN (Traversal Using Relays around NAT) server if STUN doesn’t help. Similar to direct connection, number of users who can watch video simultaneously will be limited to performance of the on board video server at your video source.
Connection through a streaming server adds more flexibility in design of network configuration and allows to scale solution if you need to broadcast video to many users simultaneously.
Streaming servers with push sources.
If you use push sources then the network configuration is simple. All you need is to have your streaming server on a public IP address. Then you can push video to this streaming server from your video source even if it’s behind NAT and view video by connecting to a streaming server from any network that has access to Internet.
Streaming servers with pull sources.
There are 5 main network configurations for pull video sources.
Streaming server in a local network.
It works with local and global IP video sources. Viewers can only watch video from your local network.
Streaming server in a local network with port forwarding.
Same as in the previous section but viewers can watch video from anywhere. Requires configuration of port forwarding on your network router.
Streaming server in the Internet
Viewers can watch video from anywhere. It works only with global IP video sources.
Streaming server in the Internet with a VPN to a local network.
Same as in the previous section plus it works with local IP video sources assuming there is a VPN to a local network. Requires VPN server or a router with VPN support.
Steaming server in the Internet and Streaming server – relay in a local network
This is the most flexible configuration. It doesn’t require any additional network configuration (like VPN or port forwarding).
Yaro Lisitsyn Co-founder | VXG (Video Experts Group)