HLS vs RTMP - dry statistics. Broadcasting IP cameras in HLS format Hls broadcasting

Processing, storing and transmitting video for his online project, rather than using sites like YouTube, inevitably comes to the question of which transmission protocol to use to broadcast video to users' devices. The choice is small, because... There are a number of industry standards that support certain devices. In addition, the choice of protocol largely depends on the “class” of video - live broadcast or video-on-demand. The choice of the media server that will be the engine of your media machine also depends on the choice of protocol: will you install several heterogeneous servers or build a delivery network on one solution? Therefore, you need to weigh everything and make a decision based on the criteria of your business.

In general, we get an equation with many unknowns. The dynamics of the process are important here - where is the industry going anyway? What if I invest in supporting the technology, but it fizzles out in a year, because this has already happened. Or will I bet on a fashionable technology, but no one supports it?

We decided to evaluate how the share of different protocols changed over time - to look at the dynamics of the whole process. The data was taken for the last year.

Initial data

For starters, who are we to judge market shares? We are the developers of a web reporting service for media servers. We have been working in the market for four years and companies come to us with different infrastructures, different numbers of servers and different needs. It turns out to be a good snapshot of the state of the industry.

We made a small report where you can select a date range and receive data with a graph on the number of video views through different protocols.

The report provides data on servers:

  • Wowza Streaming Engine in all versions, from 2.2 to the latest 4.x; most of them are 3.x.
  • Nimble Streamer, working with HLS, Smooth, HDS and progressive download, is our development.
  • Windows Media Services - there are literally a couple of dozen of them, but they exist, and we need to take them into account
At the time of writing, the service serves about 1000 servers from 60 countries.

The report is also periodically updated on our blog; it is available under the appropriate tag.

Go

The report for June/July 2014 looks something like this. From 1.4 billion views more than half are HLS. In second place is RTMP with a quarter of views. RTSP is about a sixth. The rest are in the region of statistical error.

What happened a year ago during the same period? The situation is almost a mirror image. RTMP - almost two thirds, RTSP and HLS share second and third places. True, the measurement base was almost 3 times smaller - “only” 500 million views. There were also fewer servers in our service, of course.

Let's walk between these two points.

So, June - August 2014, 3 months of summer. 800 million views, but the shares are the same, August did not bring any changes.

September - November 2013. A new season has begun, HLS began to eat away RTMP's share. Total 1.1 billion views, RTMP has about half of the total, HLS has a quarter.

December 2013 - February 2014. 1.4 billion views, of which HLS already accounts for more than 40%. RTMP and RTMP share second and third place with a quarter share. The Olympics in Sochi gave an increase in the number of views and at the same time forced providers to remember all the clients with all their exotic or old devices that only understand RTSP - hence the jump in this protocol.

Processing, storing and transmitting video for his online project, rather than using sites like YouTube, inevitably comes to the question of which transmission protocol to use to broadcast video to users' devices. The choice is small, because... There are a number of industry standards that support certain devices. In addition, the choice of protocol largely depends on the “class” of video - live broadcast or video-on-demand. The choice of the media server that will be the engine of your media machine also depends on the choice of protocol: will you install several heterogeneous servers or build a delivery network on one solution? Therefore, you need to weigh everything and make a decision based on the criteria of your business.

In general, we get an equation with many unknowns. The dynamics of the process are important here - where is the industry going anyway? What if I invest in supporting the technology, but it fizzles out in a year, because this has already happened. Or will I bet on a fashionable technology, but no one supports it?

We decided to evaluate how the share of different protocols changed over time - to look at the dynamics of the whole process. The data was taken for the last year.

Initial data

For starters, who are we to judge market shares? We are the developers of a web reporting service for media servers. We have been working in the market for four years and companies come to us with different infrastructures, different numbers of servers and different needs. It turns out to be a good snapshot of the state of the industry.

We made a small report where you can select a date range and receive data with a graph on the number of video views through different protocols.

