rix0r.nl

A man and his machine

A look into prebuffering

The QuickTime playback bar

I’ve been interested for a while in the prebuffering algorithm that QuickTime uses… you know, where it loads a movie clip and automatically starts playing it as soon as the clip can be finished playing without interruptions. I was wondering about the equation they were using for that, especially since a friend told me it was an equation that couldn’t be solved.

So today I tried to drill down and see if I could come up with a solution (and it’s a good opportunity to plug one of my recent applications :) ).

First off, a few definitions:

The input parameters to the equation:

  • Download rate d (in bytes/second)
  • Sample rate s (b/s)
  • Video clip length n (s)

Output of the equation:

  • Prebuffer length b (s)

We pick a time b.

  • At that point, the bytes downloaded so far is
  • That means that there is still left to download:
  • That means we simply have to pick b so that the time needed to download the remaining file size (, or simply ) is smaller than or equal to the time it takes to play the entire clip.

In short:

Well, what are the solutions to that? (Excuse me if I’m being too verbose here)

Which is, come to think of it, not all that surpising: the buffer b has to accomodate for the difference in download and sample rate (s - d), for the entire length of the clip (times n).

So what’s the final solution, should you ever need to implement such a beast? Here it is:

Equation to find the minimum fill level of the autoplay buffer


I hope you’ve enjoyed my deriving and stating the semi-obvious. Have a nice day ;) .

Leave a Reply