Fix encodability checks throwing due to unsupported config feature set; now counts as not supported (fixes #456)

This commit is contained in:
Vanilagy
2026-08-06 11:07:15 +02:00
parent ce10bb774a
commit 4e4e6eed0c
2 changed files with 32 additions and 10 deletions
+10
View File
@@ -1117,10 +1117,15 @@ export const canEncodeVideo = async (
} }
for (const { config, quantizer } of candidates) { for (const { config, quantizer } of candidates) {
try {
const support = await VideoEncoder.isConfigSupported(config); const support = await VideoEncoder.isConfigSupported(config);
if (!support.supported) { if (!support.supported) {
continue; continue;
} }
} catch {
// Can type-error when unknown config features are used
continue;
}
if (!isFirefox()) { if (!isFirefox()) {
return true; return true;
@@ -1245,8 +1250,13 @@ export const canEncodeAudio = async (
return false; return false;
} }
try {
const support = await AudioEncoder.isConfigSupported(encoderConfig); const support = await AudioEncoder.isConfigSupported(encoderConfig);
return support.supported === true; return support.supported === true;
} catch {
// Can type-error when unknown config features are used
return false;
}
})(); })();
canEncodeAudioMemo.set(key, promise); canEncodeAudioMemo.set(key, promise);
+13 -1
View File
@@ -705,11 +705,15 @@ class VideoEncoderWrapper {
); );
} }
try {
const support = await VideoEncoder.isConfigSupported(candidateConfig); const support = await VideoEncoder.isConfigSupported(candidateConfig);
if (support.supported) { if (support.supported) {
selected = candidate; selected = candidate;
break; break;
} }
} catch {
// Not supported
}
} }
if (!selected) { if (!selected) {
@@ -2209,8 +2213,16 @@ class AudioEncoderWrapper {
throw new Error('AudioEncoder is not supported by this browser.'); throw new Error('AudioEncoder is not supported by this browser.');
} }
let supported: boolean;
try {
const support = await AudioEncoder.isConfigSupported(encoderConfig); const support = await AudioEncoder.isConfigSupported(encoderConfig);
if (!support.supported) { supported = support.supported ?? false;
} catch {
supported = false;
}
if (!supported) {
throw new Error( throw new Error(
`This specific encoder configuration (${encoderConfig.codec}, ${encoderConfig.bitrate} bps,` `This specific encoder configuration (${encoderConfig.codec}, ${encoderConfig.bitrate} bps,`
+ ` ${encoderConfig.numberOfChannels} channels, ${encoderConfig.sampleRate} Hz) is not` + ` ${encoderConfig.numberOfChannels} channels, ${encoderConfig.sampleRate} Hz) is not`