如何在Node js上定义ffprobe

6kkfgxo0  于 11个月前  发布在  Node.js
关注(0)|答案(1)|浏览(139)

我使用ffmpeg.ffprobe在Node JS上获取视频的持续时间数据,但我得到了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 was using 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) => {});

字符串
'''

bvuwiixz

bvuwiixz1#

@ffmpeg-installer/ffmpeg只为你安装ffmpeg而不是ffprobe,你需要ffprobe-installer
然后像下面这样加载

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

字符串

相关问题