This commit is contained in:
Jared Furlow 2025-10-11 13:52:03 -05:00
parent 2437b98e92
commit cb449f3834
2 changed files with 10 additions and 1 deletions

5
dist/index.js vendored
View File

@ -42,14 +42,17 @@ app.post("/uploadVideo", async (req, res) => {
const fileStream = fs.createWriteStream(targetPath);
uploadingFile.pipe(fileStream);
fileStream.on("close", () => {
console.log(`Completed upload ${fileInfo.filename}`);
console.log(`Completed upload ${videoId}`);
const ffmpegCommand = `ffmpeg -y -loglevel error -i "${targetPath}" -c:v libx264 -crf 23 -preset medium -movflags +faststart -c:a aac -b:a 128k ${formattedPath}`;
currentlyExecFfmpeg = true;
execPromise(ffmpegCommand).then(async ({ stdout, stderr }) => {
if (stderr && stderr.length > 0) console.log("FFmpeg stderr:", stderr);
await minioClient.fPutObject("videos-garage", videoId, formattedPath);
console.log(`Size - Old: ${fs.statSync(targetPath).size / (1024 * 1024)} New: ${fs.statSync(formattedPath).size / (1024 * 1024)}`);
fs.unlinkSync(targetPath);
fs.unlinkSync(formattedPath);
console.log(await minioClient.presignedGetObject("videos-garage", videoId, 24 * 60 * 60));
console.log("");
}).catch((error) => {
console.log("FFmpeg caught error:", error);
}).finally(() => {

View File

@ -74,6 +74,11 @@ app.post("/uploadVideo", async (req, res) => {
videoId,
formattedPath
);
console.log(
`Size - Old: ${
fs.statSync(targetPath).size / (1024 * 1024)
} New: ${fs.statSync(formattedPath).size / (1024 * 1024)}`
);
fs.unlinkSync(targetPath);
fs.unlinkSync(formattedPath);
console.log(
@ -83,6 +88,7 @@ app.post("/uploadVideo", async (req, res) => {
24 * 60 * 60
)
);
console.log("");
})
.catch((error) => {
console.log("FFmpeg caught error:", error);