refactor(web): add runtime audio encoder capability negotiation for mp4 exports
Introduce a dedicated utility that probes browser support for AAC/WebCodecs audio settings instead of assuming a single hardcoded configuration (`mp4a.40.2`, 192 kbps, stereo, 44.1 kHz). This file should centralize support detection and fallback selection so ChromeOS/Chrome variants that reject the current config can still export with audio. Affected files: audio-codec-support.ts Signed-off-by: ChinhLee <76194645+chinhkrb113@users.noreply.github.com>
This commit is contained in:
parent
3516bd69f4
commit
0314087e21
|
|
@ -0,0 +1,45 @@
|
||||||
|
const CANDIDATE_CONFIGS: AudioEncoderConfig[] = [
|
||||||
|
{
|
||||||
|
codec: "mp4a.40.2",
|
||||||
|
sampleRate: 44100,
|
||||||
|
numberOfChannels: 2,
|
||||||
|
bitrate: 192000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
codec: "mp4a.40.2",
|
||||||
|
sampleRate: 44100,
|
||||||
|
numberOfChannels: 2,
|
||||||
|
bitrate: 128000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
codec: "mp4a.40.2",
|
||||||
|
sampleRate: 44100,
|
||||||
|
numberOfChannels: 1,
|
||||||
|
bitrate: 128000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
codec: "mp4a.40.2",
|
||||||
|
sampleRate: 48000,
|
||||||
|
numberOfChannels: 2,
|
||||||
|
bitrate: 128000,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export async function resolveSupportedMp4AudioConfig(): Promise<AudioEncoderConfig | null> {
|
||||||
|
if (typeof AudioEncoder === "undefined") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const config of CANDIDATE_CONFIGS) {
|
||||||
|
try {
|
||||||
|
const support = await AudioEncoder.isConfigSupported(config);
|
||||||
|
if (support.supported) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue