@@ -7,7 +7,7 @@ const NO_LOAD = Error('ffmpeg.wasm is not ready, make sure you have completed lo
7
7
8
8
module . exports = ( _options = { } ) => {
9
9
const {
10
- log : logging ,
10
+ log : optLog ,
11
11
logger,
12
12
progress : optProgress ,
13
13
...options
@@ -22,6 +22,7 @@ module.exports = (_options = {}) => {
22
22
let runReject = null ;
23
23
let running = false ;
24
24
let customLogger = ( ) => { } ;
25
+ let logging = optLog ;
25
26
let progress = optProgress ;
26
27
let duration = 0 ;
27
28
let ratio = 0 ;
@@ -44,22 +45,22 @@ module.exports = (_options = {}) => {
44
45
const [ h , m , s ] = ts . split ( ':' ) ;
45
46
return ( parseFloat ( h ) * 60 * 60 ) + ( parseFloat ( m ) * 60 ) + parseFloat ( s ) ;
46
47
} ;
47
- const parseProgress = ( message , progress ) => {
48
+ const parseProgress = ( message , prog ) => {
48
49
if ( typeof message === 'string' ) {
49
50
if ( message . startsWith ( ' Duration' ) ) {
50
51
const ts = message . split ( ', ' ) [ 0 ] . split ( ': ' ) [ 1 ] ;
51
52
const d = ts2sec ( ts ) ;
52
- progress ( { duration : d , ratio } ) ;
53
+ prog ( { duration : d , ratio } ) ;
53
54
if ( duration === 0 || duration > d ) {
54
55
duration = d ;
55
56
}
56
57
} else if ( message . startsWith ( 'frame' ) || message . startsWith ( 'size' ) ) {
57
58
const ts = message . split ( 'time=' ) [ 1 ] . split ( ' ' ) [ 0 ] ;
58
59
const t = ts2sec ( ts ) ;
59
60
ratio = t / duration ;
60
- progress ( { ratio, time : t } ) ;
61
+ prog ( { ratio, time : t } ) ;
61
62
} else if ( message . startsWith ( 'video:' ) ) {
62
- progress ( { ratio : 1 } ) ;
63
+ prog ( { ratio : 1 } ) ;
63
64
duration = 0 ;
64
65
}
65
66
}
@@ -213,8 +214,8 @@ module.exports = (_options = {}) => {
213
214
throw NO_LOAD ;
214
215
} else {
215
216
// if there's any pending runs, reject them
216
- if ( runReject ) {
217
- runReject ( 'ffmpeg has exited' )
217
+ if ( runReject ) {
218
+ runReject ( 'ffmpeg has exited' ) ;
218
219
}
219
220
running = false ;
220
221
try {
0 commit comments