-
Notifications
You must be signed in to change notification settings - Fork 3
/
example.js
64 lines (52 loc) · 1.79 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const createSpriteWithVTT = require('./index')
const fs = require("fs");
/** input and output paths **/
// used in the paths, could use different names if you want
// the file to create sprite and vtt from
const inputFilePath = `./examples/assets/video.mp4`;
// const inputFilePath = `./videos/extrawelt.mp4`;
// output variables
const filename = 'video'
const spriteFileName = `${filename}_sprite.webp`;
const vttFileName = `${filename}_sprite.vtt`;
const outputFileDirectory = './assets';
fs.mkdirSync(outputFileDirectory, { recursive: true });
// where to output the files
const spriteOutputFilePath = `${outputFileDirectory}/${spriteFileName}`;
const webVTTOutputFilePath = `${outputFileDirectory}/${vttFileName}`;
// used in building the path for sprite prepend
// (aka where the sprite image will be served from)
const prependPath = '.'
/** variables to setup the output of the sprite/vtt **/
// how often should a snapshot be taken
const intervalInSecondsAsInteger = 2;
// in pixels
const thumbnailLongestSide = 140;
// will clip the sprite file to a maximum of this size
const targetSizeInKb = 80;
// how many columns to use, seems arbitrary so will use 9
const columns = 9;
const debug = true;
if(debug){
console.log(`inputFile: ${inputFilePath}`)
console.log(`intervalInSecondsAsInteger: ${intervalInSecondsAsInteger}`)
console.log(`columns: ${columns}`)
console.log(`spriteOutputFilePath: ${spriteOutputFilePath}`)
console.log(`prependPath: ${prependPath}`)
console.log(`filename: ${filename}`)
console.log(`spriteFileName: ${spriteFileName}`)
}
createSpriteWithVTT({
inputFilePath,
filename,
spriteFileName,
spriteOutputFilePath,
webVTTOutputFilePath,
prependPath,
intervalInSecondsAsInteger,
columns,
thumbnailLongestSide,
targetSizeInKb,
debug,
outputFileDirectory
})