mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
refactor: simplify duration calculation by returning muxer directly
This commit is contained in:
1 parent
5129ee5ecc
commit
952924cdd5
1 file changed
+4
-6
@@ -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;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user