From 37afd7daf6c7bdd7b7d913ac6a9834a8558b4fb5 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Wed, 26 Jul 2023 11:30:39 +0200 Subject: [PATCH] improve msg for negative time --- public/ffmpeg.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/ffmpeg.js b/public/ffmpeg.js index 6bde2e0a..9598de08 100644 --- a/public/ffmpeg.js +++ b/public/ffmpeg.js @@ -64,15 +64,16 @@ function handleProgress(process, durationIn, onProgress, customMatcher = () => { } const timeStr = match[1]; - console.log(timeStr); + // console.log(timeStr); const match2 = timeStr.match(/^(\d+):(\d+):(\d+)\.(\d+)$/); + if (!match2) throw new Error(`Invalid time from ffmpeg progress ${timeStr}`); const h = parseInt(match2[1], 10); const m = parseInt(match2[2], 10); const s = parseInt(match2[3], 10); const cs = parseInt(match2[4], 10); const time = (((h * 60) + m) * 60 + s) + cs / 100; - console.log(time); + // console.log(time); const progressTime = Math.max(0, time); // console.log(progressTime); @@ -83,7 +84,7 @@ function handleProgress(process, durationIn, onProgress, customMatcher = () => { const progress = duration ? Math.min(progressTime / duration, 1) : 0; // sometimes progressTime will be greater than cutDuration onProgress(progress); } catch (err) { - console.log('Failed to parse ffmpeg progress line', err); + console.log('Failed to parse ffmpeg progress line:', err.message); } }); }