improve msg for negative time

pull/1676/head
Mikael Finstad 2023-07-26 11:30:39 +02:00
rodzic 999e855254
commit 37afd7daf6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 25AB36E3E81CBC26
1 zmienionych plików z 4 dodań i 3 usunięć

Wyświetl plik

@ -64,15 +64,16 @@ function handleProgress(process, durationIn, onProgress, customMatcher = () => {
} }
const timeStr = match[1]; const timeStr = match[1];
console.log(timeStr); // console.log(timeStr);
const match2 = timeStr.match(/^(\d+):(\d+):(\d+)\.(\d+)$/); 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 h = parseInt(match2[1], 10);
const m = parseInt(match2[2], 10); const m = parseInt(match2[2], 10);
const s = parseInt(match2[3], 10); const s = parseInt(match2[3], 10);
const cs = parseInt(match2[4], 10); const cs = parseInt(match2[4], 10);
const time = (((h * 60) + m) * 60 + s) + cs / 100; const time = (((h * 60) + m) * 60 + s) + cs / 100;
console.log(time); // console.log(time);
const progressTime = Math.max(0, time); const progressTime = Math.max(0, time);
// console.log(progressTime); // 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 const progress = duration ? Math.min(progressTime / duration, 1) : 0; // sometimes progressTime will be greater than cutDuration
onProgress(progress); onProgress(progress);
} catch (err) { } catch (err) {
console.log('Failed to parse ffmpeg progress line', err); console.log('Failed to parse ffmpeg progress line:', err.message);
} }
}); });
} }