1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-24 19:32:29 +01:00

fix progress bug

closes #2161
This commit is contained in:
Mikael Finstad 2024-09-26 09:18:08 +03:00
parent 4c00987db9
commit f6c1266588
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

View File

@ -1178,19 +1178,20 @@ function App() {
setCutProgress(0);
let lastOutPath: string | undefined;
let totalProgress = 0;
const onProgress = (progress: number) => {
totalProgress += progress;
const segmentProgresses: Record<number, number> = {};
const handleSegmentProgress = (segIndex: number, progress: number) => {
segmentProgresses[segIndex] = progress;
const totalProgress = segments.reduce((acc, _ignored, index) => acc + (segmentProgresses[index] ?? 0), 0);
setCutProgress(totalProgress / segments.length);
};
// eslint-disable-next-line no-restricted-syntax
for (const segment of segments) {
for (const [index, segment] of segments.entries()) {
const { start, end } = segment;
if (filePath == null) throw new Error();
// eslint-disable-next-line no-await-in-loop
lastOutPath = await captureFramesRange({ customOutDir, filePath, fps: detectedFps, fromTime: start, toTime: end, estimatedMaxNumFiles: captureFramesResponse.estimatedMaxNumFiles, captureFormat, quality: captureFrameQuality, filter: captureFramesResponse.filter, outputTimestamps: captureFrameFileNameFormat === 'timestamp', onProgress });
lastOutPath = await captureFramesRange({ customOutDir, filePath, fps: detectedFps, fromTime: start, toTime: end, estimatedMaxNumFiles: captureFramesResponse.estimatedMaxNumFiles, captureFormat, quality: captureFrameQuality, filter: captureFramesResponse.filter, outputTimestamps: captureFrameFileNameFormat === 'timestamp', onProgress: (progress) => handleSegmentProgress(index, progress) });
}
if (!hideAllNotifications && lastOutPath != null) {
showOsNotification(i18n.t('Frames have been extracted'));