&1', escapeshellarg($videoPath), escapeshellarg($time), escapeshellarg($thumbnailPath) ); $output = []; $returnVar = 0; // Ejecutar el comando exec($command, $output, $returnVar); // Verificar si se generó correctamente if ($returnVar === 0 && file_exists($thumbnailPath) && filesize($thumbnailPath) > 0) { return true; } // Si falla, intentar con un tiempo diferente if ($time !== '00:00:01') { return generateThumbnail($videoPath, $thumbnailPath, '00:00:01'); } return false; } // Obtener lista de videos $videos = []; $video_files = []; // Escanear directorio de videos foreach ($video_extensions as $ext) { $video_files = array_merge($video_files, glob($videos_dir . '*.' . $ext)); } // Procesar información de los videos $videos = []; if (!empty($video_files)) { foreach ($video_files as $video_file) { if (empty($video_file)) continue; $filename = basename($video_file); $title = pathinfo($filename, PATHINFO_FILENAME); // Verificar si el archivo de video existe y es legible if (!file_exists($video_file) || !is_readable($video_file)) { continue; } // Generar miniatura o usar una por defecto $thumbnail_path = $thumbnails_dir . $title . '.jpg'; $default_thumbnail = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNjAwIiBoZWlnaHQ9IjkwMCIgdmlld0JveD0iMCAwIDE2MDAgOTAwIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjMjIyIi8+PHRleHQgeD0iNTAlIiB5PSI1JSIgZm9udC1mYW1pbHk9IkFyaWFsIiBmb250LXNpemU9IjE0IiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmaWxsPSIjZmZmIiBmb250LXdlaWdodD0iYm9sZCI+Tm8gaGF5IHZpZGVvcyBkaXNwb25pYmxlc8K3PC90ZXh0Pjwvc3ZnPg='; // Intentar generar la miniatura si no existe if (!file_exists($thumbnail_path) || !is_readable($thumbnail_path)) { // Crear directorio de miniaturas si no existe if (!is_dir($thumbnails_dir)) { @mkdir($thumbnails_dir, 0777, true); } // Generar miniatura con FFmpeg if (function_exists('shell_exec') && is_callable('shell_exec')) { $ffmpeg_path = trim(shell_exec('which ffmpeg')); if (!empty($ffmpeg_path)) { generateThumbnail($video_file, $thumbnail_path); } } } // Usar miniatura generada o la predeterminada $thumbnail = (file_exists($thumbnail_path) && is_readable($thumbnail_path)) ? $thumbnail_path : $default_thumbnail; $videos[] = [ 'title' => htmlspecialchars($title, ENT_QUOTES, 'UTF-8'), 'url' => $video_file, // Usamos la ruta relativa 'thumbnail' => $thumbnail, 'duration' => '0:00', 'views' => number_format(rand(1000, 1000000)), 'upload_date' => date('d/m/Y', filemtime($video_file)), 'description' => 'Descripción del video ' . htmlspecialchars($title, ENT_QUOTES, 'UTF-8') ]; } } // Determinar el video actual $current_video = null; $current_video_index = 0; if (!empty($_GET['v'])) { $requested_video = urldecode($_GET['v']); foreach ($videos as $index => $video) { if ($video['title'] === $requested_video) { $current_video = $video; $current_video_index = $index; break; } } } // Si no se encontró el video solicitado, usar el primero if (empty($current_video) && !empty($videos)) { $current_video = $videos[0]; } ?>
= nl2br(htmlspecialchars($current_video['description'])) ?>
Sube algunos videos a la carpeta /videos/ para comenzar.