ekoukltd/video-thumbnail

Video thumbnails

5.0.0 2023-07-15 00:44 UTC

This package is auto-updated.

Last update: 2024-11-19 02:03:46 UTC


README

Simple package for generating video thumbnail in Laravel using FFMpeg.

Support my work

If you want to support my work in other way than contributing the code itself, you can always pass me some small donation 🍺 at https://paypal.me/ekoukltd :)

Installation

Composer install:

composer require ekoukltd/video-thumbnail

After package installation, add the ServiceProvider to the providers array in config/app.php

Ekoukltd\VideoThumbnail\VideoThumbnailServiceProvider::class

And to the aliases array

'VideoThumbnail' => Ekoukltd\VideoThumbnail\Facade\VideoThumbnail::class

Also you can publish package config file with:

php artisan vendor:publish --tag=video-thumbnail

and set ffmpeg and ffprobe paths in .env file:

FFMPEG="/usr/bin/ffmpeg"
FFPROBE="/usr/bin/ffprobe"

Versions

Usage

VideoThumbnail::createThumbnail(
    $videoUrl, 
    $storageUrl, 
    $fileName, 
    $second, 
    $width = 640, 
    $height = 480
);

$videoUrl - absolute path to video file,
$storageUrl - absolute path where the thumbnail should be save,
$fileName - name of thumbnail file,
$second - from which second of the movie thumbnail should be created,
$width [Optional] - width (in pixels) of the thumbnail (default 640),
$height [Optional] - height (in pixels) of the thumbnail (default 480).

Example

VideoThumbnail::createThumbnail(
    public_path('files/movie.mp4'), 
    public_path('files/thumbs/'), 
    'movie.jpg', 
    2, 
    1920, 
    1080
);