[whatwg] media elements: Relative seeking
eric.carlson at apple.com
Mon Dec 1 20:51:39 PST 2008
On Dec 1, 2008, at 6:10 PM, Chris Double wrote:
> The only accurate value I can provide with Ogg is the exact
> duration if the http server supports byte range requests, or some
> other out of band duration metadata (X-Content-Duration, etc).
> Without byte range requests, accurate duration is not possible.
While you can seek to the end of an Ogg file to get duration from
the last frame's time stamp, you can't do that with every file type.
For example, an MPEG audio elementary stream (eg. MP3) isn't a file
format, it is just the raw output from a decoder, and there are no
time stamps at all so the only way to get an accurate file duration is
to sum the duration of every sample. It is *possible* to include an
indication of duration in the file , but a player must be
prepared to handle files without any indication as well as files in
which the stored duration(s) are inconsistent with the observed
As I have noted before, an estimated duration based on the
calculated duration of the portion(s) of a file that have been
processed, iteratively refined as more data is seen, works well for
us. You might try it with files on servers that don't support byte
range requests, or on machines where you don't want to incur the cost
of extra network IO.
 VBR files can include a header with the number of MPEG audio
frames in the file. This can be used with the sampling rate to
calculate the duration.
 Some ID3v2 tags include a frame that stores the file duration in
milliseconds (strangely enough, stored as a string).
More information about the whatwg