Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

513
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda