vide.me/video-thumbnail-sprite

用于生成视频缩略图精灵的PHP库

v1.0.3 2018-04-20 09:34 UTC

This package is not auto-updated.

Last update: 2024-09-26 03:10:07 UTC


README

Software License Packagist Version

警告:此库仅处于维护模式。虽然它稳定(并且已经稳定了很多年)并且我们仍然对此库进行最小限度的维护,但我们不再在生产中使用它,并且从现在起它将不会收到新功能。/警告

用于在JWPlayer的seek bar中显示缩略图的PHP库

系统要求

PHP 7.x(请参阅版本0.2以获取支持PHP 5.5/5.6的最新版本)。

需要安装以下二进制文件

安装

composer require emgag/video-thumbnail-sprite

使用方法

use Emgag\Video\ThumbnailSprite\ThumbnailSprite;

$sprite = new ThumbnailSprite();
$ret = $sprite->setSource('path-to-source-video.mp4')
       ->setOutputDirectory('dir-to-store-sprite-and-vtt')
       // filename prefix for image sprite and WebVTT file (defaults to "sprite", resulting in "sprite.jpg" and "sprite.vtt")
       ->setPrefix('sprite') 
       // absolute URL of sprite image or relative to where the WebVTT file is stored
       ->setUrlPrefix('http://example.org/sprites')
       // sampling rate in seconds 
       ->setRate(10) 
       // minimum number of images (will modify sampling rate accordingly if it would result in fewer images than this)
       ->setMinThumbs(20)
       // width of a single thumbnail in px 
       ->setWidth(120) 
       ->generate();
       
// $ret = ['vttFile' => 'path-to-vtt-file', 'sprite' => 'path-to-sprite-file'] 

提供了两种不同的缩略图生成方法,ffmpeg(默认)或ffmpegthumbnailer

// default, is set implicitly if not provided
$sprite->setThumbnailer(new Thumbnailer\Ffmpeg());
// change thumbnailer to ffmpegthumbnailer
$sprite->setThumbnailer(new Thumbnailer\FfmpegThumbnailer());

为了保留精灵的单独源图像,而不是在将其组合成单个图像后删除它

$sprite->setOutputImageDirectory('dir-to-store-images');

致谢

用途

许可证

video-thumbnail-sprite遵循MIT许可证