emgag / video-thumbnail-sprite
此包已被废弃且不再维护。未建议替代包。
用于生成视频缩略图精灵的PHP库
v1.0.3
2018-04-20 09:34 UTC
Requires
- php: 7.*
- captioning/captioning: ^2.0
- emgag/flysystem-tempdir: ^0.1.0
- intervention/image: ^2.0
- php-ffmpeg/php-ffmpeg: ~0.6
- symfony/process: ^2.5|^3.0|^4.0
Requires (Dev)
- guzzlehttp/guzzle: ^5.0|^6.0
- phpunit/phpunit: ^6.2
README
警告: 此库不再维护 /警告
用于在JWPlayer的seek bar中使用的视频缩略图精灵的PHP库 JWPlayer。
系统要求
PHP 7.x (请参阅 版本0.2 以获取支持PHP 5.5/5.6的最新版本)。
需要安装以下二进制文件
- ffmpeg (已测试 >= v2.2) 或 ffmpegthumbnailer
- imagemagick (已测试 >= v6.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');
致谢
- 受 vlanard/videoscripts 和 scaryguy/jwthumbs 的启发。
- 感谢 Mehrdad-Dadkhah 添加 ffmpegthumbnailer 支持和其他附加功能。
用途
- 字幕/字幕
- emgag/flysystem-tempdir
- intervention/image
- php-ffmpeg/php-ffmpeg
- symfony/process
- thephpleague/flysytem
许可证
video-thumbnail-sprite 在 MIT 许可证 下授权。