fix: populate questions and options tables, scale AI chapters/checkpoints to video duration, open student lesson discovery

This commit is contained in:
Hamza-Ayed
2026-08-28 04:14:16 +03:00
parent dc2ebb108c
commit 17a22c6985
5 changed files with 75 additions and 57 deletions
+15 -3
View File
@@ -207,8 +207,20 @@ class VideoService
$segmentPattern = $hlsOutputDir . '/segment_%03d.ts';
$thumbnailPath = $hlsOutputDir . '/thumbnail.jpg';
// 1. Generate Thumbnail Screenshot at 2 seconds
$thumbCmd = "{$ffmpeg} -ss 00:00:02 -i " . escapeshellarg($sourceMp4Path) . " -vframes 1 -q:v 2 " . escapeshellarg($thumbnailPath) . " -y 2>/dev/null";
// Measure real video duration from input file
$durationSeconds = 10;
$probeCmd = "{$ffmpeg} -i " . escapeshellarg($sourceMp4Path) . " 2>&1";
$probeOutput = @shell_exec($probeCmd);
if ($probeOutput && preg_match('/Duration:\s*(\d{2}):(\d{2}):(\d{2})/i', $probeOutput, $m)) {
$durationSeconds = ($m[1] * 3600) + ($m[2] * 60) + (int)$m[3];
}
if ($durationSeconds <= 0) {
$durationSeconds = 10;
}
// 1. Generate Thumbnail Screenshot at 1 second (or 00:00:01)
$thumbTime = ($durationSeconds > 2) ? '00:00:02' : '00:00:01';
$thumbCmd = "{$ffmpeg} -ss {$thumbTime} -i " . escapeshellarg($sourceMp4Path) . " -vframes 1 -q:v 2 " . escapeshellarg($thumbnailPath) . " -y 2>/dev/null";
@shell_exec($thumbCmd);
// 2. Generate HLS Segments & Playlist (6-second chunks for fast start)
@@ -221,7 +233,7 @@ class VideoService
return [
'hls_url' => file_exists($playlistPath) ? $hlsUrl : null,
'thumbnail_url' => file_exists($thumbnailPath) ? $thumbUrl : null,
'duration_seconds' => 600
'duration_seconds' => $durationSeconds
];
}