Error: Output format png is not available
Opened this issue · 0 comments
ljnMeow commented
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:fontcolor=white@0.6`,
])
.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