w3c / webcodecs

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

Output trimming for future BYOB #176

Open chcunningham opened 3 years ago

chcunningham commented 3 years ago

BYOB is blocked on having read-only buffers, tracked in https://github.com/WICG/reducing-memory-copies/issues/1. This issue adds a consideration for when that is eventually resolved.

The request from audio industry pros is for an ability to say "when you write your output to my buffer, please skip over X bytes and stop writing after Y bytes". The use case is for codecs that are known to produce throw some initial throw-away outputs, like opus and mp3.

padenot commented 3 years ago

and AAC, and Vorbis, for completeness about formats commonly used on the web.

This is similar in spirit to what MSE provides, https://w3c.github.io/media-source/#sourcebuffer-audio-splice-rendering-algorithm, except here it's for saving some CPU and memory traffic, not to implement gapless audio.

chcunningham commented 3 years ago

Triage note: marking 'extension', as doing this for BYOB would involve new arguments to decode() or configure().

Separately, I want to highlight that we are now offering this feature without BYOB as part of the AudioData redesign in https://github.com/w3c/webcodecs/pull/228