Re: Buffered bytes for media elements

On Oct 17, 2008, at 6:54 AM, Jim Jewett wrote:

>> How can knowing the number of *bytes*
>> available allow you to make a good decision about when sufficient  
>> data
>> is available to begin playback when you don't know the bit-rate of  
>> the
>> media file? In other words, how can you know when it is safe to begin
>> playback when you have N bytes available but you don't know if  
>> playing
>> the media file requires 10 K per second or 10 Megs per second?
>
> I'm speculating here, but
>
> (a)
> Many videos are really a sort of slideshow, without motion.  Even
> those with motion often begin with a credits screen that stays static
> for several seconds.
>
> If you want to have x seconds buffered, then you want to buffer x
> seconds of changing video, not x seconds of the highly-compressible
> intro.
>
> On a per-video basis, you could just say "well, we need 3x bytes on
> this one because of the way it starts."  But if you want to use more
> generic scripts, you need some way of telling whether or not those x
> seconds were data-heavy.  Specifying bytes rather than seconds is a
> fairly good proxy.
>
   This is exactly the situation the "readyState" property is supposed  
to handle, "HAVE_ENOUGH_DATA" state means the playback can begin  
without having to pause to re-buffer. The media engine is really the  
only thing in a position to make an accurate decision about this,  
because the answer depends on the overall data rate of the media file  
(including local highs and lows) and the amount of bandwidth available  
between the client machine and the server with the media file.

> (b)
> If you're thinking of switching to a higher or lower resolution, the
> bandwidth limits are normally expressed in (something equivalent to)
> bytes/second.  You could do the equivalent with seconds, plus a timer,
> plus knowledge of the specific video, but ... it may be simpler to
> track bytes.
>
   Even if you want to make these calculations yourself, just knowing  
the number of bytes buffered doesn't give you enough information  
because you also need to know the encoding rate of the media file.

eric


>

Received on Friday, 17 October 2008 18:27:10 UTC