CBR and VBR

blink3times wrote on 11/19/2008, 4:36 AM
This is sort of a continuation from another thread, but I find it quite interesting an felt it deserved its own thread.

People tend to say that a 2 pass vbr setting would yield a better quality than a comparable cbr setting. This may or may not be true... but there are a few things that just aren't making much sense.

If we use HDV as an example which we all know is recorded at 25Mbps and we also know that you can't get a better quality on a 25M recording by rendering it at say... 30M, then what is the sense in using the default setting in the Blu Ray template (20M/25M/30M)?

If the bitrate average is set at the original recording's maximum bit rate (25M) then the VBR technique has no room to maneuver at the high end and even if it does render much over 25M then it's just wasted bits because you CAN'T get a better quality than was originally recorded. Logically speaking, the only thing a VBR setting would do in this case is become a 'space saver' by removing bits where they are not needed. In other words if the average setting is set at the original recording's maximum then doesn't the high setting become redundant and useless? Conversely, if I use a CBR setting of 28M (the extra few thousand bits over 25M to take care of any spikes above 25 that MAY exist) I may be wasting space by delivering more bits to a particular scene that doesn't need.... But I'm NOT going to get a better or worse quality because I'm already OVER hdv's max recording level anyway.

To me, it would make more sense when using VBR, to set the average bit rate LOWER than the hdv max (25M) so that the 2 pass vbr system not only has room to manuver at the low end... but also at the high end. If for example we set the low at15M, the average at 20M, and the high at 28M then the VBR system would be able to actually take advantage of adding/subtracting bits in BOTH directions and not just at the low end. But at the same time (in the back of my head) I'm feeling as though I'm cheating myself by setting a LOWER average bitrate!?! Am I ripping myself off by setting a lower average bitrate?

I ran a sample test with a LOWER average bit rate for hdv (at 15M) and this is what I got:
=======================================================
The test strip was indoors with average lighting
VBR was set for 15M average, 30M high, and 10M low (2 pass) and took 4:29 to render
CBR was 15M and took 2:09 to render

My results were as follows:
VBR file size= 235,794,432
CBR file size= 237,525,104

When burned to disk and played back in the PS3:
CBR varied in bit rate between 14.6 and 15.6
VBR varied in bit rate between 9.3 and 28.3

As for quality.... my wife and I couldn't tell the difference between the 2.

The VBR file size is DEFINITELY smaller..... BUT it does however produce the same quality (or at least no difference that I could see)
==========================================================


Any one else's opinion would be gladly appreciated.

Comments

megabit wrote on 11/19/2008, 5:30 AM
FWIW:

I vaguely remember one of the Ulead NLE encoding my MPEG's; when I chose 2-pass VBR, after the first pass I could see the size of the resultant file - after the second pass it was almost 50% smaller, and the quality - the same.

AMD TR 2990WX CPU | MSI X399 CARBON AC | 64GB RAM@XMP2933  | 2x RTX 2080Ti GPU | 4x 3TB WD Black RAID0 media drive | 3x 1TB NVMe RAID0 cache drive | SSD SATA system drive | AX1600i PSU | Decklink 12G Extreme | Samsung UHD reference monitor (calibrated)

Chienworks wrote on 11/19/2008, 5:35 AM
I can think of two things you're overlooking.

1) Whenever compressed material is recompressed the quality is always worse. True, rendering 25Mbps to 30mbps isn't going to look better than the original 25Mbps. However, rendering 25Mbps to 30Mbsp is going to look better than rendering 25Mbps to 25Mbps. Why? Because less is lost going from 25 to 30 than going from 25 to 25.

