stef77dd / videothumbnailsprite
用于生成视频缩略图精灵的PHP库
1.0.3
2023-10-19 14:49 UTC
Requires
- php: >=7.3 || >=8.0
- captioning/captioning: >=2.0
- emgag/flysystem-tempdir: >=3.0
- intervention/image: >=2.5
- php-ffmpeg/php-ffmpeg: >=1.1
- symfony/process: >=5.0
Requires (Dev)
- guzzlehttp/guzzle: >=7.0
- phpunit/phpunit: >=9.0
README
警告:此库已不再维护 /警告
PHP库,用于生成视频缩略图精灵,适用于JWPlayer的搜索条中的缩略图。[JWPlayer](https://support.jwplayer.com/customer/portal/articles/1407439-adding-preview-thumbnails)。
系统要求
PHP > 7.x(请参阅版本0.2,支持PHP 5.5/5.6的最新版本)。
以下二进制文件需要安装
- either ffmpeg (已测试 >= v2.2) or ffmpegthumbnailer
- imagemagick (已测试 >= v6.6)
安装
composer require stef77dd/videoThumbnailSprite
使用方法
use \Stef77dd\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');
致谢
- 受vlanard/videoscripts和scaryguy/jwthumbs的启发。
- 感谢Mehrdad-Dadkhah添加ffmpegthumbnailer支持和其他额外功能。
- 从Emgag的video-thumbnail-sprite分支。
用途
- 字幕/字幕
- imrantune/flysystem-tempdir
- intervention/image
- php-ffmpeg/php-ffmpeg
- symfony/process
- thephpleague/flysytem
许可证
videoThumbnailSprite遵循MIT许可证。