TCP vs UDP on video stream

后端 未结 13 1870
名媛妹妹
名媛妹妹 2020-12-04 05:38

I just came home from my exam in network-programming, and one of the question they asked us was \"If you are going to stream video, would you use TCP or UDP? Give an

相关标签:
13条回答
  • 2020-12-04 05:50

    It depends. How critical is the content you are streaming? If critical use TCP. This may cause issues in bandwidth, video quality (you might have to use a lower quality to deal with latency), and latency. But if you need the content to guaranteed get there, use it.

    Otherwise UDP should be fine if the stream is not critical and would be preferred because UDP tends to have less overhead.

    0 讨论(0)
  • 2020-12-04 05:50

    While reading the TCP UDP debate I noticed a logical flaw. A TCP packet loss causing a one minute delay that's converted into a one minute buffer cant be correlated to UDP dropping a full minute while experiencing the same loss. A more fair comparison is as follows.

    TCP experiences a packet loss. The video is stopped while TCP resend's packets in an attempt to stream mathematically perfect packets. Video is delayed for one minute and picks up where it left off after missing packet makes its destination. We all wait but we know we wont miss a single pixel.

    UDP experiences a packet loss. For a second during the video stream a corner of the screen gets a little blurry. No one notices and the show goes on without looking for the lost packets.

    Anything that streams gains the most benefits from UDP. The packet loss causing a one minute delay to TCP would not cause a one minute delay to UDP. Considering that most systems use multiple resolution streams making things go blocky when starving for packets, makes even more sense to use UDP.

    UDP FTW when streaming.

    0 讨论(0)
  • 2020-12-04 05:56

    Usually a video stream is somewhat fault tolerant. So if some packages get lost (due to some router along the way being overloaded, for example), then it will still be able to display the content, but with reduced quality.

    If your live stream was using TCP/IP, then it would be forced to wait for those dropped packages before it could continue processing newer data.

    That's doubly bad:

    • old data be re-transmitted (that's probably for a frame that was already displayed and therefore worthless) and
    • new data can't arrive until after old data was re-transmitted

    If your goal is to display as up-to-date information as possible (and for a live-stream you usually want to be up-to-date, even if your frames look a bit worse), then TCP will work against you.

    For a recorded stream the situation is slightly different: you'll probably be buffering a lot more (possibly several minutes!) and would rather have data re-transmitted than have some artifacts due to lost packages. In this case TCP is a good match (this could still be implemented in UDP, of course, but TCP doesn't have as much drawbacks as for the live stream case).

    0 讨论(0)
  • 2020-12-04 05:58

    This is the thing, it is more a matter of content than it is a time issue. The TCP protocol requires that a packet that was not delivered must be check, verified and redelivered. UDP does not use this requirement. So if you sent a file which contains millions of packets using UDP, like a video, if some of the packets are missing upon delivery, they will most likely go unmissed.

    0 讨论(0)
  • 2020-12-04 06:02

    If the bandwidth is far higher than the bitrate, I would recommend TCP for unicast live video streaming.

    Case 1: Consecutive packets are lost for a duration of several seconds. => live video will stop on the client side whatever the transport layer is (TCP or UDP). When the network recovers: - if TCP is used, client video player can choose to restart the stream at the first packet lost (timeshift) OR to drop all late packets and to restart the video stream with no timeshift. - if UDP is used, there is no choice on the client side, video restart live without any timeshift. => TCP equal or better.

    Case 2: some packets are randomly and often lost on the network. - if TCP is used, these packets will be immediately retransmitted and with a correct jitter buffer, there will be no impact on the video stream quality/latency. - if UDP is used, video quality will be poor. => TCP much better

    0 讨论(0)
  • 2020-12-04 06:03

    I recommend you to look at new p2p live protocol Bittorent Live.

    As for streaming it's better to use UDP, first because it lowers the load on servers, but mostly because you can send packets with multicast, it's simpler than sending it to each connected client.

    0 讨论(0)
提交回复
热议问题