Skip to content

Commit

Permalink
Revert to duration ratio for audio
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Aug 24, 2022
1 parent af3ccad commit cd01b8e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/createFFmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,23 @@ module.exports = (_options = {}) => {
readFrames = true;
}
} else if (readFrames && message.startsWith(' Stream')) {
const fps = parseFloat(message.match(/(\d+) fps/)[1]);
frames = duration * fps;
const match = message.match(/(\d+) fps/);
if (match) {
const fps = parseFloat(match[1]);
frames = duration * fps;
} else {
frames = 0;
};
readFrames = false;
} else if (message.startsWith('frame') || message.startsWith('size')) {
const ts = message.split('time=')[1].split(' ')[0];
const t = ts2sec(ts);
const f = parseFloat(message.match(/frame=\s*(\d+)/)[1]);
ratio = Math.min(f / frames, 1);
if (frames) {
ratio = Math.min(f / frames, 1);
} else {
ratio = t / duration;
};
prog({ ratio, time: t });
} else if (message.startsWith('video:')) {
prog({ ratio: 1 });
Expand Down

0 comments on commit cd01b8e

Please sign in to comment.