What is RTMP?
Initially, RTMP (Real Time Messaging Protocol) was created by Adobe Systems for transmitting audio and video streams, text messages, and other data across the web. The main principle of its work lies in initiating interaction between a server and user’s Flash Player. RTMP is based on TCP, which means that its high priority lies in sustaining stable connection and providing low-latency interaction. In order to broadcast smooth streams and to transmit as much data as possible RTMP server divides information into fragments. Then, fragments’ size is defined due to the format of interaction between a user and a server.
What is more interesting about RTMP is that it involves different virtual channels, which transmit data packets during one media session. These channels may include: a channel for RPC requests and their results, one for control messages, channels for audio and video streaming. Moreover, they can operate simultaneously without causing any technical issues for one another.
RTMP vs RTSP
In terms of data transmitting, there is another well-known protocol called RTSP. So, let’s take a look at the differences between RTMP and RTSP protocols.
The main purpose of RTSP (Real Time Streaming Protocol) is to maintain the activities of streaming servers. Furthermore, this protocol sets up an interaction between a client and a server. RTSP enables end users to control media session by means of simple commands such as play, pause, and stop. Moreover, it allows clients to watch video from any fragment without waiting for complete download.
RTMP, in its turn, also sustains abovementioned features. However, RTMP server, by means of RTMP protocol, can monitor every action taken by a client starting from the time he or she initiates session until the session is closed. In such a way, it makes reports within RTMP more precise and provides a full picture of user’s activity during particular media session. Likewise RTMP, RTSP is capable of live streaming as well. However, streaming data transmission is not a main task for RTSP, that is why, for this purpose it needs some additional protocols.
How it works
The principle of RTMP work is simple. In order to start RTMP stream, it’s enough to establish interaction between RTMP server and client RTMP player. Once this communication is set up, the server starts transmitting the media as a constant flow of bytes. This process continues until either the server or the player finishes the session.
The good thing is that RTMP protocol is very flexible and delivering audio, video and text information in various formats belongs to its capabilities. For instance, RTMP protocol enables video streaming in MP4 and FLV formats, audio streaming – in MP3 and AAC. Moreover, thanks to this protocol, RTMP server sends media to web applications as well as to mobile devices. For this purpose a user needs to have Flash Player installed in a browser or on a mobile device accordingly. Then, swf file, which contains all media information of the stream, will be played by Flash Player. However, one of the greatest benefits of RTMP protocol is that it can be applied to live and on demand streaming. Let’s take a look at each of these streaming processes.
Live video streaming belongs to key features of RTMP protocol. With its help, you can broadcast your video live during the process of its recording. Mainly, live broadcasting is used for sports events, shows, concerts etc. In this case, RTMP protocol is literally irreplaceable. It has low latency from real time in streaming, in comparison with HTTP protocol and its delay of more than ten seconds, which is not appropriate for professional live streaming.
Let’s review one more vivid example of RTMP exceptional functionality for live streaming. For example, popular IP cameras that support RTMP protocol, have built in loudspeakers, so you can not only see the video live, but also be involved in the process of broadcasting and express your opinion to the streamers.
On demand streaming
On demand streaming allows users to choose when to watch selected media content, which is more convenient for them rather than to observe this content at the time of its broadcast. As a rule, video on demand (VOD) is used for several reasons: because it plays smoothly even with low Internet connection speed, when the number of viewers online is not substantial, for the sake of HD quality. With RTMP protocol even VOD is more efficient. First of all, it provides multicast support. If you want to have one stream inside your working network and provide it to multiple users, with RTMP you won’t need to create separate connections for each user. Other protocols like HTTP or CDN do not have this feature. Also, RTMP enables users to reconnect to the video stream in case of connection issues. During troubles with connection, the video is played from buffer and when a user reconnects the buffer starts filling and in such a way avoids frequent pauses in video stream.
Obviously, all this information makes you curious how to implement RTMP. This is a cross-platform protocol and it works on Windows, Mac, Linux, Android, Windows Mobile, iOS. Do you have console and enjoy playing games? You can easily use RTMP services for such devices as Xbox One, PlayStation and PS Vita.
Due to the variety of platforms suitable for RTMP protocol, there are many options for its implementation. They can vary from command-line implementation to full featured open source implementation.
RTMPDump tool is used for command-line implementation, as it perfectly copes with recording RTMP streams, live broadcasting and video on demand. Besides, RTMPDump is an open source tool which can be used on Linux, Android, Mac OS X, and Microsoft. This utility is very popular because of its small size and the ability to decrypt RTMPE, which is encrypted RTMP, and RTMPS – secure RTMP.
RTMPDump package has three programs: rtmpdump, rtmpsrv, and rtmpsuck. Each of these programs performs particular functions. For example, rtmpdump is used for establishing connection to RTMP servers and capturing the stream itself; rtmpsuck can capture the stream as well, or it can assist in gathering key parameters for rtmpdump. Main function of rtmpsrv is to keep track of connections and streams.
If you’re more interested in full implementation, you’ll need these three pieces of software: live video encoder, media streaming server and video client application. You don’t know which live video encoder to install? Then, you can choose between Flash Media Live Encoder, FFmpeg, WireCast, Wowza Transcoder, Nimble Streamer Transcoder. However, please take into account that the most popular one is Flash Media Live Encoder, which is available for free download on Adobe website.
As for video client application, Adobe Flash Player is the most advisable variant. It is a free RTMP player and works as a plug-in from a browser or even mobile device. Flash Player is suitable for Windows, OS X, Chrome OS, and Linux. Alternative options are Gnash and VLC media player. Both of them are open source media players. Gnash has all chances to substitute Flash Player in RTMP streaming on Linux. VLC media player, in its turn, is not universal, as it can sustain RTMP streams only partially.
RTMP servers such as Adobe Flash Media Server, Wowza Streaming Engine, Flussonic Media Server are claimed to be very good ones. However, you can install free RTMP server like Nginx with RTMP Module or Red5, which is also an open source RTMP server on Java.
How to tackle the most frequent issues with RTMP protocol
RTMP protocol, despite all its obvious advantages, has also some disadvantages. Due to the fact that it differs a lot from HTTP protocol, it is not sustained by HTML5. Furthermore, RTMP protocol works poorly on iDevices and it affects the quality of video streaming. In such case, it’s better to use HLS protocol on Apple gadgets. The principles of HLS and RTMP work are quite similar, but, in cases with HLS, the stream is divided into series of tiny HTTP-based files. Initially, this protocol was developed for Quicktime, iOS and Safari browser. However, now HLS protocol can be used on many other platforms as well. The protocol copes very well with bandwidth limitations and adapts video quality accordingly. Considering the speed of video delivery, HLS won’t be the best variant, as its latency is twenty seconds.
Another drawback of RTMP protocol is that it’s vulnerable to bandwidth issues. Sometimes, low bandwidth may cause interruptions in media streaming or even stream may not start if Internet connection speed is not enough. An alternative way for broadcasting with limited bandwidth is to use Dash. Dash is an adaptive bitrate streaming technology which provides high quality media broadcasting. This technique is able to diagnose the bandwidth of a particular user and adapt video quality accordingly to connection speed. In addition, it cannot do without an encoder that encodes the video at many bit rates. Then, different encodings are switched by the player due to suitable resources. As a result, little buffering is achieved and great video experience is gained. It is hard to estimate all benefits of this technique for streaming major events at national level, for example.
One more downside of RTMP protocol lies in the necessity to have installed Flash Player plug-in, without which RTMP media transmitting will be impossible. Also, there are some troubles while applying RTMP for CDN streaming services.
Do you still have questions regarding RTMP protocol or its implementation? Let us know and we’ll help you with it and demonstrate all its benefits in practice.