This commit is contained in:
ChinhLee 2026-07-17 19:30:45 -05:00 committed by GitHub
commit 2a69f7e870
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 45 additions and 0 deletions

View File

@ -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;
}