
// Coding
Which Streaming Protocol is Better for You: RTMP vs. RTSP
// Coding
Let's compare the RTMP and RTSP streaming protocols. We will tell you how they work, what are the pros and cons of each. We will show you how to choose in your case.
If you want to run a video streaming platform with minimum latency, you will have a very limited number of streaming protocols for this task. At the same time, if you want to use the Internet as a video stream transmission channel, the choice will be even less, since you will need to overcome a number of difficulties, for example, jitter, lags or packet loss. In this article, we will compare two such communication protocols - RTMP and RTSP, describe their advantages with disadvantages, and also give some recommendations on choosing the most suitable option for you.
Latency when streaming data via popular communication protocols. Source
If you compare the videos you want to send to viewers with a car, the streaming protocol is the traffic rules and the road that the car takes from one place to another. If the road is good, the car will reach its destination without any problems. If there are hollows and holes on the road, the movement will take longer and the car may be damaged.
With video data, everything is the same: if the protocol is good, the video signal will reach the viewer with minimal delay and will be of high quality. If the protocol is poorly implemented or does not correspond to the task, then the video on the viewer's screen may "crumble", often interrupt for loading, contain artifacts, not load at all, or audio and video signals will be out of sync.
Different streaming protocols target different aspects of the stream (tasks). They are usually divided into adaptive bitrate protocols, which are aimed at reducing delays and buffers for the video stream, and those aimed at minimizing latency, which allows the video signal to be transmitted to viewers in almost real time - live streaming.
RTMP and RTSP are perhaps the two most common protocols focused on low latency video streaming. And although they are designed to achieve similar goals, close comparison between them makes it easy to find significant differences that are important to know.
Real Time Messaging Protocol, or RTMP, is a standardized protocol for transferring multimedia data over the Internet. This technology was developed by Macromedia (currently owned by Adobe) and was originally used to transfer data between an RTMP server and a Flash player on the user's device. Flash is no longer used due to security concerns, but RTMP is still popular.
As a communication protocol, RTMP technology aims to provide stable and smooth transmission of the increasing amounts of data required to transmit and receive video in real time. This is achieved by fragmenting the data stream into small equal parts (the default is 64 bytes for audio data and 128 bytes for video data) and their sequential transmission to the receiving device, which then reassembles them into a video stream.
After Flash became outdated in 2020 (Google and other big players stopped supporting Adobe Flash Player altogether), RTMP was used as an open source protocol for the first mile contribution (transfer from the encoder to the network video host). This is how RTMP is currently used by Facebook, YouTube, Periscope and most other platforms.
RTMP currently exists in 5 variants:
Typically, live video streaming works like this: a camera captures video (or a video card captures the screen) and sends it to the host or video platform server through an encoder (this step is commonly referred to as the "first mile"). Then the server or video platform processes this stream and transmits it further through the content delivery network (CDN) to distribute the video stream to users' devices (this is the "last mile"). When Flash was still running, both of these steps went through RTMP, but since Flash became outdated, RTMP no longer works on the "last mile". From this point on, the stream must intercept another communication protocol (HLS, MPEG-DASH, CMAF or WebRTC).
The diagram shows four distinct stages in the real-time video delivery chain. The first stage is usually called the "first mile" (video transmission from the camera to the server), and the fourth is called the "last mile" (the video is delivered to the user's screen, for example, a TV). Source
RTMP packets are delivered in a few seconds in three stages:
To ensure smooth and consistent streaming, RTSP uses two other network communication protocols - TCP to issue and receive control commands (such as a play or stop request) and UDP (User Datagram Protocol) to deliver audio, video, and data. Thanks to this, the client can start playing the RTSP stream while downloading the stream.
Although RTSP can be used for both live broadcasts and video-on-demand, it is now commonly used in the last mile to transfer a video stream from the cloud to the player of the user's device, since this protocol allows the viewer to play, pause and rewind the video. In addition, RTSP is also popular in systems where you need to transmit video signal from cameras over IP, for example, from IP cameras or CCTV cameras.
RTSP video transmission scheme. Source
Once the device (player) knows the list of commands and how to make the request, it sends a request for the description of the video content to the streaming server, and the server responds with a description of this media. Then the device sends a download request, and the server responds with information about the transport mechanism, and then the video streaming process is initiated through the specified mechanism.
Since RTSP depends on a dedicated server and relies on RTP, this protocol does not support encrypting video content or retransmitting lost packets. In addition, RTSP is not HTTP compatible, hence it does not allow for direct playback of the video stream in a web browser. To do this, you need to convert the video stream through a special intermediate server.
In the vast majority of cases, the choice between RTMP and RTSP is determined by the project task and the devices used to stream video in real time. Here are some guidelines on when to use which video streaming protocol to use in your case.
IP cameras → RTSP. Almost all IP cameras support RTSP, which is due to the fact that IP cameras existed long before the creation of the RTMP protocol. And since RTSP was (and still is) a fairly simple and effective tool for transmitting video signals, there is no need to change anything.
In conjunction with RTSP and IP cameras, the IP camera itself acts as an RTSP server. This means that to connect a video camera to the IP camera server and broadcast video, you need to launch an RTSP client, for example, via Restreamer Red5 Pro. This plugin allows you to connect to the stream as a client and redirect it to other endpoints that support Red5 Pro (a browser that works with WebRTC).
IoT devices → RTSP or RTMP. Sensors, drones, robots, cars, and other IoT devices can benefit from the ability to stream live video. Since such a broadcast will not only show what the IoT device "sees", but will also allow it to be controlled in real time. Fortunately, most of these devices are natively built in software with RTSP support. However, some manufacturers like DJI prefer RTMP.
Red5 Pro Mobile SDK → RTSP. Usually mobile devices do not support RTSP. However, it can be easily added using the Red5 Pro Mobile SDK, which uses RTSP to stream live video content to and from mobile devices via the Red5 Pro app. Thus, you can create both separate source-viewer connections and conduct a large number of broadcasts to a large number of viewers (streamer subscribers).
YouTube, Twitch, Facebook → RTMP. Despite the refusal of Flash Media Player, RTMP is still used as a receiving protocol in many third-party streaming services and applications, such as YouTube Live, Twitch, and Facebook. Zoom also has built-in support for outputting video stream via RTMP.
Old hardware encoder → RTMP. Many hardware video encoders (especially for older devices) only accept RTMP streams. If your task / project requires the use of such an encoder, then the choice between RTMP and RTSP will be obvious for you.
The debate over which streaming protocol is better, RTMP or RTSP, has been going on for over twenty years, and it looks like it will not end until one of the protocols is completely outdated. Which, most likely, will not happen soon due to a sharp increase in the number of vloggers, streamers and other live broadcasting enthusiasts.
However, when you think about it, you don't have to choose between one of these video streaming protocols. By choosing a reliable technical partner like Merehead, you can develop a solution that takes the best of these two protocols and overcomes their shortcomings. Custom development will require a little more time and resources than off-the-shelf solutions, but it will still be more profitable in the long run.