Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timing object with frame counter representation #14

Open
Adam-Oudaimah-SCASE opened this issue Dec 15, 2020 · 2 comments
Open

Timing object with frame counter representation #14

Adam-Oudaimah-SCASE opened this issue Dec 15, 2020 · 2 comments

Comments

@Adam-Oudaimah-SCASE
Copy link

Hello,
I am using this equation Math.floor(to.query().position * 20) to get the current frame number from a video.
The problem is that the position is not an integer number so I sometimes get the previous frame.
I know that the position, in this case, represents the currentTime of the video (which is a float number) that why I'm getting this error.
Is there a way to make the position in the TimingObject to represent the frame number?

@ingararntzen
Copy link
Contributor

Hi.

Keep in mind that the Timing Object represents a logical timeline linked to a clock (e.g. performance.now()), whereas the timeline of the video (e.g. frame numbers) is a bit more wiggly in playback. Even if you sync the video to the timing object - the diff will likely be non-zero at any time. So - during playback you should regard your timing object as an approximation of the video offset - or vice versa.

Also

  • there are no integer type in Javascript - numbers are all floats
  • from your equation: are you sure the framerate is 20? 24 or 25 are much more common values

@ingararntzen
Copy link
Contributor

Here's a link with a lot more on this by the way.

w3c/media-and-entertainment#4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants