refactor: simplify duration calculation by returning muxer directly

This commit is contained in:
NoLogicAlan committed 2026-10-17 03:26:48 +03:00
1 parent 5129ee5ecc
commit 952924cdd5
1 file changed
+4 -6
+4 -6
View File
@@ -321,9 +321,8 @@ const StreamPipeline = {
pcmStream.on("data", (chunk) => { pcmBytes += chunk.length; }); pcmStream.on("data", (chunk) => { pcmBytes += chunk.length; });
pcmStream.pipe(encoder).pipe(muxer); pcmStream.pipe(encoder).pipe(muxer);
const wrapper = Object.create(muxer); muxer.getDurationMs = () => Math.round((pcmBytes / (PCM_RATE * PCM_CHANNELS * 2)) * 1000);
wrapper.getDurationMs = () => Math.round((pcmBytes / (PCM_RATE * PCM_CHANNELS * 2)) * 1000); return muxer;
return wrapper;
}, },
/** /**
@@ -437,9 +436,8 @@ const StreamPipeline = {
}); });
oggStream.pipe(demuxer).pipe(muxer); oggStream.pipe(demuxer).pipe(muxer);
await headPromise; await headPromise;
const wrapper = Object.create(muxer); muxer.getDurationMs = () => frameCount * OPUS_FRAME_MS;
wrapper.getDurationMs = () => frameCount * OPUS_FRAME_MS; return muxer;
return wrapper;
}, },
/** /**