javascriptnode.jsffmpegffprobe

How to define ffprobe on node.js


I am using ffmpeg.ffprobe to get the duration data of the video on Node JS, but I am getting the error:

Cannot find ffprobe

function video_control(video) {
    var path = video.path
    ffmpeg.setFfmpegPath(require("@ffmpeg-installer/ffmpeg").path);
    ffmpeg.ffprobe(path, (err, metadata) => {
    if (err) {
            console.log(err);
    } else {
        const duration = metadata.format.duration;
        console.log(duration);
    }
    });
}

By the way, I used this structure to get the duration data of the video, but I wanted to use ffmpeg because it created errors in some webm format videos.

const { getVideoDurationInSeconds } = require('get-video-duration')
getVideoDurationInSeconds(path).then(async (duration) => {});

Solution

  • @ffmpeg-installer/ffmpeg only install ffmpeg for you not ffprobe, you need ffprobe-installer

    And load it like below

    ffmpeg.setFfprobePath(require("@ffprobe-installer/ffprobe").path)