我想确切地知道我可以将哪些字符串作为
codec
传递给VideoEncoder.isConfigSupported({ codec, width, height })
,但到目前为止我还没有找到明确的答案:
vp8
是有效的编解码器字符串由于目前只有基于 chromium 的浏览器支持此功能,因此我决定查找 chromium 源代码,并找到了列出更多编解码器字符串的位置:
TEST.run
运行的,它不是从 JS 层触发的,而是从 那里,在这个 python 文件中,其中提到了一些更多的编解码器字符串就在上面:avc1.42001E
、vp8
、vp09.00.10.08
video
、h264
、vp8
、hevc
、vp9
、audio
、aac
、opus
所有这一切都非常令人沮丧,因为我有一个很大的编解码器列表,有时可以传递给网络编解码器,但我不确定这是否是完整的列表。我还应该看哪里?
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 });
})()
为了保持一致性,WebCodecs 编解码器注册表中描述的格式字符串已设计为与 ISOBMFF 中使用的字符串相匹配。根据编解码器的不同,字符串中可能包含相当数量的元数据,因此虽然列表是有限的,但它却非常大。
以AV1为例,ISOBMFF绑定指定格式为
av01.<profile>.<level><tier>.<bitDepth>.<monochrome>.<chromaSubsampling>.
<colorPrimaries>.<transferCharacteristics>.<matrixCoefficients>.<videoFullRangeFlag>
其中大部分字段都是可选的。
一般来说,如果一个编解码字符串能够根据编解码注册中的定义进行解析,那么该编解码字符串就是有效的。