Move function to fonction.php and Add video Thumbnail
This commit is contained in:
@ -4,6 +4,10 @@ error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
include 'fonction.php';
|
||||
|
||||
require '/var/www/html/projects/vendor/autoload.php';
|
||||
|
||||
$root = $_SERVER["DOCUMENT_ROOT"];
|
||||
|
||||
$directory = "/uploads/";
|
||||
@ -12,7 +16,22 @@ if(isset($_GET["file"])) {
|
||||
$file = $root.urldecode($_GET["file"]);
|
||||
$size = isset($_GET["size"]) ? $_GET["size"] : 100;
|
||||
if(file_exists($file)) {
|
||||
echo getthumbnail($file, $size);
|
||||
switch (font_type($file)) {
|
||||
case 'file-image':
|
||||
echo getThumbnail($file, $size);
|
||||
break;
|
||||
case 'file-video':
|
||||
$thumb = createThumbnail($file, 10);
|
||||
echo getThumbnail($thumb, $size);
|
||||
break;
|
||||
case 'file-pdf':
|
||||
// code...
|
||||
break;
|
||||
default:
|
||||
echo "Not image";
|
||||
break;
|
||||
|
||||
}
|
||||
exit();
|
||||
}
|
||||
else {
|
||||
@ -22,8 +41,20 @@ if(isset($_GET["file"])) {
|
||||
}
|
||||
}
|
||||
|
||||
function createThumbnail(string $file, int $sec)
|
||||
{
|
||||
$thumbnail = '/tmp/thumbnail.png';
|
||||
|
||||
function getthumbnail(string $file, int $size)
|
||||
$ffmpeg = FFMpeg\FFMpeg::create();
|
||||
$video = $ffmpeg->open($file);
|
||||
$frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds($sec));
|
||||
$frame->save($thumbnail);
|
||||
|
||||
return($thumbnail);
|
||||
}
|
||||
|
||||
|
||||
function getThumbnail(string $file, int $size)
|
||||
{
|
||||
|
||||
list($width, $height) = getimagesize($file);
|
||||
|
Reference in New Issue
Block a user