I want to know exactly which strings I can pass as codec to VideoEncoder.isConfigSupported({ codec, width, height }) but so far I have not found a definite answer:
- The TS declaration file only precises that it must be a string (I wish I could have found a union of string constants there ^^)
- This webcodec article from google only precises that
vp8is a valid codec string - The specs are a rabbit hole that I have trouble navigating
- They describe what a codec string should do but don't include an extensive list
- They precise that a codec string must match either
av01.*,avc1.*,vp8, orvp09.*. From there, there are some links to find more, but I couldn't find how to navigate them. For example, I wanted to know which codecs start withav01., so I went to its registration page that links there that link there, there, and there. The two first links don't say anything about fully qualified codec strings, and the last link links to the web codecs specs I started from originally :/
- This MDN page about the codec in mime types is quite complete and explains the rules to create codec strings, but lot of what I've tried with didn't seem to work
Since, at the moment, only chromium-based browsers support this, I decided to lookup the chromium source code and I found places where more codec strings are listed:
- Tests from the webcodecs directory are apparently run via
TEST.runthat is not found triggered from the JS layer but rather from there, in this python file, where some more codec strings are mentionned just above:avc1.42001E,vp8,vp09.00.10.08 - Some codec strings seem to be mentionned here, along with other things:
video,h264,vp8,hevc,vp9,audio,aac,opus - This test file list a bunch of codecs to be used with canPlayType (not part of web codecs, but related)
All of this is quite frustrating because I have quite a big list of codecs that can sometimes be passed to web codecs, but I am not certain that this is the complete list of it. Where else should I look?
const maybeCodecs = ["aac","ac-3","audio","avc1","avc1, mp4a.40","avc1, mp4a.40.02","avc1, mp4a.40.2","avc1.42001E","avc1.42101E","avc1.42701E","avc1.42E01E","avc1.42E01E, mp4a.40","avc1.42E01E, mp4a.40.02","avc1.42E01E, mp4a.40.2","avc1.42F01E","avc3","avc3, mp4a.40","avc3, mp4a.40.02","avc3", "mp4a.40.2","avc3.42801E","avc3.42C01E","avc3.42E01E","avc3.42E01E, mp4a.40","avc3.42E01E, mp4a.40.05","avc3.42E01E, mp4a.40.29","avc3.42E01E, mp4a.40.5","ec-3","flac","h264","hev1.1.6.L93.B0","hev1.1.6.L93.B0,mp4a.40.5","hevc","hvc1.1.6.L93.B0","hvc1.1.6.L93.B0,mp4a.40.5","mp4a.40","mp4a.40.02","mp4a.40.2","mp4a.66","mp4a.67","mp4a.68","mp4a.69","mp4a.6B","mp4a.A5","mp4a.A6","mp4a.a5","mp4a.a6","opus","theora","video","vp09.00.10.08","vp8","vp9"];
(async () => {
if (typeof VideoEncoder === "undefined") return console.log('web codecs is not supported');
const supportedCodecs = [];
const unsupportedCodecs = [];
const codecsThatTriggerError = [];
for (const codec of maybeCodecs) {
try {
const { supported } = await VideoEncoder.isConfigSupported({ codec, width: 256, height: 256 });
if (supported) supportedCodecs.push(codec);
else unsupportedCodecs.push(codec);
} catch(e) {
codecsThatTriggerError.push(codec);
}
}
console.log({ supportedCodecs, unsupportedCodecs, codecsThatTriggerError });
})()