To use the thumbnails plugin, you must load it first, right after the video.js script, e.g.
Code snippet
<script src="/videojs/video.min.js"></script> <script src="/videojs/nuevo.min.js"></script> <script src="/videojs/plugins/thumbnails.js"></script> srcoption.
Code snippet
<script> const player = videojs("my_player_id", {license:"key"}); player.nuevo(); player.thumbnails({ src:"vtt-thumbnails-url", basePath:"thumbnail-image-directory-url/" }) </script> Thumbnails from single images.
For each thumbnail, you must prepare a single image in JPG, PNG, or GIF format. Though it is suggested to keep the same size for each image, it can also be a different size, but you should keep the same display ratio for each image. In the VTT file, just enter the image filename for each time cue.Code snippet
WEBVTT
00:00.000 --> 00:05.000 thumbnail_1.jpg
00:05.000 --> 00:10.000 thumbnail_2.jpg
00:10.000 --> 00:15.000 thumbnail_3.jpg
00:15.000 --> 00:20.000 thumbnail_4.jpg Code snippet
player.thumbnails({ src:"vtt-thumbnails-url", width:192, height:108 }); Thumbnails from sprite image
To limit file size, avoid loading delays, and limit the number of server requests, the thumbnails plugin supports Thumbnail Sprites - multiple thumbnails in one tiled image.Code snippet
WEBVTT
00:00.000 --> 00:05.000 thumbnail.jpg#xywh=0,0,160,90
00:05.000 --> 00:10.000 thumbnail.jpg#xywh=0,160,0,90
00:10.000 --> 00:15.000 thumbnail.jpg#xywh=0,320,0,90
00:15.000 --> 00:20.000 thumbnail.jpg#xywh=0,480,0,90 The VTT sepcification and preparing sprite image are exactly the same as for JWPlayer, described here. Since JWPlayer is popular, we believe that many users are familiar with this technique and are able to prepare tiled images.
We also prepared a bash script to generate a tiled sprite image from video and a VTT file with one command. You need to have ffmpeg tool installed on your server. The script is free to download and use by logged-in users.