项目作者: emgag

项目描述 :
PHP library for generating video thumbnail sprites
高级语言: PHP
项目地址: git://github.com/emgag/video-thumbnail-sprite.git
创建时间: 2015-05-18T15:19:56Z
项目社区:https://github.com/emgag/video-thumbnail-sprite

开源协议:MIT License

下载


video-thumbnail-sprite

Software License
Packagist Version

WARNING: This library is no longer maintained /WARNING

PHP library for generating video thumbnail sprites to be used for thumbnails in JWPlayer‘s seek bar.

System requirements

PHP 7.x (see release 0.2 for the latest version supporting PHP 5.5/5.6).

Following binaries need to be installed

Installation

  1. composer require emgag/video-thumbnail-sprite

Usage

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

There are two different thumbnailing methods available, ffmpeg (default) or ffmpegthumbnailer.

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

To keep individual source images of the sprite instead of removing it after assembling the sprite into a single image:

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

Acknowledgments

Uses:

License

video-thumbnail-sprite is licensed under the MIT License.