Add video thumbnail support.
This commit is contained in:
@@ -8,6 +8,9 @@ import core from "file-type/core";
|
||||
import GenerateUrl from "./MediaUrlGen";
|
||||
import { FolderPaths } from "./serverInit";
|
||||
import { logger } from "../server";
|
||||
const simpleThumb = require("simple-thumbnail");
|
||||
const ffmpeg = require("ffmpeg-static");
|
||||
|
||||
var Bluebird = require("bluebird");
|
||||
|
||||
Bluebird.promisifyAll(gm.prototype);
|
||||
@@ -39,6 +42,10 @@ export default async function GenerateThumbnail(
|
||||
if (type?.mime === "application/pdf") {
|
||||
const fileOnDisk: Buffer = await fs.readFile(file);
|
||||
await GeneratePdfThumbnail(file, thumbPath);
|
||||
} else if (type?.mime.startsWith("video")) {
|
||||
await simpleThumb(file, thumbPath, "250x?", {
|
||||
path: ffmpeg,
|
||||
});
|
||||
} else {
|
||||
logger.debug("Thumbnail being created for : " + thumbPath);
|
||||
const thumbnail = await imageThumbnail(file, {
|
||||
@@ -51,7 +58,11 @@ export default async function GenerateThumbnail(
|
||||
}
|
||||
return path.relative(path.dirname(file), thumbPath);
|
||||
} catch (err) {
|
||||
logger.error("Error when genenerating thumbnail:", { thumbPath, err });
|
||||
logger.error("Error when genenerating thumbnail:", {
|
||||
thumbPath,
|
||||
err,
|
||||
message: (err as Error).message,
|
||||
});
|
||||
return path.relative(path.dirname(file), thumbPath);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user