
A short explainer by Tsahi Levent‑Levi distinguishing lossless and lossy codecs and their role in real‑time media (WebRTC/VoIP). He explains codecs as encoders/decoders that convert analog audio/video into bits, gives a worked example for 720p video to show raw data sizes, and argues that lossy codecs are typically used in WebRTC because they achieve much lower bitrates suitable for live conversation while preserving perceptual quality.
Questions this video answers
720p (1280 by 720 pixels).
Around 900,000 pixels.
About 3 bytes per pixel.
Approximately 2.7 million bytes per frame.
Around 83 million bytes per second.
Chapters
What are lossless and lossy codecs and how that fits exactly with WebRTC and what we're doing here. So let's first talk about what codecs are. Codecs are encoders, decoders. There are things that enable us to compress data or media and send it over the network, also store it in files. Now, with codecs, what we're trying to do is to take analog data, what we see and what we hear, and then digitize it to something that we can explain or express in bits, zeros and ones. And that moves us into the digital world. Let's take video, for example. With video, I might say that I want to take my camera feed and then encode it at 720p. 720p is the resolution that we have. The resolution here is 1280 by 720 pixels. That's a lot of pixels, around 900,000 pixels. Take that pixels and then move it into actual data. Each pixel has an RGB information to it, red, green and blue, which is around 3 bytes per pixel. That gets us to 2.7 million bytes that we need to deal with. But we want to do it at 30 FPS, 30 frames per second. So you multiply that 2.7 million by 30 and we're going to around 83 million bytes. And that's a lot of data that we need to pass along the network. So we're not going to just pass it as is. We're going to compress it. And here we come to lossless and lossy. With a lossless compression, what we're trying to do is, is to think about the data that we have as if that is a zip file. What does that mean? It means that I'm going to take the data that I have, compress it, and make sure that I preserve everything. So every byte in that image is going to be the exact byte after I decode it. So I take the data, encode, decode, and if I compare it, I get the exact same copy of that data, a zip file. Lossless compressions are different. What they first do is they say, well, let's see what we perceive as humans. What do we exactly see and what we hear? Any data that I have within that image or video and that audio feed that I'm not going to perceive when I see it or hear it, I'm going to throw away first. So that's the first thing that we do. We're going to focus on what humans perceive. Once we have that, we're going to compress that even further and send that. Last but not least, we're going to also focus on making sure that everything that we're doing here is done live in real time, because we're trying to have a conversation and if the encoding or the decoding takes too long, it is going to be too late for us. Okay, so what we're going to do is to use lossless codecs. Why? Because they compress a lot better the data that we have. We're going to be left with a lower bitrate that goes through the network while we're trying to preserve as much data as needed for us as humans. So we don't really care if everything was sent because we understand what is there. We don't even perceive the difference. Now, the fact that we have lossless godex give us one more advantage and that's this knob that is there. I can look at that data and say, well, I want to preserve more information or less information. I want the bit rate to be lower where I don't care about that information in that specific area of my screen. So I'm going to use less bits for that. I'm going to give less quality for that thing that I have to do. Why? Because that fits my current needs, be it a dynamic purpose, cpu, network memory, what's being displayed on the other thing, other side, or anything else. Okay, so that's been lossless and lossy codecs in WebRTC and with voice over IP in general, what we are going to use is lossy codecs, codecs that throw information. Why? Because they compress a lot better. The compression rate that they give us is better. And then we don't need to deal with 83 million bytes, but something a lot lower at around 700 kilobits per second or 1 megabit per second, which is manageable. Now, if you want to learn more about Bloggme, the things that I do, or about WebRTC, go and check out my website, Blogic me. Thank you.
More from Tsahi

Meta rebuilt AV1 for mobile scale. Should smaller teams follow? | Chats with Arin









