Skip to content

Commit cd01b8e

Browse files
committed
Revert to duration ratio for audio
1 parent af3ccad commit cd01b8e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/createFFmpeg.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,23 @@ module.exports = (_options = {}) => {
5858
readFrames = true;
5959
}
6060
} else if (readFrames && message.startsWith(' Stream')) {
61-
const fps = parseFloat(message.match(/(\d+) fps/)[1]);
62-
frames = duration * fps;
61+
const match = message.match(/(\d+) fps/);
62+
if (match) {
63+
const fps = parseFloat(match[1]);
64+
frames = duration * fps;
65+
} else {
66+
frames = 0;
67+
};
6368
readFrames = false;
6469
} else if (message.startsWith('frame') || message.startsWith('size')) {
6570
const ts = message.split('time=')[1].split(' ')[0];
6671
const t = ts2sec(ts);
6772
const f = parseFloat(message.match(/frame=\s*(\d+)/)[1]);
68-
ratio = Math.min(f / frames, 1);
73+
if (frames) {
74+
ratio = Math.min(f / frames, 1);
75+
} else {
76+
ratio = t / duration;
77+
};
6978
prog({ ratio, time: t });
7079
} else if (message.startsWith('video:')) {
7180
prog({ ratio: 1 });

0 commit comments

Comments
 (0)