fix: audio regions on silent video, interleaved >2ch stride, coderabbit config

- Fall back to video container duration when mainBuffer is null but
  audioRegions are present (prevents empty output)
- Use data.numberOfChannels as deinterleave stride instead of capped
  dataChannels (fixes garbled audio for 5.1+ sources)
- Fix .coderabbit.yaml: '*' is not valid regex, use '.*'
This commit is contained in:
webadderall
2026-04-18 20:45:46 +10:00
parent 028fd91ffd
commit ebe2bc5c16
2 changed files with 8 additions and 5 deletions
+1 -1
View File
@@ -2,4 +2,4 @@ reviews:
auto_review:
enabled: true
base_branches:
- "*"
- ".*"
+7 -4
View File
@@ -593,7 +593,7 @@ export class AudioProcessor {
let sourceDurationSec: number;
if (mainBuffer) {
sourceDurationSec = mainBuffer.duration;
} else if (hasExternalSources) {
} else if (hasExternalSources || regionEntries.length > 0) {
sourceDurationSec = await this.getMediaDurationSec(videoUrl);
} else {
sourceDurationSec = primaryBuffer?.duration ?? 0;
@@ -983,20 +983,23 @@ export class AudioProcessor {
);
}
} else if (format) {
// Interleaved format — deinterleave into per-channel arrays
// Interleaved format — deinterleave into per-channel arrays.
// Use data.numberOfChannels as stride (not capped dataChannels)
// since the raw buffer contains all source channels.
const srcChannels = data.numberOfChannels;
const size = data.allocationSize({ planeIndex: 0 });
const bytes = new ArrayBuffer(size);
data.copyTo(bytes, { planeIndex: 0 });
const interleaved = this.rawToFloat32(
bytes,
format,
frames * dataChannels,
frames * srcChannels,
);
for (let ch = 0; ch < dataChannels; ch++) {
const chData = new Float32Array(frames);
for (let i = 0; i < frames; i++) {
chData[i] =
interleaved[i * dataChannels + ch];
interleaved[i * srcChannels + ch];
}
channelChunks[ch].push(chData);
}