-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbare-encoder.js
45 lines (39 loc) · 1.44 KB
/
bare-encoder.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
const async = require('async')
const fs = require('fs')
const { getFFprobeVideo, hlsEncode, determineOutputs } = require('./uploader/src/encoderHelpers.js')
const config = require('./config.js')
const vpath = process.argv[2]
const dpath = process.argv[3]
console.log('Source video',vpath)
console.log('Destination path',dpath)
getFFprobeVideo(vpath).then((d) => {
let { width, height, duration, orientation } = d
if (!width || !height || !duration || !orientation)
throw new Error('failed to ffprobe video info')
// same processing as local encoder
let outputResolutions = determineOutputs(width,height,config.outputs)
// Create folders
fs.mkdirSync(config.dataDir+'/'+dpath)
for (let r in outputResolutions)
fs.mkdirSync(config.dataDir+'/'+dpath+'/'+outputResolutions[r]+'p')
const ops = hlsEncode(
1, vpath,
orientation,
config.encoder,
config.quality,
outputResolutions,
false,
config.dataDir+'/'+dpath,
config.threads,
(id, resolution, p) => {
console.log('ID '+id+' - '+resolution+'p --- Frames: '+p.frames+' FPS: '+p.currentFps+' Progress: '+p.percent.toFixed(3)+'%')
},
(id, resolution, e) => {
console.error(id+' - '+resolution+'p --- Error',e)
})
async.parallel(ops,(errors) => {
if (errors)
console.log('Error',errors)
console.log('All done!')
})
})