Closed Bug 614775 Opened 14 years ago Closed 14 years ago

Estimate video length (in seconds) based on Content-Length (in bytes) and bitrate

Categories

(Core :: Audio/Video, defect)

Other
Linux
defect
Not set
major

Tracking

()

RESOLVED INVALID

People

(Reporter: BenB, Unassigned)

References

Details

Ogg, including Theora in ogg container (ogv), is a streaming format and doesn't tell the length of the video, in seconds. However, we need the video length for a) the progress meter in the bottom and b) for seeking (= allowing user to jump around, selecting different parts of the video). Not having that is a serious limitation for users.

Of course the X-Content-Duration header would be ideal, but we can't expect all servers to have that.

For non-live streams, we can estimate the video length based on the length of the file in bytes (Content-Length HTTP header) and the bitrate of the first, known part of the video. The same algo will also allow to seek, by estimating the byte position of a video position (in seconds).

mplayer does it like that for HTTP streams (e.g. MPEG2 TS and MPEG4 TS, which are also streaming formats - I haven't tried ogg via http in mplayer), and it works quite well.

This bug may be invalid, we probably already do it (it's obvious), but I can't see it working.
The only advantage I can see this having is it would give a duration for videos on servers that don't support byte ranges. These aren't very common. It still wouldn't allow seeking since the server doesn't support byte ranges.

In the case of a Ogv resource that does allow seeking, it's easier and more accurate to do the seek to the end to find the value.
> it's easier and more accurate to do the seek to the end to find the value.

For some reason, that apparently doesn't work for me, though.
Yes, the server above (which is not mine) sends "Accept-Ranges: bytes".
From bug 614760 comment 12:
> It's not my server, I just use the testcase from bug
> 614695:<http://smormedia.gavagai.nl/2010/10/TiranaTraffic.ogv>.
> wget says "Accept-Ranges: bytes" is in the server response, yes.

If I change the about:config setting network.http.accept-encoding to the empty string then that video play fine, shows a duration and can seek.
You're right, on all accounts.
I used Testcase 1 from bug 614760.
It didn't work without patch and not with my patch 1 in bug 614760.
It does work with patch 2b (based on your comment) in bug 614760 and with network.http.accept-encoding = "".

Using Content-Length would save us one HTTP request, but would be less accurate. So, let's forget this.
INVALID
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.