fluent-ffmpeg / node-fluent-ffmpeg

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

fluent-ffmpeg cannot catch error throw by filter #1142

Open windschaser opened 2 years ago

windschaser commented 2 years ago

Is there any possible to show error throw by filter? Some times I may need more detail when error occurs.

mandaputtra commented 2 years ago

Can you provide code example, what do you mean by error filter? I'll look at this as soon as I can.

laggingreflex commented 2 years ago

.on('stderr', console.error) - this'll show all errors ffmpeg would've shown.

danilmakarow commented 3 months ago

Have the same problem - errors that occuring during ffmpeg work are not catchable by catch blocks. Example:

  compressVideo(filePath: string, passThroughStream: PassThrough) {
    try {
      const ffmpeg = this.ffmpegService.create();

      ffmpeg
        .input(filePath)
        .videoCodec("libx264")
        ...
        .on("error", (error) => {
          throw new InternalServerErrorException(error);
        })
        .pipe(passThroughStream, { end: true });
    } catch (error) {
      console.log("CATCHED - VideoCompressService - compressVideo", error);
    }
  }

FfmpegService to be clear:

import ffmpeg from "fluent-ffmpeg";
import ffmpegStatic from "ffmpeg-static";

@Injectable()
export class FfmpegService {
  private ffmpeg: typeof ffmpeg;

  constructor() {
    this.ffmpeg = ffmpeg;
    this.ffmpeg.setFfmpegPath(ffmpegStatic);
  }

  create(
    input?: string | stream.Readable,
    options?: ffmpeg.FfmpegCommandOptions,
  ) {
    return this.ffmpeg(input, options);
  }
}

As a result - when error occuring its not catched by any catch block and crashes the whole node js process. Tried to do without .on("error") event - same result.