Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function compressVideo(videoPath, outputPath, cback) {
console.log(videoPath, outputPath);
hbjs.spawn({
input: videoPath,
output: outputPath,
preset: 'Very Fast 480p30'
})
.on('error', function(err){
// invalid user input, no video found etc
console.log("error", err);
cback(err);
})
.on('progress', function(progress){
console.log(
'Percent complete: %s, ETA: %s',
progress.percentComplete,
progress.eta
);
})
var id = uid(24);
var ext = path.extname(input);
var filename = path.basename(input, ext);
var vid = encodeStates[id] = {
id: id,
input: input,
output: path.normalize(outputDir + path.sep + filename + ".mp4")
};
var encOptions = _.extend({}, this.fileEncodeOptions, {
input: vid.input,
output: vid.output
});
var handle = handbrake.spawn(encOptions)
.on('error', function (err) {
console.log('Error while encoding ', vid, ': ', err);
delete encodeStates[id];
})
.on('progress', function (progress) {
vid.progress = progress;
})
.on("complete", function(params) {
vid.progress = 'complete';
delete encodeStates[id];
});
handle.vid = vid;
return handle;
}
});