w3c / webcodecs

WebCodecs is a flexible web API for encoding and decoding audio and video.

Home Page:https://w3c.github.io/webcodecs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Probably a silly question: can this encode irregularly spaced frames?

o0101 opened this issue · comments

commented

I'm sorry I'm not sure how to describe this simply, so I'll just relate the use case:

Chrome DevTools Protocols has a Page.startScreencast method. While the reality may be complex, consider that it simply generates frames on any redraw of the rendered page. For instance, redraws and frames in response to a person interacting with the page.

These frames may be emitted at irregular intervals. Maybe there's 5 seconds of "silence", then a flurry of frames. And so on.

Can this sort of imagery be converted into accurate and efficiently compressed video stream at all? And, can webcodecs encode this?

Again, I'm sorry to ask as I'm sure this is already spelled out somewhere. I'm afraid I'm no expert did not find a certain answer here or elsewhere!

Variable frame rate is in some sense the default, but there are some extra considerations:

  • You can't accurately set the duration field of a frame unless you wait for the next one first. Durations are not necessary but can affect the next point.
  • Bitrate control does not work well, you'll probably want to use QP.
  • You'll want a container that also supports variable frame rate, which basically means 'not raw'. It'll be harder than usual to pick a timebase for MP4.
  • Some user interactions with low frame rate video playback are not ideal, depending on the player implementation (unrelated to WebCodecs). You may want to set a minimum frame rate and feed the same frame repeatedly (with new timestamps) if you see issues.