refactor: 视频提取进度实时更新卡片,不再刷日志面板

- 主进程通过 video:progress IPC 推送当前帧数
- 前端监听进度事件,直接更新视频芯片的 meta 文本
- 日志面板只保留开始和完成两条记录
This commit is contained in:
thzxx
2026-06-18 11:45:31 +08:00
parent 52c0c3aff5
commit abd3dfde72
4 changed files with 38 additions and 15 deletions
+5 -5
View File
@@ -569,15 +569,15 @@ function extractVideoFrames(filePath: string, maxFrames: number, maxWidth: numbe
});
child.stderr?.on('data', (data: Buffer) => {
ffmpegStderr += data.toString();
// 实时解析进度 frame=\d+
const progressMatch = ffmpegStderr.match(/frame=\s*(\d+)/g);
if (progressMatch) {
const last = progressMatch[progressMatch.length - 1];
// 实时推送进度到渲染进程(每秒一次,覆盖更新)
const match = ffmpegStderr.match(/frame=\s*(\d+)/g);
if (match) {
const last = match[match.length - 1];
const currentFrame = parseInt(last.replace(/\D/g, ''));
if (currentFrame > lastProgressFrame && Date.now() - lastProgressTime > 1000) {
lastProgressFrame = currentFrame;
lastProgressTime = Date.now();
sendLog('debug', `🎬 提取进度`, `${currentFrame}`);
mainWindow?.webContents.send('video:progress', { current: currentFrame });
}
}
});