Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 1st June 2009, 11:29   #1  |  Link
Comatose
Registered User
 
Join Date: Dec 2007
Posts: 639
The relationship between --vbv-bufsize and --vbv-maxrate

So, after all this time, I'm not sure exactly what they mean, and how to come up with a proper bufsize.

My goal is to restrict peak bitrate to allow streaming. Does --vbv-maxrate do this? I used to think so, but someone once told me that's not exactly what it does, or that the actual bitrate also depends on the bufsize.

Does --vbv-maxrate 1500 restrict the peak bitrate to 1.5Mbps?
Is bufsize = the amount of bits that should be kept to assure playback?

I'm very confused, so much that I'm not even sure I'm asking the right questions. Halp :<
Comatose is offline   Reply With Quote
Old 1st June 2009, 14:02   #2  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Basically, it works like that: Bufsize specifies the size of the device's buffer. That buffer is filled with a constant data rate. That "input" rate equals the CD/DVD/BD read speed (or the Network bandwidth). Still the video is allowed to have a variable bitrate. So if the bitrate of the video increases over the input bitrate, then the buffer will slowly run out of data. Hence you can have only short bitrate spikes. If the bitrate of the video falls below the input bitrate, then the buffer will slowly run full. Hence you can have only short "low bitrate" periods. VBV takes care of all this! It makes sure that the buffer will never overflow nor underflow, as that would cause playback errors. Maxrate specifies the maximum bitrate that the video can ever have. I think Maxrate is independent from the current buffer filling level, but I may be wrong...



How do you com up with the correct buffer size? Well, the buffer size is defined by the device's hardware. You need to know the correct size of the individual device
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 1st June 2009 at 14:30.
LoRd_MuldeR is offline   Reply With Quote
Old 1st June 2009, 14:43   #3  |  Link
Comatose
Registered User
 
Join Date: Dec 2007
Posts: 639
So, --vbv-bufsize = [available bandwidth]. If I want to limit the bandwidth to allow streaming, the values of bufsize and maxrate should be the same, right?

The reason I think that maxrate has something to do with bufsize is that it seems that even if you specify maxrate, it's ignored unless you specify bufsize.

I still don't understand completely, mainly because you say that "VBV takes care of all this", but don't explain how. Still, for my purposes, this is enough (if I got the streaming bitrate limit idea correct), since for all other purposes, you know which settings you should use because they're laid out in a spec or something. But it would be interesting to know, if you have the patience to explain or can link to some resource
Comatose is offline   Reply With Quote
Old 1st June 2009, 15:30   #4  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by Comatose View Post
So, --vbv-bufsize = [available bandwidth]. If I want to limit the bandwidth to allow streaming, the values of bufsize and maxrate should be the same, right?
Uhm, no.

For example: If you have a low bandwidth, but a big buffer, you can use a video bitrate that is even lower than the available bandwidth, so the buffer will accumulate more and more data. Then after that period of "low bitrate", your video can have a bitrate spike (for a short moment) and use a bitrate much higher than the bandwidth! That's possible because we have enough data in the buffer, right before the spike. Of course we still must make sure that the buffer will never run out of data (underflow) or exceed its capacity (overflow). And that's what VBV does! So the bigger the buffer, the better for VBV, because it can allow stronger video bitrate fluctuations (which results in better quality). Anyway, the maximum bitrate fluctuation (peak bitrate) is still limited by the Maxrate parameter...

Quote:
Originally Posted by Comatose View Post
I still don't understand completely, mainly because you say that "VBV takes care of all this", but don't explain how.
Very basically, VBV keeps track of the buffer filling level. If the buffer is in danger to run out of data, then VBV forces the encoder to lower the bitrate, even if that may cause visible artifacts. This also happens in the other direction: If the buffer is in danger to overflow, VBV forces the encoder to use an even higher bitrate. In reality VBV is more complex, of course...
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 1st June 2009 at 15:43.
LoRd_MuldeR is offline   Reply With Quote
Old 1st June 2009, 15:35   #5  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by Comatose View Post
So, --vbv-bufsize = [available bandwidth]. If I want to limit the bandwidth to allow streaming, the values of bufsize and maxrate should be the same, right?
bufsize / maxrate = number of seconds of wall clock time the decoder has to buffer before it starts playing.

That's it. Plain and simple.
Dark Shikari is offline   Reply With Quote
Old 1st June 2009, 15:50   #6  |  Link
Comatose
Registered User
 
