WICG / video-rvfc

video.requestVideoFrameCallback() incubation
https://wicg.github.io/video-rvfc/
Other
54 stars 19 forks source link

The 'presentedFrames' field does adjust to seeking in a video #82

Closed jpdiogoNOVA closed 2 years ago

jpdiogoNOVA commented 2 years ago

Hello everyone!

I have a piece of code that works as something like this:

let arg1 = (...);
const callFrameByFrame= (now, metadata) => {
    myFunction(arg1, metadata.presentedFrames);
    video.requestVideoFrameCallback(callFrameByFrame);
};
video.requestVideoFrameCallback(callFrameByFrame);

The function myFunction works fine throughout the video being played even if this piece of code only begins executing X seconds after the video has begun (ex: 5 seconds after the video has started). However, this video element is associated with a slider where it is possible to move to a specific time (targetTime) in a video by doing something like:

video.currentTime = targetTime;

The problem is after doing this, myFunction no longer receives the metadata.presentedFrames equal to the current frame in that video's current second which makes it run out of sync with the video when seeking.

Has anyone found a way to work around this?

Kinds regards, Joao Diogo, Nova University

tguilbert-google commented 2 years ago

The fact that presentedFrames does not update after seeks is by design. presendtedFrames corresponds to the number of frames sent to the compositor, regardless of where those frames came from in the video/stream.

I do not know if there is a way to work around this, and depends on how presentedFrames is being used by myFunction. Depending on your needs, you could use WebCodecs to extract all frames manually.

jpdiogoNOVA commented 2 years ago

Thank you!

That's the same conclusion we arrived at.

Kinds regards, Joao Diogo, Nova University

tguilbert-google commented 2 years ago

Sounds good!