定制 amnuts/jwplayer-thumbnail-preview-generator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

amnuts/jwplayer-thumbnail-preview-generator

Composer 安装命令:

composer require amnuts/jwplayer-thumbnail-preview-generator

包简介

A simple but effective command-line tool for generating thumbnails of a video, and corresponding VTT file, for use within JW Player to allow for toolbar video preview.

README 文档

README

A simple but effective command-line tool for generating thumbnails of a video and corresponding VTT file for use within JW Player to generate the toolbar thumbnail previews.

Flattr this git repo

Requirements

FFmpeg is required to generate the thumbnails. If you have libav-tools install and the binary is a different name to ffmpeg (or even if you have ffmpeg but installed in a different location) then you can modify the $params information to point to your particular ffmpeg install.

PHP 5.4+ is required as the code uses short array syntax and the CallbackFilterIterator.

Getting started

There are two ways to getting started using this script:

  1. Simply to copy/paste or download the thumbnails.php to your server
  2. Install via composer by running the command:
composer require amnuts/jwplayer-thumbnail-preview-generator

How to use the generator

Simplest example

Typical usage would look like:

php thumbnails.php -i "/input/video.mp4"

This would generate the thumbnails for the video given coalesced into one file (a sprite sheet) and the required VTT file that specifies which thumbnail to display and where in the sprite sheet it is located.

Verbose output

If you do not wish to generate a sprite sheet then include the -v switch to generate verbose output - ie, all the thumbnails are separate files and the VTT file points to each.

php thumbnails.php -i "/input/video.mp4" -v

It is recommended that you use the default coalesced file as this is more optimal when loading than individual images.

Changing output directory

You can change the output directory with the -o switch:

php thumbnails.php -i "/input/video.mp4" -o "/output/directory"

This will write the images and VTT file in the provided directory (default is just to write into the same directory as the generator script).

Change time between thumbnails

To alter the default time between thumbnails use the -t switch with the number of seconds you'd like between each:

php thumbnails.php -i "/input/video.mp4" -t 30

That will generate one thumbnail for every 30 seconds of video.

Change thumbnail width

To change the width of the thumbnail use the -w switch with the size in pixels:

php thumbnails.php -i "/input/video.mp4" -w 75

That will generate thumbnails that are 75 pixels in width. The height is automatic and proportional to the video size.

Generate poster image

The tool also provides the ability to generate a poster file of the video from a random frame of the video at the same time it's generating the thumbnails. To do this, use the -p switch:

php thumbnails.php -i "/input/video.mp4" -p

How to include in JW Player

The code you would use for JW Player would be something like:

<div id="video">video loading...</div>
<script>
    jwplayer("video").setup({
        playlist: [{
            file: "/input/video.mp4",
            image: "poster.jpg",
            tracks: [{
                file: "thumbnails.vtt",
                kind: "thumbnails"
            }]
        }]
    });
</script>

License

MIT: http://acollington.mit-license.org/

统计信息

  • 总下载量: 1.63k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 57
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 56
  • Watchers: 7
  • Forks: 17
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固