Skip to content

Commit 9b8a5f7

Browse files
authored
Merge pull request #153 from bbudd/parseprogress-fix
Allow progress callback to interpret information
2 parents 163b648 + 59dc367 commit 9b8a5f7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/utils/parseProgress.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
let duration = 0;
2+
let ratio = 0;
23

34
const ts2sec = (ts) => {
45
const [h, m, s] = ts.split(':');
@@ -10,13 +11,15 @@ module.exports = (message, progress) => {
1011
if (message.startsWith(' Duration')) {
1112
const ts = message.split(', ')[0].split(': ')[1];
1213
const d = ts2sec(ts);
14+
progress({ duration: d, ratio });
1315
if (duration === 0 || duration > d) {
1416
duration = d;
1517
}
1618
} else if (message.startsWith('frame') || message.startsWith('size')) {
1719
const ts = message.split('time=')[1].split(' ')[0];
1820
const t = ts2sec(ts);
19-
progress({ ratio: t / duration });
21+
ratio = t / duration;
22+
progress({ ratio, time: t });
2023
} else if (message.startsWith('video:')) {
2124
progress({ ratio: 1 });
2225
duration = 0;

0 commit comments

Comments
 (0)