How to use get-video-duration - 1 common examples

To help you get started, we’ve selected a few get-video-duration examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cs-education / classTranscribe / modules / conversion_utils.js View on Github external
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) => {

get-video-duration

Get the duration of a video file

MIT
Latest version published 3 years ago

Package Health Score

57 / 100
Full package analysis

Popular get-video-duration functions