Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

510
Views
Getting the "Invalid data found when processing input" error when I try to convert a raw pcm file to mp3?

I tried to convert a file from pcm into mp3 with ffmpeg and the npm package fluent-ffmpeg. This is my code:

const ffmpeg = require('fluent-ffmpeg');

function convert(input, output, callback) {
    ffmpeg(input)
        .output(output)
        .on('end', function() {                    
            console.log('conversion ended');
            callback(null);
        }).on('error', function(err){
           console.log('error: ' + err);
           callback(err);
        }).run();
   }

   convert('./test.pcm', './converted.mp3', function(err){
   if(!err) {
      console.log('conversion complete');
   }
});

But every time I execute the script, I get this error:

error: Error: ffmpeg exited with code 1: ./test.pcm: Invalid data found when processing input

When I tired running:

ffmpeg -f s16le -ar 48k -ac 2 -i test.pcm converted.mp3

Everything worked though. Is there something wrong with the npm package? Is there something I missed out or something I did wrong on my code?

Edit:

My code works when I try to convert an mp3 to a wav file (for example). So it's only struggling with pcm files.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!