improve onProgress

pull/377/head
Mikael Finstad 2020-05-17 20:54:36 +08:00
rodzic 0c2bd1df94
commit 58a9802392
1 zmienionych plików z 9 dodań i 4 usunięć

Wyświetl plik

@ -85,10 +85,11 @@ function handleProgress(process, cutDuration, onProgress) {
if (!match) return;
const str = match[1];
console.log(str);
const progressTime = moment.duration(str).asSeconds();
console.log(progressTime);
onProgress(progressTime / cutDuration);
// console.log(str);
const progressTime = Math.max(0, moment.duration(str).asSeconds());
// console.log(progressTime);
const progress = cutDuration ? progressTime / cutDuration : 0;
onProgress(progress);
} catch (err) {
console.log('Failed to parse ffmpeg progress line', err);
}
@ -238,6 +239,8 @@ async function cut({
const ffmpegArgs = [
'-hide_banner',
// No progress if we set loglevel warning :(
// '-loglevel', 'warning',
...inputCutArgs,
@ -448,6 +451,8 @@ export async function mergeFiles({ paths, outPath, allStreams, outFormat, ffmpeg
// Keep this similar to cut()
const ffmpegArgs = [
'-hide_banner',
// No progress if we set loglevel warning :(
// '-loglevel', 'warning',
// https://blog.yo1.dog/fix-for-ffmpeg-protocol-not-on-whitelist-error-for-urls/
'-f', 'concat', '-safe', '0', '-protocol_whitelist', 'file,pipe', '-i', '-',