RTMP vs RTSP/RTP: Which to choose for an interactive livestream?

Joey picture Joey · Aug 6, 2017 · Viewed 22.1k times · Source

If you are trying to develop an interactive livestream application, you rely on ultra low (real-time) latency. For example for a video conference or a remote laboratory.

The two protocols, which should be suitable for this circumstances are:

  • RTSP, while transmitting the data over RTP
  • RTMP

*WebRTC: As I'm trying to give a bigger audience the possibility to interact with each other, WebRTC is not suitable. Because as far as I know it is not designed for a bigger audience.

My questions:

  1. Which one should I choose for this use-case? RTSP/RTP or RTMP?

  2. Which protocol delivers better results regarding end-to-end latency, session start-up time?

  3. Which one consumes more hardware resources?

  4. RTMP seems to use a persistent TCP connection. But which protocol is used for the transmission? It cannot be TCP, because this could not ensure real-time latency?

  5. What are in general the pros and cons for using either of the protocols?

I did not find any comparison of these two protocols in scientific papers or books. Only that the famous mobile live-streaming app Periscope is using RTMP.

Other apps like Instagram or Facebook are for example providing text-based interaction with the streamer. If developers want to build the next "killer application" based on interactive live-streams: I think this question is essential to answer.

Answer

Brad picture Brad · Aug 6, 2017

You make a lot of assumptions in your answer.

WebRTC: As I'm trying to give a bigger audience the possibility to interact with each other, WebRTC is not suitable. Because as far as I know it is not designed for a bigger audience.

That's simply not true. WebRTC doesn't know or care how you structure your applications server-side. There are plenty of off-the-shelf services for handling large group calls and low latency video distribution via WebRTC.

You should also know that for the media streams, WebRTC is RTP under the hood.

It cannot be TCP, because this could not ensure real-time latency?

Of course it can. There's some overhead with TCP, but nothing that prevents you from using it in a real time scenario. The overhead with TCP is minimal.

UDP is traditionally used for these sorts of scenarios, as reliability isn't required, but that doesn't mean TCP can't be used almost as performantly.

RTMP

RTMP is a dead protocol for Flash. No browsers support it. Other clients only support it for legacy reasons. You shouldn't use it for anything new going forward.

Only that the famous mobile live-streaming app Periscope is using RTMP.

Well, that's not a reason to do much of anything.

  1. Which protocol delivers better results regarding end-to-end latency, session start-up time?

WebRTC

  1. Which one consumes more hardware resources?

That's not the right question to ask. Your overhead in almost any other parts of the application is going to be far more than the transport overhead of the protocol used for distribution.

The real list of things you need to think about:

  • Client compatibility. What sort of clients must you support?
  • Do you really need low latency everywhere? Do you understand the tradeoffs you're making with that demand? Are you willing to destroy any sense of video quality and reliability for all your users if only a handful of them are going to be interactive?
  • What's your budget? Off-the-shelf solutions for distribution are much cheaper. If you can push off your stream to YouTube for non-interactive users, you can save yourself a ton of money. If you can't use existing infrastructure, be prepared to spend mountains of cash.
  • What are your actual latency requirements? Are you prepared to reduce the number of people that can use your application when these latency requirements cannot be met on crappier networks and mobile devices?
  • What are your quality requirements?
  • Where will you transcode video to a variety of bitrates?
  • Do your viewers need adaptive bitrate viewing?
  • Do you need to push streams to other platforms simultaneously?
  • Do you need to record the streaming for on-demand watching or going back in time?

You might also find my post here helpful: https://stackoverflow.com/a/37475943/362536

In short, check your assumptions. Understand the tradeoffs. Make decisions based on real information, not sweeping generalizations.