2) The point of VBR is to allow the [b]maximum[B] bitrate to be used only when necessary, so you should be comparing maximum bitrate rather than average. To do a real comparison you should be comparing a 10Mbps/15Mbps/30Mbps VBR file to a 30Mbps CBR file, not a 15Mbps CBR file. This way you'll know that the CBR file matches the highest bitrate used by the VBR version. The way you're doing it now the CBR file is going to be lower quality than the VBR file, even if you didn't notice the difference. Do this and you'll see that the file size savings of using VBR are huge. The test you did forced the CBR file to be lower quality than the VBR file, since it couldn't go higher than 15Mbps at any time.
blink3times wrote on 11/19/2008, 6:14 AM
Thanks guys... that makes perfect sense.

So then... would it be fair to say that if vbr was used properly it will maintain the same quality (as compared to cbr max-ed out at 28M and not necessarily better) but produce a smaller file?

And should the average setting be LESS than the normal hdv level (within reason) as long as the high setting is at or near the HDV limit? (Say... a setting of 10/22/30).

And if that were true then what would "within reason" be?
farss wrote on 11/19/2008, 6:59 AM
You're looking at the this the wrong way around.

You can do no better quality than CBR at the maximum bitrate that the media supports.

The problem that you then strike is that for say a SD DVD with PCM audio the maximum length of video that you can fit at 8Mb'sec is roughly one hour. If you want to fit say 2 hours onto that DVD and use CBR at around 4Mb/sec you're quite likely forcing the encoder to not make the best possible use of the bit budget. Everything gets encoded at 4Mb/sec. Including fades to black, static titles and still images whereas these could be encoded at a much lower bitrate with no loss of quality and the saving in bits used for video that might benefit from a higher bitrate.

So in this instance a VBR of 2,4,8 means the stills etc get encoded at 2Mb/sec. If the encoder hits an explosion it will briefly spike the bitrate to 8Mb/sec whilst also keeping its eye on the target average of 4 Mb/sec.

More passes means the encoder can do a better job of averaging it all out and optimising it. The Cinecraft encoder can do upto 200 (I think that's the number) of passes which would take quite a while.

Now if you wanted to fit 1hr 15 minutes onto your SD DVD you might need to drop the bitrate down to 6Mb/sec. At that bitrate it's most likely you'll not see any advantage in using VBR.

I'll say again though. The single most important factor in getting a good encode is the quality of the material going into the encoder. If you doubt this what enough videos on Youtube.

Bob.
blink3times wrote on 11/19/2008, 7:54 AM
"So in this instance a VBR of 2,4,8 means the stills etc get encoded at 2Mb/sec. If the encoder hits an explosion it will briefly spike the bitrate to 8Mb/sec whilst also keeping its eye on the target average of 4 Mb/sec."

Yes, I well understand this Bob. It's basically what I said in my original statement in the other thread. In theory vbr works on kind of a "rob from the rich and give to the poor" ideology, taking bits where they are not needed and placing them where they are giving you better overall control and increased efficiency of their distribution. This concept is not at all hard to understand.... never has been.

What I am saying is that if the average bitrate is set at the maximum range of the original video (hdv is 25M so you set the average at 25M) then there really is no room for the encoder to operate at the high end (maybe a few 100K but that's it). What your in essence doing is making the high end setting redundant so the end result is not robbing from the rich and GIVING to the poor (there's no room to give really)... you're simply robbing from the poor, or taking bits away and saving a bit of space in the process

The question is would you not be better served by the vbr encoder by setting an average slightly LOWER than the input video's max bitrate and setting the high end at or just slightly above the video's max bitrate.
Chienworks wrote on 11/19/2008, 9:31 AM
If you put the average and max too close together, you'll really end up with ... CBR. The amount of time in which the encoder gets to drop to lower rates becomes vanishingly small, so there's no sense in doing this.

Choose an average rate that lets you fit the amount of material you have in the amount of space you're willing to use. Set the maximum high enough to handle the few high-action, high-detail scenes. Set the minimum proportionally lower so that the encoder has some 'rich' bits available to steal and give to the 'poor' bits. What values are these then? I can tell you: i dunno. It depends on your material and media.

What happens if you do this and the quality is insufficient or the size too great? You have several choices. You can use a lower average bitrate. You can shorten the material. You can use larger media. You can reduce details (crop out cluttered backgrounds for example, or shorten high action scenes). You can use smoothing or denoising filters so that bits aren't wasted on garbage. You can use better source material that has less noise (Bob's favorite!). You can use a better encoder that knows how to handle these problems more efficiently. You can shrug and say 'oh well'.

