Skip to content

Make sprite sheets or gif previews of your videos using Node.js

License

Notifications You must be signed in to change notification settings

tpkn/video-preview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Video Preview npm Package

Make sprite sheets or gif previews of your videos using Node.js

preview

The module creates two types of previews:

  • Horizontal or vertical sprite sheet for css animation-timing-function: steps(10, end)
  • Animated gif image

API

await VideoPreview(input_file, output_file, total_frames[, options])

input_file

Type: String
Full path to source video file.

output_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!

total_frames

Type: Number
The amount of frames in a preview file. If = 1, then would be taken frame from duration / 2 position

options.temp_dir

Type: String
Default: {INPUT FILE PATH}/temp_{UNIQ ID}/
Temporary folder for storing video frames

options.video_length

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!

options.frames_format

Type: String
Default: jpg
png gives maximum quality, but jpg is faster

options.width

Type: Number | String
Output image width. Read this article for more info

options.height

Type: Number | String
Output image height. Read this article for more info

options.quality

Type: Number
Default: 75
For now it works only for gif output format

options.direction

Type: String
Default: v
Frames direction for jpg or png sprite sheets

Key Value
v vertical direction
h horizontal direction

options.fps

Type: Number
Default: 1
Gif frame rate

options.loop

Type: Boolean
Default: true
Loop gif

options.ffmpeg_bin

Type: String
Default: ffmpeg
FFmpeg binary

options.mediainfo_bin

Type: String
Default: MediaInfo
MediaInfo binary

options.convert_bin

Type: String
Default: convert
Convert binary

options.gifski_bin

Type: String
Default: gifski
Gifski binary

options.cleanup

Type: Boolean
Default: false
Remove extracted frames from temp_dir at the end

options.silent

Type: Boolean
Default: true
Enables logging stdout / stderr data

@output

Type: Object

{
   file: 'z:/preview.gif'
}

Usage

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);
})

PS

About

Make sprite sheets or gif previews of your videos using Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published