bbc / VideoContext

An experimental HTML5 & WebGL video composition and rendering API.
http://bbc.github.io/VideoContext/
Apache License 2.0
1.33k stars 157 forks source link

Extracting image at given time #163

Closed ghost closed 5 years ago

ghost commented 5 years ago

What is the best way to render a static image of a frame at given time? I tried two approaches:

  1. Seek to the frame I want, play context and pause shortly after. It kind of works, but from my understanding is not an optimal way to do this;

  2. Same as "1", but using a combination of "manualUpdate" option and VideoContext.update method. Then I grab canvas data using toDataURL which currently producing black frame for some reason.

Would appreciate any advice on how to move forward.

PTaylour commented 5 years ago

Good timing on this question: we have a ticket in our current decide on our preferred method of seeking to frame (this is as part of a revamp to our screenshot testing)

I don't have a good answer yet, but we'll be working on it this week.

richski commented 5 years ago

@povidlo227 We've found the first approach accurate enough, providing the playback rate is reduced.

This is how we're currently using it within our draft testing PR (https://github.com/bbc/VideoContext/pull/147):

You can view a simple demo here: https://codesandbox.io/embed/vigorous-kirch-1bmow.

With regards to your second approach, you shouldn't see a black frame. Would you be able to share a CodeSandbox and we can have a look?

richski commented 5 years ago

Closing due to 120 days of inactivity.