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

video.currentTime is not precise enough to indentify a frame #433

Open
mzur opened this issue Mar 21, 2022 · 6 comments
Open

video.currentTime is not precise enough to indentify a frame #433

mzur opened this issue Mar 21, 2022 · 6 comments
Labels

Comments

@mzur
Copy link
Member

mzur commented Mar 21, 2022

Apparently, video.currentTime can be modified/rounded by the browser for security reasons. This means that the value returned by currentTime is not precise enough to identify the video frame. The following observation confirms this issue: If the video is played and paused and then video.currentTime = video.currentTime is set, the displayed video frame is updated most of the time! Try it in this fiddle.

The issue that frame-accurate handling of videos is not really possible in the browser is discussed for a long time. I don't know how we can handle this, yet, but it might become complicated.

@mzur mzur added the bug label Mar 21, 2022
@mzur mzur moved this to High Priority in BIIGLE Roadmap Mar 21, 2022
@mzur
Copy link
Member Author

mzur commented Mar 22, 2022

See this discussion for how a switch to frame numbers instead of times could be accomplished. However, it's probably hard to keep an independent timer to track the video progress synchronized with the video (e.g. if it buffers, is paused, the playback rate changes etc.).

mzur added a commit that referenced this issue Mar 22, 2022
These improvements were discovered while investigating #433.
@mzur
Copy link
Member Author

mzur commented Apr 11, 2022

Also related: w3c/media-and-entertainment#4

mzur added a commit that referenced this issue Apr 11, 2022
The actual workaround is to set video.currentTime = video.currentTime
whenever the video is paused. The other changes attempt to remove the
flickering of the video in these cases (because the video is rendered
blank while seeking). This does not work in all cases yet.

References #433
@mzur
Copy link
Member Author

mzur commented Apr 12, 2022

PR #444 implements a workaround where the video frame is updated whenever the video is paused. The updated frame exactly shows the frame corresponding to currentTime so annotations placed at this time will always resolve back to the correct frame. The downside is that the video jumps one frame forward or backward whenever the video is paused. Considering the very complex alternatives, I can live with that. I'll leave this open since this issue should be fixed eventually (maybe with updated web APIs?) but I'll lower the priority, as it is no longer pressing.

@mzur mzur moved this from High Priority to Medium Priority in BIIGLE Roadmap Apr 12, 2022
@mzur
Copy link
Member Author

mzur commented Jun 30, 2022

Tator implements an elaborate video playback mechanism (see discussion linked above) but I believe it relies on custom video re-encoding (with fixed and known parameters). This could be one thing we could copy to get accurate annotation times. Another tool that seems to be quite sophisticated in this regard is DIVE, which we also could take a look at.

@mzur
Copy link
Member Author

mzur commented Mar 24, 2023

Here is an example how a video could be rendered frame by frame using the Web Codecs API: https://stackoverflow.com/a/32708998/1796523

@mzur
Copy link
Member Author

mzur commented May 13, 2024

Here is a project that renders videos using the WebCodecs API: https://github.com/aegir-assembly/omni-clip
It uses FFMpeg (WASM) to demux the video files. This could be a solution for our support of many different containers/codecs. WHile the whole of FFMpeg is very large, maybe we can only compile a subset of it that is required for demuxing.

Another thing to consider is that with WebCodecs we can only support remote files with CORS enabled (similar to the image annotation tool).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Medium Priority
Development

No branches or pull requests

1 participant