1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-11-24 15:16:30 +09:00

fix cleanup

This commit is contained in:
mei23 2022-06-13 21:54:10 +09:00
parent 6c358f9b74
commit d54cf8262a
No known key found for this signature in database
GPG Key ID: DD8628500D3E4B23

View File

@ -6,6 +6,8 @@ import FFmpeg from 'fluent-ffmpeg';
export async function GenerateVideoThumbnail(source: string): Promise<IImage> {
const [dir, cleanup] = await createTempDir();
const outFile = `${dir}/out.png`;
try {
await new Promise((res, rej) => {
FFmpeg({
@ -22,8 +24,9 @@ export async function GenerateVideoThumbnail(source: string): Promise<IImage> {
});
// JPEGに変換 (Webpでもいいが、MastodonはWebpをサポートせず表示できなくなる)
return await convertToJpeg(`${dir}/out.png`, 498, 280);
return await convertToJpeg(outFile, 498, 280);
} finally {
await fs.promises.unlink(outFile);
cleanup();
}
}