<?php
require_once 'config.php';

echo "检查视频文件...\n\n";

$stmt = $pdo->query("SELECT video_id, video_name, storage_path, file_name, file_size FROM video_assets WHERE is_active = 1");

while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    $fullPath = __DIR__ . '/' . $row['storage_path'] . $row['file_name'];
    $exists = file_exists($fullPath) ? '✅ 存在' : '❌ 不存在';
    $sizeOnDisk = file_exists($fullPath) ? filesize($fullPath) : 0;
    
    echo "ID: {$row['video_id']}\n";
    echo "名称: {$row['video_name']}\n";
    echo "路径: {$row['storage_path']}{$row['file_name']}\n";
    echo "数据库大小: {$row['file_size']} bytes\n";
    echo "实际大小: {$sizeOnDisk} bytes\n";
    echo "状态: $exists\n";
    
    // 检查文件格式
    if (file_exists($fullPath)) {
        $finfo = new finfo(FILEINFO_MIME_TYPE);
        $mime = $finfo->file($fullPath);
        echo "MIME类型: $mime\n";
    }
    
    echo "\n";
}

// 测试视频URL
echo "--- 测试视频URL ---\n";
$videoUrl = 'http://localhost/yangquan_wedding/videos/host/6a33c641eaa1a.mp4';
$ch = curl_init($videoUrl);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo "视频URL: $videoUrl\n";
echo "HTTP状态: $httpCode\n";
?>