-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogress.php
More file actions
44 lines (37 loc) · 1.18 KB
/
progress.php
File metadata and controls
44 lines (37 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
header('Content-Type: application/json');
$logFile = 'process.log';
$doneFile = 'process_done';
$progress = 0;
$logContent = '';
$completed = false;
if (file_exists($logFile)) {
$logContent = file_get_contents($logFile);
// Deteksi tahap proses
if (strpos($logContent, "Generating ASS subtitle") !== false) {
$currentStep = 2; // Tahap transkripsi
$progress = 33;
} elseif (strpos($logContent, "Merging video with subtitle") !== false) {
$currentStep = 3; // Tahap merge
$progress = 66;
} else {
$currentStep = 1; // Tahap ekstrak audio
$progress = 0;
}
// Hitung progress per tahap
if (preg_match('/time=(\d+):(\d+):(\d+)/', $logContent, $matches)) {
$currentTime = $matches[1] * 3600 + $matches[2] * 60 + $matches[3];
$progress += min(33, ($currentTime / $totalDuration) * 33);
}
}
if (file_exists($doneFile) || (file_exists('output/merged.mp4') && filesize('output/merged.mp4') > 0)) {
$completed = true;
$progress = 100;
}
echo json_encode([
'progress' => $progress,
'log' => $logContent,
'completed' => $completed
]);