Files
2026-05-15 16:13:33 +01:00

27 lines
943 B
PHP

<?php
namespace App\Services;
use FFMpeg\FFMpeg;
use FFMpeg\Coordinate\TimeCode;
class VideoService
{
public function generateThumbnail(string $videoPath): string
{
$ffmpeg = FFMpeg::create([
'ffmpeg.binaries' => 'C:/Users/Livetech/AppData/Local/Microsoft/WinGet/Packages/Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe/ffmpeg-8.1-full_build/bin/ffmpeg.exe',
'ffprobe.binaries' => 'C:/Users/Livetech/AppData/Local/Microsoft/WinGet/Packages/Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe/ffmpeg-8.1-full_build/bin/ffprobe.exe',
]);
$video = $ffmpeg->open(storage_path('app/public/' . $videoPath));
$frame = $video->frame(TimeCode::fromSeconds(5));
$thumbnailPath = 'thumbnails/' . uniqid() . '.jpg';
$fullPath = storage_path('app/public/' . $thumbnailPath);
dd($thumbnailPath);
$frame->save($fullPath);
return $fullPath;
}
}