/** * Convert an AVI video capture into the video frames the WPT is expecting * * @param mixed $testPath * @param mixed $run * @param mixed $cached */ function ProcessAVIVideo(&$test, $testPath, $run, $cached) { global $max_load; $cachedText = ''; if ($cached) { $cachedText = '_Cached'; } $videoFile = "{$testPath}/{$run}{$cachedText}_video.mp4"; $crop = ''; if (!is_file($videoFile)) { $videoFile = "{$testPath}/{$run}{$cachedText}_video.avi"; } if (is_file($videoFile)) { $videoDir = "{$testPath}/video_{$run}" . strtolower($cachedText); if (!is_file("{$videoDir}/video.json")) { if (isset($max_load) && $max_load > 0) { WaitForSystemLoad($max_load, 3600); } if (is_dir($videoDir)) { delTree($videoDir, false); } if (!is_dir($videoDir)) { mkdir($videoDir, 0777, true); } $videoFile = realpath($videoFile); $videoDir = realpath($videoDir); if (strlen($videoFile) && strlen($videoDir)) { if (PythonVisualMetrics($videoFile, $videoDir, $testPath, $run, $cached)) { unlink($videoFile); } else { $crop = FindVideoCrop($videoFile, $videoDir); if (Video2PNG($videoFile, $videoDir, $crop)) { $startOffset = DevToolsGetVideoOffset($testPath, $run, $cached, $endTime); FindAVIViewport($videoDir, $startOffset, $viewport); EliminateDuplicateAVIFiles($videoDir, $viewport); $lastImage = ProcessVideoFrames($videoDir, $viewport); $screenShot = "{$testPath}/{$run}{$cachedText}_screen.jpg"; if (isset($lastImage) && is_file($lastImage)) { unlink($videoFile); if (!is_file($screenShot)) { copy($lastImage, $screenShot); } } } } } $videoInfo = array(); if (isset($viewport)) { $videoInfo['viewport'] = $viewport; } file_put_contents("{$videoDir}/video.json", json_encode($videoInfo)); } } }
<?php chdir('..'); $settings = null; require_once 'common_lib.inc'; require_once 'video/visualProgress.inc.php'; ignore_user_abort(true); set_time_limit(3600); error_reporting(E_ERROR | E_PARSE); $max_load = GetSetting('render_max_load'); if ($max_load !== false && $max_load > 0) { WaitForSystemLoad($max_load, 3600); } // Globals used throughout the video render $width = 900; $height = 650; $padding = 4; $textPadding = 0; $minThumbnailSize = 60; $biggestThumbnail = 0; $backgroundColor = null; $textColor = null; $bgEvenText = null; $bgOddText = null; $image_bytes = null; $timeFont = __DIR__ . '/font/sourcesanspro-semibold.ttf'; $labelFont = __DIR__ . '/font/sourcesanspro-semibold.ttf'; $labelHeight = 30; $timeHeight = 40; $timePadding = 3; $rowPadding = 10;