Skip to content
Snippets Groups Projects
Unverified Commit 1d8ec102 authored by MeiMei's avatar MeiMei Committed by GitHub
Browse files

fix: GenerateVideoThumbnail (#8825)

* fix: GenerateVideoThumbnail

* CHANGELOG

* fix cleanup

* Revert "fix cleanup"

This reverts commit d54cf8262ac01a3deb6b8dd7689ec144d4d09ea8.
parent 3a42fe50
No related branches found
Tags 2023.9.0-beta.7
No related merge requests found
......@@ -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
......
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<IImage> {
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<IImage> {
.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();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment