0

I am using [fluent-ffmpeg][1] package to convert mp3 to wav. I have installed ffmpeg on my machine as well.

Now in nodejs, I am trying following commands with options

ffmpeg(mp3FilePath)
  .inputOptions([
      '-af', '"highpass=f=300, lowpass=f=3400"',
      '-r', '8000',
      '-ac', '1'
  ])
  .output(wavFilePath)
  .on('error', (err) => {
      console.log('An error occurred: ' + err.message);
      res.json("failed");
   })
   .on('progress', (progress) => {
      // console.log(JSON.stringify(progress));
      console.log('Processing: ' + progress.targetSize + ' KB converted');
   })
   .on('end', () => {
      console.log('Processing finished !');
      res.json("done");
   }).run();

but this throws error

An error occurred: ffmpeg exited with code 1: lowpass=f=3400": Invalid argument

I am not able to figure out what is the problem. Any help? [1]: https://www.npmjs.com/package/fluent-ffmpeg

Sunil Garg
  • 14,608
  • 25
  • 132
  • 189

1 Answers1

0

I was using output options as input options and to pass audio filter there is a function

ffmpeg(mp3FilePath)
    .audioFilters('highpass=f=300, lowpass=f=3400'
    )
    .outputOptions([
        "-ar 8000",
        '-ac 1'
    ])
    .output(wavFilePath)
    .on('error', (err) => {
        console.log('An error occurred: ' + err.message);
        resolve("failed");
    })
    .on('progress', (progress) => {
        console.log('Processing: ' + progress.targetSize + ' KB converted');
    })
    .on('end', () => {
        console.log('Processing finished !');
    }).run();
Sunil Garg
  • 14,608
  • 25
  • 132
  • 189