fluent-ffmpeg / node-fluent-ffmpeg

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

Ffmpeg pipe never ends. #1215

Open J3imip opened 1 year ago

J3imip commented 1 year ago

Version information

Code to reproduce

    return new Promise((resolve, reject) => {
      Ffmpeg(this.url)
        .toFormat("flv")
        .outputFps(30)
        .setDuration("1:00")
        .videoFilters([
          {
            filter: "crop",
            options: this.cropOptions,
          },
          {
            filter: "scale",
            options: "640:640",
          },
        ])
        .on("error", (error) => reject(error))
        .on("end", () => resolve(this.videoPassThrough))
        .pipe(this.videoPassThrough, { end: true })
    });
    return new Promise(async(resolve, reject) => {
      Ffmpeg(this.url) 
        .audioCodec("libopus")
        .audioBitrate("32")
        .toFormat("ogg")
        .noVideo()
        .on('end', () => {
          resolve(this.voicePassThrough);
        })
        .on("error", err => {
          reject(err);
        })
        .pipe(this.voicePassThrough, { end: true });
    })

Expected results

Output results to PassThrough stream using pipe (1st represented code).

Observed results

Ffmpeg instance never ends (1st represented code). 2nd code works well, it resolves voice PassThrough stream on "end" event, but the first one executing forever. Event "end" is not calling for some reason. I've tried to handle "end" event on PassThrough directly, but it also does not calling. So my ffmpeg promise executing always and I'm trying to stop it and return PassThrough when it will be filled.

However, it works (event "end" occurs) if I'll write PassThrough to the file, but due to restrictions I can't afford it.

Checklist

Trard commented 1 month ago

Same, how did you solve it?