13 Tweets 15 reads Dec 24, 2022
1. How do video live streamings work on YouTube, TikTok live, or Twitch? The technique is called live streaming.
Livestreaming differs from regular streaming because the video content is sent via the internet in real-time, usually with a latency of just a few seconds.
2. The diagram below explains what happens behind the scenes to make this possible.
Step 1: The raw video data is captured by a microphone and camera. The data is sent to the server side.
3. Step 2: The video data is compressed and encoded. For example, the compressing algorithm separates the background and other video elements. After compression, the video is encoded to standards such as H.264.
The size of the video data is much smaller after this step.
4. Step 3: The encoded data is divided into smaller segments, usually seconds in length, so it takes much less time to download or stream.
5. Step 4: The segmented data is sent to the streaming server. The streaming server needs to support different devices and network conditions. This is called ‘Adaptive Bitrate Streaming.’ This means we need to produce multiple files at different bitrates in steps 2 and 3.
6. Step 5: The livestreaming data is pushed to edge servers supported by CDN (Content Delivery Network.) Millions of viewers can watch the video from an edge server nearby. CDN significantly lowers data transmission latency.
7. Step 6: The viewers’ devices decode and decompress the video data and play the video in a video player.
Steps 7 and 8: If the video needs to be stored for replay, the encoded data is sent to a storage server, and viewers can request a replay from it later.
8. Common protocols for live streaming include:
🔹RTMP (Real-Time Messaging Protocol): This was originally developed by Macromedia to transmit data between a Flash player and a server. Now it is used for streaming video data over the internet.
9. Note that video conferencing applications like Skype use RTC protocol for low latency
🔹HLS (HTTP Live Streaming): It requires the H.264 or H.265 encoding. Apple devices accept only HLS format
🔹DASH (Dynamic Adaptive Streaming over HTTP): DASH does not support Apple devices
10. Both HLS and DASH support adaptive bitrate streaming.
Over to you: What are some of the optimizations that can be done in this process? Which type of storage is suitable for video persistence in step 7?
11. I hope you've found this thread helpful.
Follow me @alexxubyte for more.
Like/Retweet the first tweet below if you can:
Enjoy this thread?
You might like our "Algorithms You Should Know Video Series For System Design":
youtube.com
Updated design diagram based on feedback.

Loading suggestions...