diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-12-17 19:33:51 +1100 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-12-17 19:33:51 +1100 |
commit | 37687dc8bdc1a0dfaffc846afa56227d9f929c26 (patch) | |
tree | b867113c6775962f3ba9421669c3a634f3f250bb /src/cdn | |
parent | Remove unneeded comments (diff) | |
download | server-37687dc8bdc1a0dfaffc846afa56227d9f929c26.tar.xz |
Remove fluent-ffmpeg dep. TODO: Merge puyo's PR
Diffstat (limited to 'src/cdn')
-rw-r--r-- | src/cdn/routes/attachments.ts | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/src/cdn/routes/attachments.ts b/src/cdn/routes/attachments.ts index 9bd256aa..72c7da03 100644 --- a/src/cdn/routes/attachments.ts +++ b/src/cdn/routes/attachments.ts @@ -5,9 +5,6 @@ import FileType from "file-type"; import { HTTPError } from "lambert-server"; import { multer } from "../util/multer"; import imageSize from "image-size"; -import ffmpeg from "fluent-ffmpeg"; -import Path from "path"; -import { Duplex, Readable, Transform, Writable } from "stream"; const router = Router(); @@ -18,14 +15,6 @@ const SANITIZED_CONTENT_TYPE = [ "application/xhtml+xml", ]; -const probe = (file: string): Promise<ffmpeg.FfprobeData> => new Promise((resolve, reject) => { - ffmpeg.setFfprobePath(process.env.FFPROBE_PATH as string); - ffmpeg.ffprobe(file, (err, data) => { - if (err) return reject(err); - return resolve(data); - }); -}); - router.post( "/:channel_id", multer.single("file"), @@ -55,13 +44,6 @@ router.post( height = dimensions.height; } } - else if (mimetype.includes("video") && process.env.FFPROBE_PATH) { - const root = process.env.STORAGE_LOCATION || "../"; // hmm, stolen from FileStorage - const out = await probe(Path.join(root, path)); - const stream = out.streams[0]; // hmm - width = stream.width; - height = stream.height; - } const file = { id, @@ -93,26 +75,6 @@ router.get( content_type = "application/octet-stream"; } - // lol, super gross - if (content_type.includes("video") && format == "jpeg" && process.env.FFMPEG_PATH) { - const promise = (): Promise<Buffer> => new Promise((resolve, reject) => { - ffmpeg.setFfmpegPath(process.env.FFMPEG_PATH as string); - const out: any[] = []; - const cmd = ffmpeg(Readable.from(file as Buffer)) - .format("mjpeg") - .frames(1) - .on("end", () => resolve(Buffer.concat(out))) - .on("error", (err) => reject(err)) - const stream = cmd.pipe(); - stream.on("data", (data) => { - out.push(data) - }); - }); - const res = await promise(); - file = res; - content_type = "jpeg"; - } - res.set("Content-Type", content_type); res.set("Cache-Control", "public, max-age=31536000"); |