Fix lint error
This commit is contained in:
parent
733e3582a8
commit
538ecd21d8
@ -7,7 +7,7 @@ const NO_LOAD = Error('ffmpeg.wasm is not ready, make sure you have completed lo
|
|||||||
|
|
||||||
module.exports = (_options = {}) => {
|
module.exports = (_options = {}) => {
|
||||||
const {
|
const {
|
||||||
log: logging,
|
log: optLog,
|
||||||
logger,
|
logger,
|
||||||
progress: optProgress,
|
progress: optProgress,
|
||||||
...options
|
...options
|
||||||
@ -22,6 +22,7 @@ module.exports = (_options = {}) => {
|
|||||||
let runReject = null;
|
let runReject = null;
|
||||||
let running = false;
|
let running = false;
|
||||||
let customLogger = () => {};
|
let customLogger = () => {};
|
||||||
|
let logging = optLog;
|
||||||
let progress = optProgress;
|
let progress = optProgress;
|
||||||
let duration = 0;
|
let duration = 0;
|
||||||
let ratio = 0;
|
let ratio = 0;
|
||||||
@ -44,12 +45,12 @@ module.exports = (_options = {}) => {
|
|||||||
const [h, m, s] = ts.split(':');
|
const [h, m, s] = ts.split(':');
|
||||||
return (parseFloat(h) * 60 * 60) + (parseFloat(m) * 60) + parseFloat(s);
|
return (parseFloat(h) * 60 * 60) + (parseFloat(m) * 60) + parseFloat(s);
|
||||||
};
|
};
|
||||||
const parseProgress = (message, progress) => {
|
const parseProgress = (message, prog) => {
|
||||||
if (typeof message === 'string') {
|
if (typeof message === 'string') {
|
||||||
if (message.startsWith(' Duration')) {
|
if (message.startsWith(' Duration')) {
|
||||||
const ts = message.split(', ')[0].split(': ')[1];
|
const ts = message.split(', ')[0].split(': ')[1];
|
||||||
const d = ts2sec(ts);
|
const d = ts2sec(ts);
|
||||||
progress({ duration: d, ratio });
|
prog({ duration: d, ratio });
|
||||||
if (duration === 0 || duration > d) {
|
if (duration === 0 || duration > d) {
|
||||||
duration = d;
|
duration = d;
|
||||||
}
|
}
|
||||||
@ -57,9 +58,9 @@ module.exports = (_options = {}) => {
|
|||||||
const ts = message.split('time=')[1].split(' ')[0];
|
const ts = message.split('time=')[1].split(' ')[0];
|
||||||
const t = ts2sec(ts);
|
const t = ts2sec(ts);
|
||||||
ratio = t / duration;
|
ratio = t / duration;
|
||||||
progress({ ratio, time: t });
|
prog({ ratio, time: t });
|
||||||
} else if (message.startsWith('video:')) {
|
} else if (message.startsWith('video:')) {
|
||||||
progress({ ratio: 1 });
|
prog({ ratio: 1 });
|
||||||
duration = 0;
|
duration = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,7 +215,7 @@ module.exports = (_options = {}) => {
|
|||||||
} else {
|
} else {
|
||||||
// if there's any pending runs, reject them
|
// if there's any pending runs, reject them
|
||||||
if (runReject) {
|
if (runReject) {
|
||||||
runReject('ffmpeg has exited')
|
runReject('ffmpeg has exited');
|
||||||
}
|
}
|
||||||
running = false;
|
running = false;
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user