Recently, I was given opportunity to explore about video transcoding. There is a lot of things that I learned while doing it. *If you prefer to read in Indonesian check it here.
image courtesy of pexels
In Video Transcoding, we will face a lot of things and problem. Several problem that I have to face are video quality and video size. Why? because I?m exploring video transcoding with the purpose of to do some livestreaming. And when we transcode a video to a new output, we don?t want regression in quality or video with too big file size, then one thing that I learn is bitrate.
What is bitrate? Bitrate, as the name implies, describes the rate at which bits are transferred from one location to another. In other words, it measures how much data is transmitted in a given amount of time. TechTerms
The explanation given by TechTerms there, in this context (video transcoding), we can say that the bigger the bitrate is, the more data can be transmitted, and the more data then logically the bigger the file size is. Then if size is the problem, why don?t we just make the bitrate lower? Because bitrate directly effect the video quality. That?s why bitrate is very important in video transcoding, because we have to choose what the best bitrate we can afford in our video transcoding.
There are CBR, VBR, CVBR in this story title. Let me explain what these terms are all about.
CBR stands for Constant Bitrate. It means that when a video is transcoded with a constant bitrate, e.g 2000 kbps. It means that every part of the video should have the same bitrate which is 2000 kbps.
VBR stands for Variable Bitrate. If we use CBR, our transcoded video will have constant bitrate, VBR will result in video with variable bitrate, it can go higher or lower depending on the situation.
Why there are CBR, VBR? What?s the difference? What is CVBR then? So the main difference between CBR and VBR is the difference of bitrate in the transcoded video, whether it is constant or varying. When we transcode a 60 seconds video with 2000 kbps as the bitrate and we use CBR to do it, it will result in video with approximately 1.5 MB in size, How do you come up with that? You can easily search the formula or go to here. What?s the problem then? Because a video can have a lot of scenes in it, it?s very possible in a complex scene that needs more than 2000 kbps bitrate to show all the detail in good quality, it will be limited by our bitrate setting. The quality can be pixellated or have some transient issues, which means the quality will be worse than the input. Whereas in simple scene, because our bitrate setting, it can make our file size bigger than it needed, because of the unused bitrate.
Why don?t we just use VBR? Generally, VBR usage will result in better quality video. When we use VBR in our transcoding, in simple scene, it will decrease the bitrate. Vice versa, in complex scene, it will increase the bitrate. There is no problem then if we simply use VBR, right? Yes, but in some case there is a problem.
I explained that I?m exploring video transcoding with purpose of doing some livestreaming. Similar to livestreaming in Youtube or Twitch, they need to do some live transcoding, which is transcode input from user/streamer to output which is livestream video which will be consumed by the audience. Majority of video streaming in the internet, enable users to consume video in segments, not the whole video so users don?t need to download the entire video before they can start to watch the video. If we use VBR, of course, the video quality will be fine, but one of VBR properties which can make the bitrate goes high can also become a problem in livestreaming scenario. Not everyone has the same internet quality or bandwidth, that makes us maybe want to limit the maximal size of each segment produced by our transcoding process. That?s why there is CVBR.
CVBR stands for Constrained Variable Bitrate, What?s the difference with VBR? You can guess that there is constraint, maybe VBR with constraint? And that?s basically what it is, which is VBR where we limit/constrain the bitrate. Video which we transcode with CVBR will have some varying bitrate but we can set the bitrate. For example, the maximal bitrate is 3000 kbps. So, if we do that, we will have a video with varying bitrate, when the scene is simple, it can simply decrease the bitrate, and if the scene is complex it can increase the bitrate. But there is a difference there, if this complex scene in reality needs 4000 kbps to show the video in good quality, in VBR it will simply do that, but in CVBR, since we set the max bitrate to be 3000 kbps, it will only increase the bitrate to 3000 kbps. It makes us able to predict the maximal file size of each segment in our livestreaming since we can limit the max bitrate, so the audience can watch the stream without buffering, although there is a possibility of regression of quality because the bitrate is not enough to display the video in good quality.
From my exploration, these things make me confused as I began, and my reading and experiment result in this explanation which I wrote into this story. Thanks and hopefully, this story can help you in anyways.