You cannot simply say, 'here's a formula that will work for all my videos'.
megabit wrote on 11/19/2008, 9:40 AM
Great post, Chienworks !

AMD TR 2990WX CPU | MSI X399 CARBON AC | 64GB RAM@XMP2933  | 2x RTX 2080Ti GPU | 4x 3TB WD Black RAID0 media drive | 3x 1TB NVMe RAID0 cache drive | SSD SATA system drive | AX1600i PSU | Decklink 12G Extreme | Samsung UHD reference monitor (calibrated)

blink3times wrote on 11/19/2008, 9:56 AM
"If you put the average and max too close together, you'll really end up with ... CBR. The amount of time in which the encoder gets to drop to lower rates becomes vanishingly small, so there's no sense in doing this."

Yes... this is quite true. As an extreme example if I set the low at 25, the average at 25, and the high at 25, then I have in effect used the vbr encoder to create a cbr render. So you really need a wide swath in the settings for the vbr encode to have a serious effect.... which is why i'm confused on the idea of setting the average at the blu ray default template for hdv (the default is 25M average).

So if space is not an issue and you have for example a one hour HDV video going to a 25 gig disk, what exactly are you accomplishing with a 2 pass vbr render that you can't get from a 28M cbr render..... other than a longer render time?
johnmeyer wrote on 11/19/2008, 10:39 AM
I had a power outage as I was typing almost exactly the same thing that Kelly (Chienworks) posted.

So if space is not an issue and you have for example a one hour HDV video going to a 25 gig disk, what exactly are you accomplishing with a 2 pass vbr render that you can't get from a 28M cbr render..... other than a longer render time?

Nothing. VBR, whether one-pass, two-pass, three-pass (some encoders offer "n"-pass) is only useful for low bitrates where fewer bits are used for low-motion areas and more bits are used to encode fast motion. Single pass VBR has no idea that the second half of your video is a static shot of the Empire State Building (Andy Warhol) which requires virtually zero bits to encode, so since it only looks at a few frames at a time and makes allocations based on those local frames, it doesn't do a very good job of allocating the bits. A multi-pass encoder can look at the entire video and encode that static shot at near zero, and use all those bits for the faster motion.

The important thing to understand is that the [b]ONLY[b] thing which determines file size -- and therefore how many minutes will fit on a disc -- is the bitrate. Resolution doesn't matter. If you encode 320x240 or 1920x1080 at 25 mbs, they will both end up at exactly the same file size. However, lower resolution requires fewer bits per second in order to achieve the same temporal quality (e.g., "mosquito" noise around fast-moving objects).

The Vegas VBR one pass encoder is extremely inaccurate, however, in its bit allocation so you often do not get very accurate size results. In theory, if you do an encode at 6,000,000 CBR and then do the same project encoded at an average of 6,000,000 bps, the two files should be the same size. With Vegas single-pass, this doesn't happen because the code is sloppy. However, with Vegas two-pass, the two encodes usually agree to within a fraction of a percent, as they should.

So, while I haven't yet done any BD discs, I have done thousands of DVDs and my rule of thumb (which you can feel free to modify for your own tastes an needs) is that I always use VBR because even the single-pass VBR provides some small improvements over CBR, and I don't think there is any encoding time slow-down. However 2-pass VBR takes twice as long, so I only use that if the average bitrate needs to be less than 6,000,000 bps (which BTW is the Vegas default). For 24p material, you can go quite a bit lower because progressive encodes much more smoothly than interlaced (which is why I always do IVTC on any film captured from TV prior to encoding). The difference between encoding movies to which pulldown has been permanently added and movies which are at their pristine 24p original cadence is night and day. Not subtle at all.

