Video Thumbnail Generator
Quick Start
import ThumbnailGenerator from 'video-thumbnail-generator';
const tg = new ThumbnailGenerator({
sourcePath: '/tmp/test.mp4',
thumbnailPath: '/tmp/',
tmpDir: '/some/writeable/directory'
});
tg.generate()
.then(console.log);
tg.generateOneByPercent(90)
.then(console.log);
tg.generateCb((err, result) => {
console.log(result);
});
tg.generateOneByPercentCb(90, (err, result) => {
console.log(result);
});
tg.generateGif()
.then(console.log();
tg.generateGifCb((err, result) => {
console.log(result);
})
Options
There are options that can be passed when generating thumbnails. Both ThumbnailGenerate.generate(opts)
and ThumbnailGenerate.generateOneByPercent(number, opts)
can take options. See example below to get screenshots at a resolution of 200x200:
When generating screenshots/thumbnails
tg.generate({
size: '200x200'
})
.then(console.log);
tg.generateCb({
size: '200x200'
}, (err, result) => {
console.log(result);
});
The opts
above can take anything that options in fluent-ffmpeg's Screenshots allow
When generating gifs
tg.generateGif({
fps: 0.75,
scale: 180,
speedMultiple: 4,
deletePalette: true
});
Tests
./node_modules/.bin/gulp test
Else, if you want to run with a code coverage report:
./node_modules/.bin/gulp test:coverage