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

329
Visualizações
How To Asynchronously Check Video File size During Transcoding Process In fluent-ffmpeg

Is there a way during the ffmpeg compression process to determine over various intervals the exact filesize that a video is at?

Such as a method to get current filesize during the process to use when comparing against the videos original filesize.

For example, a potential video being transcoded takes 5 minutes, but during the process, a function will check the file size on intervals of 100 frames or every 5 seconds to ensure that the filesize hasn't exceeded the original. If it has, it will kill the process with command.kill('SIGSTOP');

const transcodeVideo = () => {
  return new Promise((resolve, reject) => {
    ffmpeg("./video.mp4")
      .setFfprobePath(pathToFfprobe.path)
      .setFfmpegPath(pathToFfmpeg)
      .videoCodec("libx264")
      .audioCodec("libmp3lame")
      .size("720x?")
      .on("error", (err) => {
        console.log(err);
      })
      .on("end", () => {
      //irrelevant resolving code in here
      })
      .save("./transVideo.mp4");
  });
};

transcodeVideo();

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use the targetSize property from the "progress" event to get the current size of the target file:

let command = ffmpeg
  // ...
  .on("progress", progress => {
    if (progress.targetSize > originalSize) {
      command.kill();
    }
  });

To get the original size, you can use the standard functions in Node's fs library, e.g. fs.stat.

about 4 years ago · Juan Pablo Isaza Relatório
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