Getting the length of a ogg track from s3 without downloading the whole file

ogg, python

Solution

Unfortunately there does not appear to be a way to achieve this.

Mozilla's Configuring servers for Ogg media is very instructive. Basically:

- Gecko uses the `X-Content-Duration` header - sent by the web server if it has it. This explains the HTML5 audio streaming example you raised. If missing, then

- Gecko estimates the length based on the sample-rate (in the header) and the size of the file from the `Content-length` HTTP header

The sample rate is stored in the Identification Header - the first header packet. See the specification go to section "4.2 Header decode and decode setup"

Problem

How do I get the play length of an ogg file without downloading the whole file? I know this is possible because both the HTML5 tag and VLC can show the entire play length immediately after loading the URL, without downloading the entire file. Is there a header or something I can read. Maybe even the bitrate, which I can divide by the file size to get an approximate play length?

Original source