ennuicastr / libavjs-webcodecs-polyfill

A polyfill for the WebCodecs API. No, really.
78 stars 8 forks source link

Why does the polyfill manually check for codec compatibility? #3

Closed stevenwaterman closed 2 years ago

stevenwaterman commented 2 years ago

See here: https://github.com/ennuicastr/libavjs-webcodecs-polyfill/blob/7f8a03411f1fefe26a61a87895f3c1d1d5c6cd24/src/audio-decoder.ts#L87

This check prevents decoding even if the version of LibAV.js would have supported it. What am I missing here, why can you not just try and load the decoder from LibAV.js and then know it's incompatible if LibAV returns an error?

Yahweasel commented 2 years ago

Basically, I didn't want to start interpreting libav.js's codec names (which is to say, FFmpeg's codec names) as if they were the codec names defined by the spec. Of course, with #2 handled correctly, that might be irrelevant, but I don't want to expose that detail.

Ultimately, though, while for decoding it would be friendlier to just try and see rather than flatly rejecting it, on the other side (encoding) you need to adjust codec parameters, which often need to be decided in a codec-specific way. So, there's a symmetry to having the same specific list in both places.