Log in

View Full Version : VBR Time Range


UltraTV
2nd November 2011, 00:35
Is it possible to set a time range for VBR? For example, VBR would be an average over a maximum 10 second range.

The reason this is important is that for the various HTTP based streaming solutions (HLS, MSS, HDS), quality levels are advertised based on bitrate. Video files are split in x second increments, so if the client chooses a stream of say 3000kbps, but the first segment it pulls is 6000 kbps due to some action in the scene, this will cause the player to either drop frames or begin to ignore this quality level completely.

One solution is to just use constant bitrate, but for obvious reasons that is not optimal. Another solution is to cap all bitrates to a max of 1.2x average bitrate, which is also not optimal. The best solution would be the ability to dictate a time range during which the VBR tries to hit its average.

Is this possible with x264 currently? Does that sound like a reasonable solution?

nm
2nd November 2011, 01:00
Use VBV: http://mewiki.project357.com/wiki/X264_Encoding_Suggestions#VBV_Encoding

At a bandwidth of 3 Mbps, set vbv-maxrate to ~2500 kbps (3000 kbps - audio bitrate - other traffic) and vbv-buffersize to N * 2500 where N is the number of seconds you expect the player/viewer to buffer the stream before starting playback.

UltraTV
2nd November 2011, 17:36
Thanks for the response.

That's what we currently do, however, that basically means that in order to deal with a variety of client playback scenarios, we have to keep maxrate somewhere below 20% of avg bitrate. It would be nice to have some sort of hybrid where you can say that while a 10 or 20 frames can spike to 6mbps, the average over 240 frames will be 3mbps. Does that make sense?

Asmodian
2nd November 2011, 18:11
Isn't that what VBV does?

If you set vbv-maxrate to 2500 kbps, and vbv-buffersize to 25000 (assuming 24fps content). 10 or 20 frames can do whatever they want while the full 240 frames will say at or under 2500 kbps.

Is that what you meant?

Edit: do you mean a cap for a very short buffer as well? Like one max rate for 20 frames and another (lower) max rate for 240?

UltraTV
2nd November 2011, 18:26
Sort of.

What I mean is that for a movie of arbitrary length (e.g. 1 hour), set the vbr range to 10 seconds. I believe right now VBR hits an average bitrate over the entire length of the movie. The problem is, this allows certain segments of the movie to have extremely high bitrates. Setting vbv-maxrate and bufsize solves that problem, but as long as the vbr is averaged across the entire hour, vbv-maxrate needs to be very close to the average bitrate (generally within 20%), which means there is not much flexibility for the encoder to handle different scene types.

However, if it were possible to set the frame of time over which VBR is calculated (10 seconds for example), then it should be possible to increase the maxrate to something like 50% or 100%. While short sections can still receive the benefit of extra bandwidth, individual segments (generally between 2-10 seconds long) will still be close enough to the advertised bitrate to be safe.

nm
2nd November 2011, 19:07
That's what VBV does.


That's what we currently do, however, that basically means that in order to deal with a variety of client playback scenarios, we have to keep maxrate somewhere below 20% of avg bitrate.

Both vbv-maxrate and average bitrate should be kept below the network bandwidth. In your adaptive streaming scenario, the correct choice is to set both vbv-maxrate and the average bitrate at the same value: around 80 % to 90 % of the nominal bandwidth for each quality level.

For "3000 kbps" quality, I'd try something like --bitrate 2500 --vbv-maxrate 2500 --vbv-bufsize 10000.

Note that when you use a large enough vbv-bufsize, the encoder can, and most likely will use much higher bitrates than vbv-maxrate locally! If you want to allow more bitrate variability, you need to increase the buffer size.

See what this calculator tells you about the peak rates and durations: http://handbrake.dynaflashtech.net/cgi-bin/vbv_calculator.cgi