w3c / webcodecs

WebCodecs is a flexible web API for encoding and decoding audio and video.
https://w3c.github.io/webcodecs/
Other
1k stars 137 forks source link

How to keep decoder alive in a video editor? #424

Closed breakingsword closed 2 years ago

breakingsword commented 2 years ago

I have a video editor web app want to use webcodec. but when I try , I find chrome will relaim decoders that are inactive. User may pause video and do edit video or sth. when user begin to play, decoder has been relaimed. I want to know how to keep this decoder alive?

sandersdan commented 2 years ago

There is no way to guarantee that a codec is available forever; it could be reclaimed due to resource pressure, the loss of a graphics context, or other reasons. I would recommend that WebCodecs applications implement recovery mechanisms such as seek-to-previous-keyframe to recover from decoder loss. Unlike for <video>, this isn't something that can be hidden because the browser cannot force a WebCodecs application to provide a keyframe.

All that said, the Chrome implementation is currently strict about reclamation, and we are actively working to find the best set of tradeoffs. You can follow https://bugs.chromium.org/p/chromium/issues/detail?id=1277618 to see progress on that effort. You can also pass --disable-features=ReclaimInactiveWebCodecs if that simplifies your development process.

chcunningham commented 2 years ago

In addition to the pressure-based reclamation Dan mentioned, we are exploring whether we can always disable reclamation for foreground windows (looks promising).

breakingsword commented 2 years ago

thanks a lot