Join Date: Dec 2007
Posts: 639
But what LoRd_MuldeR said intrigued me. Through using the correct settings, could I make it so a user who has only 1.5Mbps of bandwidth can play a video which has large spikes (6-7.5Mbps from 1.5Mbps) (with low bitrate sections inbetween - anime) never has to wait for the video to buffer, as long as the user's bandwidth is constant?
Comatose is offline   Reply With Quote
Old 1st June 2009, 15:55   #7  |  Link
Sharktooth
Mr. Sandman
 
Sharktooth's Avatar
 
Join Date: Sep 2003
Location: Haddonfield, IL
Posts: 11,768
sure. you need a larger buffer that can contain the spikes. it must be big enough to store the highest average bps (1 second samples) of the whole encoding plus a safety margin.
Sharktooth is offline   Reply With Quote
Old 1st June 2009, 16:06   #8  |  Link
Comatose
Registered User
 
Join Date: Dec 2007
Posts: 639
What exactly is the "highest average bps (1 second samples)"? Is that the highest peak?

Is there a way to know this, other than encoding without any VBV restrictions first? Do you know if DGAVCDec respects the bufsize of a stream when measuring the bitrate?
If the peak bitrate of an encode is 7717, is --vbv-bufsize 8000 --vbv-maxrate 8000 correct? Should I specify something else for maxrate? Assuming the available bandwidth is 1.5Mbps (web streaming), that buffer will take 5 and 1/3th seconds to fill, right?

Also, using those settings, during a 8Mbps spike, the video will only play for 1 second before it stops to buffer, right?

In other words, the buffer has to be able to store as much data to accommodate the longest spike?

Last edited by Comatose; 1st June 2009 at 16:20.
Comatose is offline   Reply With Quote
Old 1st June 2009, 16:07   #9  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by Comatose View Post
Through using the correct settings, could I make it so a user who has only 1.5Mbps of bandwidth can play a video which has large spikes (6-7.5Mbps from 1.5Mbps) (with low bitrate sections inbetween - anime) never has to wait for the video to buffer, as long as the user's bandwidth is constant?
Yes. If the buffer is only big enough and had a chance to be filled enough, you can have 6 Mbps spikes, even if the available bandwidth is only 1.5 Mbps. Of course the higher the bitrate spike, the shorter it can be, because the buffer will run out of data faster. And after each spike you need a period of "video bitrate is lower than bandwidth" for the buffer to recover, before the next spike can happen. Last but not least: The bigger the buffer, the longer it will take for the buffer to reach the initial fill level. So when using a very big buffer, then users with a "slow" connection will have to wait a long time until playback begins. Last but not least, for hardware devices you don't need to think about the buffer size much, because the hardware itself restricts the buffer size...

Quote:
Originally Posted by Comatose View Post
Do you know if DGAVCDec respects the bufsize of a stream when measuring the bitrate?
Nope, it doesn't. That's why Neuron2 made his VBV verification tool:

http://forum.doom9.org/showthread.php?t=144409
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 1st June 2009 at 16:16.
LoRd_MuldeR is offline   Reply With Quote
Old 1st June 2009, 16:15   #10  |  Link
Comatose
Registered User
 
Join Date: Dec 2007
Posts: 639
Quote:
Originally Posted by LoRd_MuldeR View Post
Nope, it doesn't. That's why Neuron2 made his VBV verification tool:

http://forum.doom9.org/showthread.php?t=144409
derp. As a teenager, I have zero income :|

Maybe I'll get a job in the summer, but I was planning on using that time to see how I fare with one of the x264 SoC projects >_>
Comatose is offline   Reply With Quote
Old 1st June 2009, 16:22   #11  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by Comatose View Post
derp. As a teenager, I have zero income :|

Maybe I'll get a job in the summer, but I was planning on using that time to see how I fare with one of the x264 SoC projects >_>
I think Elecard StreamEye has a similar functionality. It's a 2000$ tool, but you can have a free trial

http://www.elecard.com/products/prod...reameye-tools/
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 1st June 2009, 16:23   #12  |  Link
Comatose
Registered User
 
Join Date: Dec 2007
Posts: 639
Thanks :P Did you notice I edited post #8? Am I totally off again? :E
Comatose is offline   Reply With Quote
Old 1st June 2009, 16:39   #13  |  Link
G_M_C
Registered User
 
Join Date: Feb 2006
Posts: 1,076
Quote:
Originally Posted by Comatose View Post
So, after all this time, I'm not sure exactly what they mean, and how to come up with a proper bufsize.

