Make sprite sheets or gif previews of your videos using Node.js
The module creates two types of previews:
- Horizontal or vertical sprite sheet for css
animation-timing-function: steps(10, end)
- Animated gif image
await VideoPreview(input_file, output_file, total_frames[, options])
Type: String
Full path to source video file.
Type: String
Full path to preview file. Pay special attention to the file extension, it is here that the type of preview to be made is determined!
Type: Number
The amount of frames in a preview file. If = 1
, then would be taken frame from duration / 2
position
Type: String
Default: {INPUT FILE PATH}/temp_{UNIQ ID}/
Temporary folder for storing video frames
Type: Number
Default: true
If not set, then video-length
module would be used to get actual video length. video-length
module requires MediaInfo binary!
Type: String
Default: jpg
png
gives maximum quality, but jpg
is faster
Type: Number | String
Output image width. Read this article for more info
Type: Number | String
Output image height. Read this article for more info
Type: Number
Default: 75
For now it works only for gif output format
Type: String
Default: v
Frames direction for jpg
or png
sprite sheets
Key | Value |
---|---|
v | vertical direction |
h | horizontal direction |
Type: Number
Default: 1
Gif frame rate
Type: Boolean
Default: true
Loop gif
Type: String
Default: ffmpeg
FFmpeg binary
Type: String
Default: MediaInfo
MediaInfo binary
Type: String
Default: convert
Convert binary
Type: String
Default: gifski
Gifski binary
Type: Boolean
Default: false
Remove extracted frames from temp_dir
at the end
Type: Boolean
Default: true
Enables logging stdout
/ stderr
data
Type: Object
{
file: 'z:/preview.gif'
}
const VideoPreview = require('video-preview');
let frames = 10;
let input_file = './videos/MONICA BELLUCCI in the Matrix Sequels (HD Movie Scenes).mp4';
let output_file = './videos/preview.gif';
VideoPreview(input_file, output_file, frames, {
width: 320,
quality: 50,
fps: 1,
cleanup: true,
}).then(result => {
console.log(result);
}).catch(err => {
console.log(err);
})
- Demo video: (c) copyright 2008, Blender Foundation / www.bigbuckbunny.org