fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.85k stars 874 forks source link

Taking too much time to compress video #1227

Closed SheerazRasheed closed 10 months ago

SheerazRasheed commented 1 year ago

Version information

Code to reproduce

const bucket = storage.bucket('my-bucket.appspot.com');
      const filePath = 'videos/video.mp4'; // Replace with the full path to your file
      const videoFile = bucket.file(filePath);
      const readStream = videoFile.createReadStream();
const ffmpegCommand = ffmpeg();
      ffmpegCommand.input(readStream);
      ffmpegCommand
        .outputOptions([
          '-preset ultrafast',
          '-c:v libx264',
          '-c:a aac',
          '-vf scale=640:480',
        ])
        .format('wav');
const outputStream = await ffmpegCommand.pipe();

(note: if the problem only happens with some inputs, include a link to such an input file)

Observed results

I am trying to read a video as a stream from firebase and compress it using ffmpeg an it is too much time for the job to complete such that my call breaks before its done and I am getting socket hangup error. I have tried to increase the timeout of the call to 540s but it is still not enought for the job to be done. The framework I am using is nestJs with react as front-end. This is a web-app and the feature I am working on is a video recording functionality.

benjaminhera commented 11 months ago

Maybe download the video file fully and then try to compress it?

njoyard commented 10 months ago

Agreed with what's said above, that does not sound like a fluent-ffmpeg problem