Learn RTMP and RTSP streaming protocols in seconds

Learn RTMP and RTSP streaming protocols in seconds

RTMP and RTSP are two common streaming protocols. So what is RTMP? What is RTSP? What is the difference between them? How should we choose between them?

What is a streaming protocol?

Streaming Protocol, whose English name is Streaming Protocol, can be explained in simple terms: Streaming Protocol is a protocol used to deliver multimedia over the Web.

Every time you watch a live or on-demand video, the technology behind it is a streaming protocol.

There are many streaming protocols, which can be divided into three categories:

  • Traditional video streaming protocols
  • HTTP-based adaptive protocol
  • New Technology

Traditional video streaming protocols

Traditional video streaming protocols mainly include:

  • RTMP
  • RTSP

HTTP-based adaptive protocol

The main adaptive protocols based on HTTP are:

  • Apple HLS
  • Low-Latency HLS
  • MPEG-DASH
  • Adobe HDS

New Technology

The new technologies mainly include:

  • SRT
  • WebRTC

What we are going to introduce and compare today are the traditional video streaming protocols: RTMP and RTSP.

TCP and UDP

Before discussing RTMP and RTSP, we need to understand TCP and UDP first, because RTMP is developed based on TCP, and RTSP uses UDP.

TCP

TCP English full name: Transmission Control Protocol, Chinese meaning: Transmission Control Protocol.

The TCP protocol is a transmission control protocol located between the application layer and the network layer, which is used to provide reliable stream transmission services, that is, transmitting data in the form of byte streams and receiving data in the form of byte streams. TCP uses a confirmation mechanism to check whether the data has arrived safely and reliably, multiplexing it at the sending end and demultiplexing it at the receiving end. TCP uses three stages to implement connection-oriented functions, such as connection establishment, data transmission, and connection termination.

UDP

UDP English full name: User Datagram Protocol, Chinese meaning: User Datagram Protocol.

UDP is a connectionless protocol, i.e., it transfers data from one end to another; without establishing a connection. UDP also sits between the application layer and the network layer. It also delivers data or information in the form of packets; these packets are called user datagrams. UDP uses multiplexing to handle outgoing user datagrams from multiple processes and demultiplexing to handle incoming user datagrams going to different processes on the same host.

Differences between TCP and UDP

  • TCP is connection-oriented, while UDP is connectionless
  • TCP is heavyweight, while UDP is lightweight
  • TCP provides reliable service, while UDP does not provide reliable service
  • TCP supports retransmission mechanism, but UDP does not
  • TCP packets arrive at the receiver in order, while UDP packets arrive out of order
  • TCP does not support broadcasting, but UDP does.
  • A TCP connection is a stream of bytes, while a UDP connection is a stream of messages.

The above is the most basic part. Now I will get into today’s topic: RTMP and RTSP protocols.

RTMP

  • English full name: Real Time Messaging Protocol
  • Chinese meaning: Real-time Messaging Protocol
  • Underlying protocol: TCP
  • Application-level video streaming protocol
  • Video Codec: H.264
  • Audio Codec: AAC
  • Delay: 3 - 30 seconds

RTMP was born in 2005, developed by Macromedia and later acquired by Adobe, and has a long history in the streaming market. It was originally used to transmit data between RTMP servers and Flash players on user devices, but Flash officially ended in 2020.

The biggest advantage of RTMP is that it can maintain a stable connection between the server and the client server, and it can perform seamless low-latency streaming regardless of the quality of the user's Internet connection. This technology is mainly achieved by dividing the data stream into equal small parts (audio data defaults to 64 bytes, video data defaults to 128 bytes) and transmitting them sequentially to the receiving device, and then reassembling them into a video stream.

How RTMP works

Generally speaking, video streaming works like this:

  • Camera capture video
  • Transmit video streams to video platform servers through encoders
  • Video platform processes video streams
  • Distribute to the server closest to the user through CDN
  • Finally, the video stream can successfully reach the user's device

RTMP plays a very important role in this link. In the process of video from the camera to the server, RTMP divides a large amount of data into small blocks and transmits it across multiple virtual channels, providing a stable and smooth video stream between the video source and the RTMP server.

The biggest disadvantage of RTMP is that it is not compatible with HTML5 players, so another protocol such as HLS must be used to transmit the video file to the user's device. In addition, RTMP is susceptible to bandwidth issues.

RTSP

  • English full name: Real Time Streaming Protocol
  • Chinese meaning: Real-time Streaming Protocol
  • Underlying protocols: TCP and UDP
  • Network Control Protocol
  • Video Codec: H.265
  • Audio Codec: AAC
  • Delay: 2 seconds

