Use decoder information for resampler sample rate, fix Opus sample rate to 48 kHz everywhere

This commit is contained in:
Vanilagy
2025-09-10 23:03:20 +02:00
parent f314f04037
commit 6f06631355
12 changed files with 52 additions and 40 deletions
+2
View File
@@ -18,6 +18,7 @@ import {
extractAudioCodecString,
extractVideoCodecString,
MediaCodec,
OPUS_SAMPLE_RATE,
VideoCodec,
} from '../codec';
import { Demuxer } from '../demuxer';
@@ -988,6 +989,7 @@ export class MatroskaDemuxer extends Demuxer {
} else if (codecIdWithoutSuffix === CODEC_STRING_MAP.opus) {
this.currentTrack.info.codec = 'opus';
this.currentTrack.info.codecDescription = this.currentTrack.codecPrivate;
this.currentTrack.info.sampleRate = OPUS_SAMPLE_RATE; // Always the same
} else if (codecIdWithoutSuffix === CODEC_STRING_MAP.vorbis) {
this.currentTrack.info.codec = 'vorbis';
this.currentTrack.info.codecDescription = this.currentTrack.codecPrivate;
+2 -2
View File
@@ -47,7 +47,7 @@ import {
parseSubtitleTimestamp,
} from '../subtitles';
import {
OPUS_INTERNAL_SAMPLE_RATE,
OPUS_SAMPLE_RATE,
PCM_AUDIO_CODECS,
PcmAudioCodec,
SubtitleCodec,
@@ -293,7 +293,7 @@ export class MatroskaMuxer extends Muxer {
const header = parseOpusIdentificationHeader(bytes);
// Use the preSkip value from the header
seekPreRollNs = Math.round(1e9 * (header.preSkip / OPUS_INTERNAL_SAMPLE_RATE));
seekPreRollNs = Math.round(1e9 * (header.preSkip / OPUS_SAMPLE_RATE));
}
}