fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ffmpeg pipe never ends.

J3imip opened this issue · comments

commented

Version information

  • fluent-ffmpeg version: 2.1.2
  • ffmpeg version: 6
  • OS: ubuntu 22.04

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

  • I have read the FAQ
  • I tried the same with command line ffmpeg and it works correctly (hint: if the problem also happens this way, this is an ffmpeg problem and you're not reporting it to the right place)
  • I have included full stderr/stdout output from ffmpeg

Same, how did you solve it?