Remove server-side transcoding

This commit is contained in:
CallMeVerity
2026-06-03 04:56:31 +01:00
parent ff2c3997a0
commit c0b93a2a6e
8 changed files with 42 additions and 294 deletions
-63
View File
@@ -9,7 +9,6 @@ import {
getVideoByMapAndPlayer,
updateVideoPB,
updateTranscodedKey,
updateTranscodeStatus,
} from "../services/db";
import {
uploadObject,
@@ -21,7 +20,6 @@ import {
completeMultipartUpload,
abortMultipartUpload,
getVideoStream,
transcodeVideo,
} from "../services/rustfs";
import { parseMtvFile } from "../services/mtv-parser";
import { getMapInfo } from "../services/momentum-api";
@@ -336,25 +334,6 @@ export const videoRoutes = new Elysia({ prefix: "/api/videos" })
await completeMultipartUpload(video.videoKey, uploadId, s3Parts);
if (
!video.transcodedKey &&
video.transcodeStatus !== "pending" &&
video.transcodeStatus !== "processing"
) {
updateTranscodeStatus(id, "pending");
const videoKey = video.videoKey;
transcodeVideo(videoKey)
.then((transcodedKey) => {
updateTranscodedKey(id, transcodedKey);
updateTranscodeStatus(id, "done");
console.log(`[transcode] Done: ${id} -> ${transcodedKey}`);
})
.catch((err) => {
console.error(`[transcode] Failed: ${id}`, err);
updateTranscodeStatus(id, "failed");
});
}
return {
...video,
videoUrl: getStreamUrl(video.id),
@@ -365,48 +344,6 @@ export const videoRoutes = new Elysia({ prefix: "/api/videos" })
};
})
.post("/:id/transcode", async ({ params: { id } }) => {
const video = getVideoById(id);
if (!video) return status(404, { error: "Not found" });
if (
video.transcodeStatus === "processing" ||
video.transcodeStatus === "pending"
) {
return status(409, {
error: "Transcode already in progress",
transcodeStatus: video.transcodeStatus,
});
}
if (video.transcodedKey) {
return {
...video,
videoUrl: getStreamUrl(video.id),
mtvUrl: getObjectUrl(video.mtvKey),
thumbnailUrl: video.thumbnailKey
? getObjectUrl(video.thumbnailKey)
: undefined,
};
}
updateTranscodeStatus(id, "pending");
const videoKey = video.videoKey;
transcodeVideo(videoKey)
.then((transcodedKey) => {
updateTranscodedKey(id, transcodedKey);
updateTranscodeStatus(id, "done");
console.log(`[transcode] Done: ${id} -> ${transcodedKey}`);
})
.catch((err) => {
console.error(`[transcode] Failed: ${id}`, err);
updateTranscodeStatus(id, "failed");
});
return { id, transcodeStatus: "pending" };
})
.get("/:id/stream", async ({ params: { id }, request, set }) => {
const video = getVideoById(id);
if (!video) return status(404, { error: "Not found" });