mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-02 21:33:52 +02:00
Fix encodability checks throwing due to unsupported config feature set; now counts as not supported (fixes #456)
This commit is contained in:
+14
-4
@@ -1117,8 +1117,13 @@ export const canEncodeVideo = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const { config, quantizer } of candidates) {
|
for (const { config, quantizer } of candidates) {
|
||||||
const support = await VideoEncoder.isConfigSupported(config);
|
try {
|
||||||
if (!support.supported) {
|
const support = await VideoEncoder.isConfigSupported(config);
|
||||||
|
if (!support.supported) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Can type-error when unknown config features are used
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1245,8 +1250,13 @@ export const canEncodeAudio = async (
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const support = await AudioEncoder.isConfigSupported(encoderConfig);
|
try {
|
||||||
return support.supported === true;
|
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);
|
canEncodeAudioMemo.set(key, promise);
|
||||||
|
|
||||||
|
|||||||
+18
-6
@@ -705,10 +705,14 @@ class VideoEncoderWrapper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const support = await VideoEncoder.isConfigSupported(candidateConfig);
|
try {
|
||||||
if (support.supported) {
|
const support = await VideoEncoder.isConfigSupported(candidateConfig);
|
||||||
selected = candidate;
|
if (support.supported) {
|
||||||
break;
|
selected = candidate;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Not supported
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const support = await AudioEncoder.isConfigSupported(encoderConfig);
|
let supported: boolean;
|
||||||
if (!support.supported) {
|
|
||||||
|
try {
|
||||||
|
const support = await AudioEncoder.isConfigSupported(encoderConfig);
|
||||||
|
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`
|
||||||
|
|||||||
Reference in New Issue
Block a user