Skip to content

Commit

Permalink
show progress
Browse files Browse the repository at this point in the history
  • Loading branch information
mifi committed Apr 25, 2020
1 parent 42e9e0d commit fbcc9d0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit fbcc9d0

Please sign in to comment.