The report provides data on servers:

  • Wowza Streaming Engine in all versions, from 2.2 to the latest 4.x; most of them are 3.x.
  • Nimble Streamer, working with HLS, Smooth, HDS and progressive download, is our development.
  • Windows Media Services - there are literally a couple of dozen of them, but they exist, and we need to take them into account
At the time of writing, the service serves about 1000 servers from 60 countries.

The report is also periodically updated on our blog; it is available under the appropriate tag.

Go

The report for June/July 2014 looks something like this. From 1.4 billion views more than half are HLS. In second place is RTMP with a quarter of views. RTSP is about a sixth. The rest are in the region of statistical error.

What happened a year ago during the same period? The situation is almost a mirror image. RTMP - almost two thirds, RTSP and HLS share second and third places. True, the measurement base was almost 3 times smaller - “only” 500 million views. There were also fewer servers in our service, of course.

Let's walk between these two points.

So, June - August 2014, 3 months of summer. 800 million views, but the shares are the same, August did not bring any changes.

September - November 2013. A new season has begun, HLS began to eat away RTMP's share. Total 1.1 billion views, RTMP has about half of the total, HLS has a quarter.

December 2013 - February 2014. 1.4 billion views, of which HLS already accounts for more than 40%. RTMP and RTMP share second and third place with a quarter share. The Olympics in Sochi gave an increase in the number of views and at the same time forced providers to remember all the clients with all their exotic or old devices that only understand RTSP - hence the jump in this protocol.

Provision of services IPTV via the Internet and local computer networks is acquiring increasingly widespread forms. There are almost no large providers left in the CIS countries that do not broadcast video via multicast into their local networks, that is, providing the service IPTV. But the provision of TV services outside of its local network associated with some hardware costs and the difficulty of ensuring the required broadcast quality.

HTTP Live Streaming also known as H.L.S., is a communication protocol implemented by Apple. Its peculiarity is that the overall flow is divided into a sequence of small boot files, each download downloads one small fragment of the transport stream. When a stream is played, the client can choose from several different alternative streams containing the same material recorded for different speeds data transfer, allowing you to adapt to the available data transfer speed. At the start of a streaming session, an enhanced M3U (m3u8) playlist is loaded containing metadata for the various substreams that are available. Because requests use only standard HTTP operations, HTTP Live Streaming is able to bypass any firewall or proxy that allows standard HTTP traffic as opposed to UDP protocols such as RTP.

HLS is based on HTTP. HLS also defines a standard encryption mechanism using AES and a security key distribution method using HTTPS or HTTP cookies, which together provide simple system copyright protection.

How does HLS work?

Now let’s find out what are the advantages and disadvantages of this technology. The advantages are undoubted and obvious. This is, first of all, the adaptability of the data transmission speed to the properties of the line and the receiving device, and secondly, built-in copyright protection mechanisms. Third, no router with width restrictions is required multicast stream via WI_FI, which would help avoid the absorption of the entire channel width by multicast streams in the case of IP television broadcasting using multicast. Also not required additional device with function UDP proxy to convert a multicast stream to HTTP, which is often required for mobile devices, although it affects the hardware load on the router or other device that performs the UDP-proxy function in the subscriber’s local network. The HLS standard has become quite widespread and is supported by almost all modern video players and IPTV set-top boxes.

IPTV set-top box

A significant disadvantage is that subscribers have multimedia set-top boxes and smart-TV set-top boxes with outdated firmware or outdated designs that do not support HLS standards or do not support them correctly. Also, one of the problems is the inability to correctly select the quality for stable broadcasting in conditions of changing line characteristics in time intervals shorter than the duration of the requested video fragment.

To organize online broadcasts in real mode time, video on demand (vod), and also to record video streams, you can use nginx together with the nginx-rtmp-module module.

Media servers

Today there are several popular media servers, which you can read more about in one of them. Media servers are needed to create online broadcasts in real time.

There are both paid and free media servers that include different functions. Today we will talk about one free and pretty good solution.

Ngnix-rtmp

The basic functionality of a media server can also be implemented using a free software— the Ngnix-rtmp-module module, which is on this moment supports streaming protocols such as RTMP and HLS.

