Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Output format png is not available #1298

Open
ljnMeow opened this issue Aug 21, 2024 · 0 comments
Open

Error: Output format png is not available #1298

ljnMeow opened this issue Aug 21, 2024 · 0 comments

Comments

@ljnMeow
Copy link

ljnMeow commented Aug 21, 2024

Version information

  • fluent-ffmpeg version: 2.1.3
  • ffmpeg version: 7.0.2
  • OS: macOS Monterey 12.3.1

Code to reproduce

private imageWatermark(file: Express.Multer.File, watermark: string) {
    const { PassThrough } = stream;

    return new Promise(async (resolve, reject) => {
      try {
        const gifStream = new PassThrough();
        gifStream.end(file.buffer);

        const outputStream = new PassThrough();
        const outputBuffers: Buffer[] = [];

        // 转义字符串
        const escapedWatermark = watermark
          .replace(/:/g, '\\:')
          .replace(/\//g, '\\/')
          .replace(/ /g, '\\ ')
          .replace(/@/g, '\\@');

        ffmpeg(gifStream)
          .outputOptions([
            `-vf`,
            `drawtext=text='${escapedWatermark}':x=(w-tw-10):y=(h-th-10):fontsize=12:[email protected]`,
          ])
          .toFormat('png')
          .on('error', (err) => reject(err))
          .pipe(outputStream);

        outputStream.on('data', (chunk: Buffer) => {
          outputBuffers.push(chunk);
        });
        outputStream.on('end', () => resolve(Buffer.concat(outputBuffers)));
      } catch (error) {
        reject(error);
      }
    });
  }

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

Expected results

Get one file buffer

Observed results

Error: Output format png is not available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant