From fbcc9d0f1060b20a1f18e52799991e6e998437a1 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Sat, 25 Apr 2020 16:37:41 +0800 Subject: [PATCH] show progress --- index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.js b/index.js index c39d5a9..6363e0e 100644 --- a/index.js +++ b/index.js @@ -243,6 +243,12 @@ module.exports = async (config = {}) => { console.log(`${width}x${height} ${fps}fps`); + const estimatedTotalFrames = fps * clips.reduce((acc, c, i) => { + let newAcc = acc + c.duration; + if (i !== clips.length - 1) newAcc -= c.transition.duration; + return newAcc; + }, 0); + const channels = 4; const { runTransitionOnFrame } = GlTransitions({ width, height, channels }); @@ -330,6 +336,11 @@ module.exports = async (config = {}) => { if (verbose) console.log('Frame', totalFrameCount, 'from', fromClipFrameCount, `(clip ${transitionFromClipId})`, 'to', toClipFrameCount, `(clip ${getTransitionToClipId()})`); + if (!verbose) { + const percentDone = Math.floor(100 * (totalFrameCount / estimatedTotalFrames)); + if (totalFrameCount % 10 === 0) process.stdout.write(`${String(percentDone).padStart(3, ' ')}% `); + } + if (!frameData1 || transitionFrameAt >= transitionNumFramesSafe - 1) { // if (!frameData1 || transitionFrameAt >= transitionNumFramesSafe) { console.log('Done with transition, switching to next clip');