whatwg / whatwg/html

Media elements should support a rational time value for seek()

Open
#609 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

topic: media
Dominant language
HTML
Stars
9.4k
Forks
3.2k
Avg merge
3d 9h
Merged PRs (30d)
38

Description

Using floating point time values when seeking is inherently imprecise. Specifically, authors attempting to precisely seek to the beginning of a specific video frame will often find that they have seeked to the end of the previous video frame. This is due to rounding errors when converting from double-width floating point values used by JavaScript to the rational integer values used by media file formats.

Double-width floating point values can accurately represent integers up to 2^52. So a rational integer time value can be represented by two JavaScript numbers so long as those numbers are both smaller than 2^52.

Building off of @foolip's work in issue #553, rational time seeking could be supported by adding an optional timeScale parameter to the SeekOptions, which defaults to 1 if absent.

An author with a 29.97 fps video file could then accurately seek to the 30th frame by issuing:

video.seek(30 * 1001, { mode: "precise", timeScale: 30000 });

Left unspecced for now is how the author would determine the correct time scale for the movie or track. For the current proposal, the time scale could be provided out of band.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading issue #553 and the existing SeekOptions and media seeking specification text. The proposal centers on an optional timeScale for precise seeking, while determining the correct movie or track time scale remains unresolved. Done means the behavior and time-scale handling are specified clearly enough to implement.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
api, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.