Temp
This commit is contained in:
parent
2437b98e92
commit
cb449f3834
5
dist/index.js
vendored
5
dist/index.js
vendored
@ -42,14 +42,17 @@ app.post("/uploadVideo", async (req, res) => {
|
|||||||
const fileStream = fs.createWriteStream(targetPath);
|
const fileStream = fs.createWriteStream(targetPath);
|
||||||
uploadingFile.pipe(fileStream);
|
uploadingFile.pipe(fileStream);
|
||||||
fileStream.on("close", () => {
|
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}`;
|
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;
|
currentlyExecFfmpeg = true;
|
||||||
execPromise(ffmpegCommand).then(async ({ stdout, stderr }) => {
|
execPromise(ffmpegCommand).then(async ({ stdout, stderr }) => {
|
||||||
if (stderr && stderr.length > 0) console.log("FFmpeg stderr:", stderr);
|
if (stderr && stderr.length > 0) console.log("FFmpeg stderr:", stderr);
|
||||||
await minioClient.fPutObject("videos-garage", videoId, formattedPath);
|
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);
|
fs.unlinkSync(formattedPath);
|
||||||
console.log(await minioClient.presignedGetObject("videos-garage", videoId, 24 * 60 * 60));
|
console.log(await minioClient.presignedGetObject("videos-garage", videoId, 24 * 60 * 60));
|
||||||
|
console.log("");
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.log("FFmpeg caught error:", error);
|
console.log("FFmpeg caught error:", error);
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
|
|||||||
@ -74,6 +74,11 @@ app.post("/uploadVideo", async (req, res) => {
|
|||||||
videoId,
|
videoId,
|
||||||
formattedPath
|
formattedPath
|
||||||
);
|
);
|
||||||
|
console.log(
|
||||||
|
`Size - Old: ${
|
||||||
|
fs.statSync(targetPath).size / (1024 * 1024)
|
||||||
|
} New: ${fs.statSync(formattedPath).size / (1024 * 1024)}`
|
||||||
|
);
|
||||||
fs.unlinkSync(targetPath);
|
fs.unlinkSync(targetPath);
|
||||||
fs.unlinkSync(formattedPath);
|
fs.unlinkSync(formattedPath);
|
||||||
console.log(
|
console.log(
|
||||||
@ -83,6 +88,7 @@ app.post("/uploadVideo", async (req, res) => {
|
|||||||
24 * 60 * 60
|
24 * 60 * 60
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
console.log("");
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log("FFmpeg caught error:", error);
|
console.log("FFmpeg caught error:", error);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user