pawlox/video-thumbnail

视频缩略图

v5.1.0 2024-03-28 12:21 UTC

This package is auto-updated.

Last update: 2024-08-28 13:06:31 UTC


README

使用FFMpeg在Laravel中生成视频缩略图的简单包。

支持我的工作

如果您想以除代码贡献以外的其他方式支持我的工作,您总是可以给我一些小额捐赠 🍺 在 https://paypal.me/pawlox :)

安装

Composer安装

composer require pawlox/video-thumbnail

在包安装后,将ServiceProvider添加到config/app.php文件中的providers数组

Pawlox\VideoThumbnail\VideoThumbnailServiceProvider::class

并添加到aliases数组

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

您还可以使用以下命令发布包配置文件

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

并在.env文件中设置ffmpeg和ffprobe路径

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

版本

用法

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

$videoUrl - 视频文件的绝对路径,
$storageUrl - 缩略图应保存的绝对路径,
$fileName - 缩略图文件的名称,
$second - 从电影的哪一秒创建缩略图,
$width [可选] - 缩略图的宽度(以像素为单位)(默认640),
$height [可选] - 缩略图的高度(以像素为单位)(默认480)。

示例

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