Thus, using Ngnix-rtmp (Ngnix web server + Ngnix-rtmp-module module), you can organize RTMP and HLS broadcasting to user devices. A summary table of protocols and devices that support them can be found in the article. Also, in one of my future articles, I plan to make a comparison table of the functionality of the Ngnix-rtmp-module module and other media servers.

Online broadcast via HLS protocol

Today we will look at how to use the Nginx-rtmp-module to organize a simple broadcast with an adaptive bitrate using the HLS protocol. First of all we need to download source codes Nginx web server from the official website. All commands presented below were executed in Linux.

  • wgethttp://nginx.org/download/nginx-1.4.1.tar.gz

Extract files from the archive.

  • tar -zxvf nginx-1.4.1.tar.gz

Download zip archive with the source files of the nginx-rtmp-module module and extract the files from the archive.

  • wget https://github.com/arut/nginx-rtmp-module/archive/master.zip

Now we need to compile nginx with the module nginx-rtmp-module , to do this, when configuring nginx, you need to specify in the option --add-module location of source files nginx-rtmp-module , and you must also specify an additional option with-http_ssl_module .

./configure --add-module=/home/nginx/nginx-rtmp-module-master --with-http_ssl_module

make install

  • If everything went without errors, you can start setting up the server. By default, the server is installed in the directory/usr/local/nginx . The nginx.conf server configuration file is located in the directory/usr/local/nginx/conf . Let's take a closer look at the rtmp:server section of the configuration file. The listen parameter specifies the port on which the server will accept rtmp requests.
  • Next we open the section for setting up the testlive application. Here we indicate that we have a live stream - the live on parameter, we enable support for the hls protocol for this application - the hls on parameter.
  • Using the parameter hls_path we set the directory in which the chunks (pieces) of the stream will be located. In order for chunks (pieces) for each video stream to be located in a separate directory, you need to include the directive hls_nested on .
  • Next, using the parameter allow publish we allow you to publish streams from your computer, and using the parameter deny publish all We prohibit everyone else from publishing videos.
  • Now let's look at the sectionhttp:server . In the parameter listen it is necessary to indicate on what port the server will receivehttp requests. We specify port 8080. And from the example configuration file move the sectionhttp:server:location/hls . You can view more detailed information on all directives of the configuration file at:https://github.com/arut/nginx-rtmp-module/wiki/Directives.
  • It's time to start the server. To do this you need to go to the directory /usr/local/nginx/bin and run the command ./nginx .

Now let's look at one example. We send three video streams to the server:

  • test1 with a bitrate of 256 kbit/s,
  • test2 with a bitrate of 512 kbit/s,
  • test3 with a bitrate of 1024 kbps.

Our goal is for a client using the HLS protocol (devices: Mac, iPad, iPhone) to be able to dynamically switch between streams, depending on the quality of the Internet connection. To do this we need in the directory /usr/local/nginx/html create a file with the extension m3u8 , For example playlist.m3u8 , with the following content:

#EXTM3U

#EXT-X-VERSION:3

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=256000,RESOLUTION=640×480

hls/test1/index.m3u8

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=512000,RESOLUTION=640×480

hls/test2/index.m3u8

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1024000,RESOLUTION=640×480

hls/test3/index.m3u8

Watch the broadcast

To view video streams, you need to embed the following code into the site's web page.

- IP address of your nginx server.

[playlist name]- the name of the file created in the previous paragraph (playlist.m3u8).

Below is an example of a simple nginx.conf configuration file.

worker_processes 1;

