mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-25 03:33:33 +01:00
Remove fluent-ffmpeg dep. TODO: Merge puyo's PR
This commit is contained in:
parent
b25fa163ae
commit
5ededaf289
5094
package-lock.json
generated
5094
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -34,7 +34,6 @@
|
|||||||
"@types/amqplib": "^0.8.2",
|
"@types/amqplib": "^0.8.2",
|
||||||
"@types/bcrypt": "^5.0.0",
|
"@types/bcrypt": "^5.0.0",
|
||||||
"@types/cookie-parser": "^1.4.3",
|
"@types/cookie-parser": "^1.4.3",
|
||||||
"@types/fluent-ffmpeg": "^2.1.20",
|
|
||||||
"@types/i18next-node-fs-backend": "^2.1.1",
|
"@types/i18next-node-fs-backend": "^2.1.1",
|
||||||
"@types/json-bigint": "^1.0.1",
|
"@types/json-bigint": "^1.0.1",
|
||||||
"@types/jsonwebtoken": "^8.5.9",
|
"@types/jsonwebtoken": "^8.5.9",
|
||||||
@ -65,7 +64,6 @@
|
|||||||
"exif-be-gone": "^1.3.1",
|
"exif-be-gone": "^1.3.1",
|
||||||
"fast-zlib": "^2.0.1",
|
"fast-zlib": "^2.0.1",
|
||||||
"file-type": "16.5",
|
"file-type": "16.5",
|
||||||
"fluent-ffmpeg": "^2.1.2",
|
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"i18next": "^21.9.2",
|
"i18next": "^21.9.2",
|
||||||
"i18next-http-middleware": "^3.2.1",
|
"i18next-http-middleware": "^3.2.1",
|
||||||
|
@ -5,9 +5,6 @@ import FileType from "file-type";
|
|||||||
import { HTTPError } from "lambert-server";
|
import { HTTPError } from "lambert-server";
|
||||||
import { multer } from "../util/multer";
|
import { multer } from "../util/multer";
|
||||||
import imageSize from "image-size";
|
import imageSize from "image-size";
|
||||||
import ffmpeg from "fluent-ffmpeg";
|
|
||||||
import Path from "path";
|
|
||||||
import { Duplex, Readable, Transform, Writable } from "stream";
|
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
@ -18,14 +15,6 @@ const SANITIZED_CONTENT_TYPE = [
|
|||||||
"application/xhtml+xml",
|
"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(
|
router.post(
|
||||||
"/:channel_id",
|
"/:channel_id",
|
||||||
multer.single("file"),
|
multer.single("file"),
|
||||||
@ -55,13 +44,6 @@ router.post(
|
|||||||
height = dimensions.height;
|
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 = {
|
const file = {
|
||||||
id,
|
id,
|
||||||
@ -93,26 +75,6 @@ router.get(
|
|||||||
content_type = "application/octet-stream";
|
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("Content-Type", content_type);
|
||||||
res.set("Cache-Control", "public, max-age=31536000");
|
res.set("Cache-Control", "public, max-age=31536000");
|
||||||
|
|
||||||
|
@ -16,10 +16,8 @@ export async function Message(this: WebSocket, buffer: WS.Data) {
|
|||||||
// TODO: compression
|
// TODO: compression
|
||||||
var data: Payload;
|
var data: Payload;
|
||||||
|
|
||||||
if (
|
if ((buffer instanceof Buffer && buffer[0] === 123) ||
|
||||||
(buffer instanceof Buffer && buffer[0] === 123) ||
|
(typeof buffer === "string")) {
|
||||||
(typeof buffer === "string")
|
|
||||||
) {
|
|
||||||
data = bigIntJson.parse(buffer.toString());
|
data = bigIntJson.parse(buffer.toString());
|
||||||
}
|
}
|
||||||
else if (this.encoding === "json" && buffer instanceof Buffer) {
|
else if (this.encoding === "json" && buffer instanceof Buffer) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"exclude": ["./src/webrtc", "./src-slowcord"],
|
"exclude": ["./src/webrtc"],
|
||||||
"include": ["./src"],
|
"include": ["./src"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
/* Visit https://aka.ms/tsconfig to read more about this file */
|
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||||
|
Loading…
Reference in New Issue
Block a user