I learned a lot about all this because I started encoding VCD and then SVCD and finally XVCD. At those low bitrates, you had to know every trick in the book in order to get something that was going to look good. I still watch the SVCDs I created way back then and they look darn nears as good as my modern DVD encodes. Of all the things I learned -- special encoding matrices, changing coefficients, noise reduction, changing motion search precision (this was TMPGEnc) -- the IVTC is the thing that made by far the most difference.

So, in summary, as Kelly says, if you set VBR average to the same as the maximum, you have just created CBR, so there is no point to choosing VBR. And, if there isn't a pretty large spread, you won't get much bang for the buck. And finally, since VBR is really provided for situations where you want to cram a LOT of material onto a given disc size, you won't get any benefit when you want to get the maximum quality.
Chienworks wrote on 11/19/2008, 10:50 AM
I just thought of a way to explain max vs average that may help some folks make sense of it ...

Think of the maximum bitrate as the quality level you're trying to achieve.
Think of the average bitrate as the quality level you're willing to tolerate to get the file size you want.
Think of the minimum bitrate as the 'elbow room' you're willing to give the encoder to work with.

The encoder will shoot for the maximum bitrate when it needs too, for high action or high detail.

The encoder will use the average bitrate whenever it can try produce the same quality as maximum, but with fewer bits because there is less action or detail to encode.

And of course the minimum bitrate allows the encoder to idle along during passages where nothing changes and save these bits to use for the high action high detail scenes.

This mode of thinking equates the maximum the CBR rate rather than equating the average to the CBR rate. I think much more useful way of comparing quality and size savings.
johnmeyer wrote on 11/19/2008, 11:03 AM
Kelly,

I like your analogy, but one thing needs to be added, namely that the ability of a VBR encoder to achieve what you describe depends almost entirely on the nature of what you are encoding. If you are encoding a newscast, where the shots alternate between a studio head shot of the talent reading the news, and shots from the field of people running during a riot, etc., then there is a wide disparity in motion from one scene to the next. VBR will make a big difference here.

On the other hand, if your entire project is hand-held footage taken from the back of a truck in the Serengeti, then the motion will be constant, and VBR will probably make no difference whatsoever.
blink3times wrote on 11/19/2008, 11:14 AM
Yes.
It's a really great way of putting it.

I guess the bottom line is that vbr is a great space saver while maintaining the quality, but your settings have to be wide enough to make the difference.... which is why I've never taken it too seriously. I've never really been in a position where I have had to squeeze every drop of space from a disk. I've always been able to simply run the bitrate up the flag pole to its max in CBR mode and get away with it.... interesting conversation.
Terje wrote on 11/20/2008, 2:07 PM
I guess the bottom line is that vbr is a great space saver while maintaining the quality

This is true, if, and only if, your material supports it. If you go outside with a hand-held camcorder and shoot your kids in daylight, it is unlikely that you will get anything from VBR but quality loss. So, I'd say that t he "rule" should be about as:

1/ If you can find media to fit your stuff on with maximum CBR, use that.
2/ If you can't, try to shortening. Cutting away stuff is always a good idea. It's only kids, nobody wants to watch more than about ten minutes anyway ;-)
3/ If you can't make it fit and there is footage that can benefit from VBR, use multi-pass VBR. How do you know what can benefit? Static stuff. Talking head with camcorder on a tripod and a static background. Outside at night. Large areas of the film with close to uniform color for extended periods of time.

Finding the avg bitrate is easy. Use a calc to find out. Max is easy too. Min is a little harder, but you could try to encode some parts of the time line where you think VBR would reduce bitrate to a CBR low bitrate and use the minimum you find acceptable as min bitrate.

It's magic, try and try and fail and fail and you will figure it out. :-)