server(

listen 1935;

application test live (

live on;

hls on;

hls_path /tmp/hls;

hls_nested on;

allow publish 10.10.146.148;

deny publish all;

server(

listen 8080;

server_name rtmp_test;

charset utf-8;

location/(

root html;

index index.html index.htm;

location /hls (

types (

application/vnd.apple.mpegurl m3u8;

alias /tmp/hls;

Conclusion

This article was written and published jointly with my colleague Evgeniy Petrov. We use this module (Ngnix-rtmp) in different projects. If anyone has any questions about Ngnix-rtmp, Wowza server, write. If you need to configure something or get advice on media servers and multimedia systems, you can also contact me and our team via.

Flussonic Media Server supports video distribution via HLS protocol.

Many of the available features are not standard for HLS, but we support them for your convenience.

Supported codecs: H264, H265, MPEG2 video, AAC, MP3, MPEG2 audio, AC-3.

Flussonic Media Server allows you to receive live broadcasts, video on demand, and video from the archive (catchup and timeshift) via HLS.

Simple HLS playback

If you have a simple live stream or file (one video, one audio), then the URL to play via HLS is very simple:

http://flussonic-ip/STREAMNAME/index.m3u8

where flussonic-ip is an example address + port of your Flussonic Media Server.

Flussonic Media Server also accepts playlist.m3u8 at the end of the URL for backwards compatibility with other servers.

When you start working with multilingual or multibitrate content, things get more complicated.

Multilingual HLS

If you want to play your multilingual stream on iPhone, you need to use the same http://192.168.2.3:8080/STREAMNAME/index.m3u8

But if you want to watch a multilingual stream using VLC or a set-top box, you need to enable video.m3u8.

URL for the player: http://flussonic-ip/STREAMNAME/video.m3u8

This is due to the fact that, according to Apple HLS requirements, for each individual language you need to specify a separate playlist with an audio only option. MPEG-TS has a different mechanism: all audio tracks are placed next to the video, and the player itself chooses what it will play. For a video to be viewable on iPhone, it must meet Apple's requirements. But VLC and set-top boxes, in violation of the HLS standard, expect old version MPEG-TS converted to HLS. Therefore, you need to include video.m3u8.

Adding "Audio only" for Apple

Apple requires all your streams to have a no video, audio only option.

They believe that if a user is watching a video over 3G and finds himself in an area of ​​​​uncertain reception, it is better for him to have only sound than buffering.

You can enable this option in Flussonic Media Server:

stream ort (url udp://239.0.0.1: 1234; add_audio_only; )

Please be aware that this may make your index.m3u8 address unplayable in VLC or STB. In this case, use video.m3u8 .

Separate bitrates for set-top boxes

When you have multibitrate multilingual content and want to play it on a set-top box that does not support multibitrate HLS playlists, you can request from Flussonic Media Server separate playlists with one video and all audio tracks, as with the mono option:

http://flussonic - ip/STREAMNAME/video1. m3u8

This playlist is not multibitrate, it contains URLs up to the segments, in which the first video track and all available audio tracks.

If you want to deliver multilingual, multibitrate streams to set-top boxes that don't understand the Apple multilingual standard, use video.m3u8:

http://flussonic - ip/STREAMNAME/video. m3u8

This is a multibitrate playlist that provides a list of playlists with different qualities: video1.m3u8, video2.m3u8, etc.

DVR catchup playback

When your stream is already recorded on the server by our DVR, you can play the video via HLS using the start and end times of the transmission (for example, from the EPG).

http://flussonic - ip/STREAMNAME/archive -1508403742-3600. m3u8

This playlist will be so-called. variant, if there will be more than one in the stream audio track or more than one bitrate. It will give a list of segments starting from UTC 1362504585 (2013 March 5 17:29:45 GMT) and forward one hour.

Mono URL will give a list of segments containing all the tracks in mpeg-ts:

http://flussonic - ip/STREAMNAME/mono -1362504585-3600. m3u8

A more specific videoN playlist will give a list of segments with N video tracks and all audio tracks:

http://flussonic - ip/STREAMNAME/video1 -1362504585-3600. m3u8

and a variant video playlist with a list of videoN playlists:

http://flussonic - ip/STREAMNAME/video -1362504585-3600. m3u8

Rewind playlist

There is a special playlist "rewind-N.m3u8" with a large “sliding” window, allowing you to rewind and pause HLS streams for many hours.

http://flussonic - ip/STREAMNAME/rewind -7200. m3u8

7200 - HLS playlist length in seconds. This means that your clients can pause the broadcast for 2 hours or rewind to the beginning of a football match without accessing special archive links.