%PDF- %PDF-
Direktori : /www/varak.net/video.varak.net/ |
Current File : /www/varak.net/video.varak.net/screen.php |
<?php function generateThumbnail($inFile, $outImg) { $output = shell_exec("/usr/bin/ffmpeg -i \"{$inFile}\" 2>&1"); preg_match('/Duration: ([0-9]{2}):([0-9]{2}):([0-9]{2})/', $output, $matches); $time = str_replace("Duration: ", "", $matches[0]); $time_breakdown = explode(":", $time); $total_seconds = round(($time_breakdown[0]*60*60) + ($time_breakdown[1]*60) + $time_breakdown[2]); //shell_exec("/usr/bin/ffmpeg -y -i {$path} -f mjpeg -vframes 1 -ss " . ($total_seconds / 2) . " -s {$w}x{$h} {$output_filename}"; shell_exec("/usr/bin/ffmpeg -ss " . floor($total_seconds / 3.78) . " -i \"$inFile\" -vframes 1 -q:v 10 $outImg"); } $file = __DIR__ . "/videos" . $_GET['file']; $hash = sha1($_GET['file']); $img = __DIR__ . "/screens/" . $hash . ".jpg"; if(!file_exists($img)) { header("Content-Type: image/jpeg"); // Generate thumbnail generateThumbnail($file, $img); } $f = fopen($img, "r"); fpassthru($f); fclose($f);