RTSP was born in 1996 and was jointly developed by experts from RealNetworks, Netscape, and Columbia University for entertainment and communication systems that control VHS-style video streams. RTSP uses the efficient RTP protocol to break stream data into smaller blocks, which can be delivered faster.

RTSP supports reliable segmented streaming, which means that users can continue to watch the stream while it is still downloading.

Android and iOS devices do not have RTSP-compatible players out of the box, so RTSP is not widely used, but RTSP is widely used in many surveillance and closed-circuit television (CCTV) applications, such as remote cameras, online education, and Internet live broadcasts.

As mentioned above, RTSP uses the RTP protocol to decompose video blocks. Here we will talk about the RTP protocol.

RTP protocol, the full English name: Real-time Transport Protocol, is the real-time transport protocol in Chinese. Its underlying layer is actually UDP, which can achieve low latency.

In addition to the RTP protocol, RTSP uses two other network communication protocols to ensure smooth and consistent streaming:

  • TCP sends and receives control commands (such as play or stop requests)
  • UDP transmits audio, video and data

How do you understand this?

TCP reliable transmission, for example, when the user presses the play or stop button, this is an accurate request, which needs to ensure reliability. This is when the role of TCP is reflected.

UDP is a low-latency protocol, so it can be used to transmit audio, video, and data very efficiently.

How RTSP works

  • The user device sends an RTSP request to the video streaming platform
  • The video streaming platform returns a list of operational requests, such as play, pause, etc.
  • The user device sends a specific request to the video streaming platform, such as playing
  • The video streaming platform parses the request and calls the specified mechanism to start video streaming processing

Because RTSP relies on dedicated servers and is dependent on RTP, the protocol does not support encrypted video content or retransmission of lost packets.

Differences between RTMP and RTSP

1. Delay

RTMP: 3-30 seconds

RTSP: 2-5 seconds

2. Audio Codec

  • RTMP: AAC, AAC-LC, HE-AAC+ v1 & v2, MP3, Speex, Opus, Vorbis
  • RTSP: AAC, AAC-LC, HE-AAC+ v1 & v2, MP3, Speex, Opus, Vorbis

3. Video Codec

  • RTMP: H.264, VP8, VP6, Sorenson Spark®, Screen Video v1 & v2
  • RTSP: H.265 (preview), H.264, VP9, ​​VP8

4. Advantages

  • RTMP: Low latency Adaptability Flexibility No buffering required
  • RTSP: Low-latency segmented streaming

5. Disadvantages

  • RTMP: Bandwidth issues HTML5 not supported Compatibility issues with some browsers and devices Low security
  • RTSP:
  • HTTP Incompatibility
  • Dependency on other protocols

How to choose between RTMP and RTSP?

In fact, after reading the difference between RTMP and RTSP, you should have an insightful understanding of the usage scenarios.

  • IP cameras, IoT devices, then you can't go wrong by choosing RTSP
  • If you are looking for a third-party streaming application, then RTMP is the right choice

Summarize

This article mainly introduces streaming media protocols, TCP and UDP protocols, RTMP and RTSP protocols. Both RTMP and RTSP streaming media protocols have their own advantages.

RTMP provides compatibility with different ingest devices and stability for low-latency streaming, however, you need a specific Flash Media Server to distribute your content using RTMP, so RTMP is suitable for major third-party streaming applications and older hardware encoders;

RTSP is best used with IP cameras and devices running IP cameras, such as drones.

Friends, do you understand?

<<:  Let’s talk about what communication is.

>>:  How can Wi-Fi positioning technology survive in a field full of strong competitors?

Recommend

Are Paxos and Raft not consensus algorithms/protocols?

As a member of the Internet, we are often immerse...

Learn how to start your networking career

The networking industry is changing rapidly, and ...

How big is the bandwidth of 1M cloud server? It is enough for 90% of websites

1M, as the lowest bandwidth configuration of clou...

The key challenges facing MSPs and CMPs in “multi-cloud” are: Network

The rapid development of new cloud-based applicat...

One of the biggest features of 5G is the security minefield

The 5G platform provided by operators has vulnera...

Why SDN and IBN Require Better Network Visibility

Intent-based networking (IBN) has been a topic of...

...

Millimeter wave tragedy puts 5G in an awkward position

The United States is increasingly anxious and str...

Remember who was to blame for a thread pool-induced fault?

This article is reproduced from the WeChat public...

How IPv6 will gradually replace IPv4

Have you noticed that many apps now have a line o...

2021 China Internet Haha List 2: Top Ten Events

In 2021, the Internet industry has emerged with m...