mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 10:53:50 +02:00
Fix encodability checks throwing due to unsupported config feature set; now counts as not supported (fixes #456)
This commit is contained in:
@@ -1117,10 +1117,15 @@ export const canEncodeVideo = async (
|
||||
}
|
||||
|
||||
for (const { config, quantizer } of candidates) {
|
||||
try {
|
||||
const support = await VideoEncoder.isConfigSupported(config);
|
||||
if (!support.supported) {
|
||||
continue;
|
||||
}
|
||||
} catch {
|
||||
// Can type-error when unknown config features are used
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isFirefox()) {
|
||||
return true;
|
||||
@@ -1245,8 +1250,13 @@ export const canEncodeAudio = async (
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const support = await AudioEncoder.isConfigSupported(encoderConfig);
|
||||
return support.supported === true;
|
||||
} catch {
|
||||
// Can type-error when unknown config features are used
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
canEncodeAudioMemo.set(key, promise);
|
||||
|
||||
|
||||
+13
-1
@@ -705,11 +705,15 @@ class VideoEncoderWrapper {
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const support = await VideoEncoder.isConfigSupported(candidateConfig);
|
||||
if (support.supported) {
|
||||
selected = candidate;
|
||||
break;
|
||||
}
|
||||
} catch {
|
||||
// Not supported
|
||||
}
|
||||
}
|
||||
|
||||
if (!selected) {
|
||||
@@ -2209,8 +2213,16 @@ class AudioEncoderWrapper {
|
||||
throw new Error('AudioEncoder is not supported by this browser.');
|
||||
}
|
||||
|
||||
let supported: boolean;
|
||||
|
||||
try {
|
||||
const support = await AudioEncoder.isConfigSupported(encoderConfig);
|
||||
if (!support.supported) {
|
||||
supported = support.supported ?? false;
|
||||
} catch {
|
||||
supported = false;
|
||||
}
|
||||
|
||||
if (!supported) {
|
||||
throw new Error(
|
||||
`This specific encoder configuration (${encoderConfig.codec}, ${encoderConfig.bitrate} bps,`
|
||||
+ ` ${encoderConfig.numberOfChannels} channels, ${encoderConfig.sampleRate} Hz) is not`
|
||||
|
||||
Reference in New Issue
Block a user