My goal is to restrict peak bitrate to allow streaming. Does --vbv-maxrate do this? I used to think so, but someone once told me that's not exactly what it does, or that the actual bitrate also depends on the bufsize.

Does --vbv-maxrate 1500 restrict the peak bitrate to 1.5Mbps?
Is bufsize = the amount of bits that should be kept to assure playback?

I'm very confused, so much that I'm not even sure I'm asking the right questions. Halp :<
Want to know what values to use ?

I've found this site that helps me;
http://handbrake.dynaflashtech.net/c...calculator.cgi

I use a buffer period of 1 second, cause i enc. mainly DIY Bluray's. Dont know the buffering period of streamed video though.

Last edited by G_M_C; 1st June 2009 at 17:12.
G_M_C is offline   Reply With Quote
Old 1st June 2009, 16:47   #14  |  Link
Comatose
Registered User
 
Join Date: Dec 2007
Posts: 639
That seems awesome, thanks.

With an ABR of 1.5Mbps, a 2s long peak, vbv-maxrate=4000 and vbv-bufsize=8000, it says it'll be able to withstand a 8Mbps peak for 2 seconds. But I don't understand why. My understanding is that maxrate limits the peaks, so the peak bitrate will never exceed 4Mbps with --vbv-maxrate 4000. What am I doing wrong?

edit: It seems the ABR value doesn't serve a purpose other than to check abr < maxrate. edit2: And the fps setting doesn't do anything either... how reliable is this tool? :|

Last edited by Comatose; 1st June 2009 at 16:50.
Comatose is offline   Reply With Quote
Old 1st June 2009, 16:52   #15  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by Comatose View Post
That seems awesome, thanks.

With an ABR of 1.5Mbps, a 2s long peak, vbv-maxrate=4000 and vbv-bufsize=8000, it says it'll be able to withstand a 8Mbps peak for 2 seconds. But I don't understand why. My understanding is that maxrate limits the peaks, so the peak bitrate will never exceed 4Mbps with --vbv-maxrate 4000. What am I doing wrong?
If the buffer is completely full and contains 8 megabits of data, 4 megabits of data per second is coming in, and 8 megabits of data per second is going out, the buffer will empty in 2 seconds.
Dark Shikari is offline   Reply With Quote
Old 1st June 2009, 16:54   #16  |  Link
Comatose
Registered User
 
Join Date: Dec 2007
Posts: 639
So the maxrate is not actually the peak bitrate - as in the highest bitrate that can exist in the stream, it's merely the max bitrate that can enter the buffer.

Your previous post makes sense to me now. Anyway, the buffer will fill completely before decoding is first started, right?

Last edited by Comatose; 1st June 2009 at 16:56.
Comatose is offline   Reply With Quote
Old 1st June 2009, 16:55   #17  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by Comatose View Post
So the maxrate is not actually the peak bitrate - as in the highest bitrate the stream can have, it's merely the max bitrate that can enter the buffer. Right?
Correct.
Dark Shikari is offline   Reply With Quote
Old 1st June 2009, 16:58   #18  |  Link
Comatose
Registered User
 
Join Date: Dec 2007
Posts: 639
Awesome, thanks. I finally understand VBV :D

edit: One last question... when x264 encodes with auto for bufsize and maxrate, can DGAVCDec, Bitrate Viewer or tools like them correctly measure the bitrate?
edit2: Actually, I can use the StreamEye trial to check the peak then compare to other tools.

Last edited by Comatose; 1st June 2009 at 17:05.
Comatose is offline   Reply With Quote
Old 1st June 2009, 17:06   #19  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by Comatose View Post
One last question... when x264 encodes with auto for bufsize and maxrate, can DGAVCDec, Bitrate Viewer or tools like them correctly measure the bitrate?
If you don't set the VBV parameters explicitly (I think you must set both), then x264 will not use VBV at all.
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 1st June 2009, 17:08   #20  |  Link
Comatose
Registered User
 
Join Date: Dec 2007
Posts: 639
Really? MeGUI says "(automatic)" on the buffer value, so I figured it does, but it decides on the optimal value. Kinda like B-frame mode where it'll pick between Spatial and Temporal when set to Auto.

Anyway, the goal was to find the peak bitrate so that I can re-encode with the optimal VBV settings. Strangely, neither Bitrate Viewer nor DGAVCDec report the same peak as StreamEye, though DGAVCDec is off by less than 10Kbps while Bitrate Viewer is off by more than 600Kbps.

Last edited by Comatose; 1st June 2009 at 17:12.
Comatose is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:03.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.