ksolutions / videotothumbbyks
A package to create thumbnails from videos and images for Laravel and Core PHP
v1.0.1
2025-06-06 12:36 UTC
Requires
- php: ^7.4|^8.0|^8.1|^8.2|^8.3
- guzzlehttp/guzzle: ^7.2
- laravel/framework: ^8.75 || ^9.0 || ^10.0 || ^11.0
- laravel/sanctum: ^2.11 || ^3.3 || ^4.0
- laravel/tinker: ^2.8 || ^2.9
- php-ffmpeg/php-ffmpeg: ^1.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
videotothumbbyks
This package is created by Khemraj Sharma if you have any Queries then Please contact me at captainjacksparrow295@gmail.com
Step ---1 ---- Install this package
composer require ksolutions/videotothumbbyks
Step ---2 ----
sudo apt update
sudo apt install ffmpeg
Step ---3 ----
In your Controller
use KSolutions\VideoToThumb\VideoToThumb;
public function uploadVideo(Request $request)
{
try {
if (!$request->hasFile('video')) {
return response()->json(['status' => 'failed', 'message' => 'No video file uploaded']);
}
$file = $request->file('video');
$time = time();
$videoPath = $file->storeAs('public/videos', $time.'-video.mp4');
$videoFullPath = storage_path('app/' . $videoPath);
$thumbnailPath = storage_path('app/public/thumbnails/'.$time.'-thumbnail.jpg');
$videoToThumb = new VideoToThumb();
$result = $videoToThumb->generateVideoThumbnail($videoFullPath, $thumbnailPath, 5);
if ($result) {
return response()->json(['status' => 'success', 'message' => 'Thumbnail generated successfully', 'thumbnail' => $thumbnailPath]);
} else {
return response()->json(['status' => 'failed', 'message' => 'Thumbnail generation failed']);
}
} catch (Exception $e) {
// Catch and display the exception message
return response()->json(['status' => 'error', 'message' => $e->getMessage()]);
}
}