fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.64k stars 874 forks source link

How to get volume levels of audio as JSON object. #1163

Open mohfoad opened 2 years ago

mohfoad commented 2 years ago

Version information

Code to reproduce

new Ffmpeg({ source: uploadPath})
        .withAudioFilter('volumedetect')
        .addOption('-f', 'null')
        .on('error', (err) => {
            return res.status(500).send({success: false, message: err.message});
        })
        .on('end', (stdout, stderr) => {
            console.log(stderr);
        })
        .format(null)
        .saveToFile('/dev/null');

(note: if the problem only happens with some inputs, include a link to such an input file)

Expected results

{
    n_samples: 3127680,
    mean_volume: "-91.0 dB"
    max_volume: "-53.4 dB"
}

Observed results

Checklist