File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ module.exports = (_options = {}) => {
25
25
let logging = optLog ;
26
26
let progress = optProgress ;
27
27
let duration = 0 ;
28
+ let frames = 0 ;
29
+ let readFrames = false ;
28
30
let ratio = 0 ;
29
31
30
32
const detectCompletion = ( message ) => {
@@ -53,11 +55,17 @@ module.exports = (_options = {}) => {
53
55
prog ( { duration : d , ratio } ) ;
54
56
if ( duration === 0 || duration > d ) {
55
57
duration = d ;
58
+ readFrames = true ;
56
59
}
60
+ } else if ( readFrames && message . startsWith ( ' Stream' ) ) {
61
+ const fps = parseFloat ( message . match ( / ( \d + ) f p s / ) [ 1 ] ) ;
62
+ frames = duration * fps ;
63
+ readFrames = false ;
57
64
} else if ( message . startsWith ( 'frame' ) || message . startsWith ( 'size' ) ) {
58
65
const ts = message . split ( 'time=' ) [ 1 ] . split ( ' ' ) [ 0 ] ;
59
66
const t = ts2sec ( ts ) ;
60
- ratio = t / duration ;
67
+ const f = parseFloat ( message . match ( / f r a m e = \s * ( \d + ) / ) [ 1 ] ) ;
68
+ ratio = Math . min ( f / frames , 1 ) ;
61
69
prog ( { ratio, time : t } ) ;
62
70
} else if ( message . startsWith ( 'video:' ) ) {
63
71
prog ( { ratio : 1 } ) ;
You can’t perform that action at this time.
0 commit comments