I am new to node and i have use case where i need to validate the loudness parameters of an audio file and check if it is present in a given range and for this I want to measure the loudness parameters of the audio file using the loudnorm filter of ffmpeg and usage of 'loudnorm' filter in fluent-ffmpeg is throwing an error as mentioned below
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
const Ffmpeg = require('fluent-ffmpeg');
Ffmpeg.setFfmpegPath(ffmpegPath);
const path = require('path');
var os = require('os');
const STREAM_URL = "any audio link";
const VOLUME_THRESHOLD = -50; // volume threshold
let tmpfile = path.join(os.tmpdir(), 'name' + '.wav');
getLoudNormData(STREAM_URL, function(meanVolume){
if(meanVolume <= VOLUME_THRESHOLD){
console.log("WE HAVE A PROBLEM! VOLUME IS TOO LOW!");
}else{
console.log("ALL GOOD!");
}
});
function getLoudNormData(streamUrl, callback){
console.log("inside");
new Ffmpeg({ source: streamUrl })
.withAudioFilter('loudnorm=I=-14:tp=-2:print_format=json')
.addOption('-f', 'null')
.on('start', function(ffmpegCommand){
console.log('Output the ffmpeg command', ffmpegCommand);
})
.on('end', function(stdout, stderr){
console.log('output is', stderr )
// find the mean_volume in the output
let meanVolumeRegex = stderr.match(/mean_volume:\s(-?[0–9]\d*(\.\d+)?)/);
// return the mean volume
if(meanVolumeRegex){
let meanVolume = parseFloat(meanVolumeRegex[1]);
console.log('mean volume is', meanVolume )
return callback(meanVolume);
}
// if the stream is not available
if(stderr.match(/Server returned 404 Not Found/)){
return callback(false);
}
})
.save('-');
}
(note: if the problem only happens with some inputs, include a link to such an input file)
[Y ] I tried the same with command line ffmpeg and it works correctly (hint: if the problem also happens this way, this is an ffmpeg problem and you're not reporting it to the right place)
[x] I have included full stderr/stdout output from ffmpeg
Version information
Code to reproduce
I am new to node and i have use case where i need to validate the loudness parameters of an audio file and check if it is present in a given range and for this I want to measure the loudness parameters of the audio file using the loudnorm filter of ffmpeg and usage of 'loudnorm' filter in fluent-ffmpeg is throwing an error as mentioned below
(note: if the problem only happens with some inputs, include a link to such an input file)
Expected results
{ "input_i" : "-27.61", "input_tp" : "-4.47", "input_lra" : "18.06", "input_thresh" : "-39.20", "output_i" : "-16.58", "output_tp" : "-1.50", "output_lra" : "14.78", "output_thresh" : "-27.71", "normalization_type" : "dynamic", "target_offset" : "0.58" }
above json in output of ffmpeg command
Observed results
Error: ffmpeg exited with code 1: Error opening filters! at ChildProcess.anonymous in fluent-ffmpeg/lib/processor.js — line 182
at ChildProcess.emit in core node:events — line 327
Checklist