From 1d8ec102f1bc9cf7923bd5a666bf0ba6336f92f9 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Tue, 14 Jun 2022 23:02:14 +0900 Subject: [PATCH] fix: GenerateVideoThumbnail (#8825) * fix: GenerateVideoThumbnail * CHANGELOG * fix cleanup * Revert "fix cleanup" This reverts commit d54cf8262ac01a3deb6b8dd7689ec144d4d09ea8. --- CHANGELOG.md | 7 +++++++ .../src/services/drive/generate-video-thumbnail.ts | 12 +++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7854f0ea48..cbf3baa7c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,13 @@ You should also include the user name that made the change. --> +## 12.x.x (unreleased) + +### Improvements + +### Bugfixes +- Fix GenerateVideoThumbnail failed @mei23 + ## 12.111.1 (2022/06/13) ### Bugfixes diff --git a/packages/backend/src/services/drive/generate-video-thumbnail.ts b/packages/backend/src/services/drive/generate-video-thumbnail.ts index b3fd025abc..6e6666481d 100644 --- a/packages/backend/src/services/drive/generate-video-thumbnail.ts +++ b/packages/backend/src/services/drive/generate-video-thumbnail.ts @@ -1,12 +1,10 @@ import * as fs from 'node:fs'; -import * as path from 'node:path'; -import { createTemp } from '@/misc/create-temp.js'; +import { createTempDir } from '@/misc/create-temp.js'; import { IImage, convertToJpeg } from './image-processor.js'; import FFmpeg from 'fluent-ffmpeg'; export async function GenerateVideoThumbnail(source: string): Promise { - const [file, cleanup] = await createTemp(); - const parsed = path.parse(file); + const [dir, cleanup] = await createTempDir(); try { await new Promise((res, rej) => { @@ -16,15 +14,15 @@ export async function GenerateVideoThumbnail(source: string): Promise { .on('end', res) .on('error', rej) .screenshot({ - folder: parsed.dir, - filename: parsed.base, + folder: dir, + filename: 'out.png', // must have .png extension count: 1, timestamps: ['5%'], }); }); // JPEGに変換 (Webpでもいいが、MastodonはWebpをサポートせず表示できなくなる) - return await convertToJpeg(file, 498, 280); + return await convertToJpeg(`${dir}/out.png`, 498, 280); } finally { cleanup(); }