Skip to content

Commit

Permalink
fix cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Jun 13, 2022
1 parent 6c358f9 commit d54cf82
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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();
}
}

0 comments on commit d54cf82

Please sign in to comment.