Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function get_thumbnails_from_video(pathToFile) {
const { getVideoDurationInSeconds } = require('get-video-duration')
var duration_one_fifth = await getVideoDurationInSeconds(pathToFile).then(duration => {
duration = Math.round(duration / 5);
let hours = Math.floor(duration / 3600);
let minutes = Math.floor(duration / 60);
let seconds = duration % 60;
return Promise.resolve(hours + ':' + minutes + ':' + seconds);
});
var outputFile = _dirname + pathToFile.substring(pathToFile.lastIndexOf('/') + 1, pathToFile.lastIndexOf('.')) + '.jpg';
const { spawn } = require('child-process-promise');
const ffmpeg = spawn('ffmpeg', ['-ss', duration_one_fifth, '-i', pathToFile, '-vframes', '1', '-q:v', '2', outputFile]);
ffmpeg.childProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
ffmpeg.childProcess.stderr.on('data', (data) => {