Update server.js
Browse files
server.js
CHANGED
@@ -3,7 +3,11 @@ const axios = require("axios");
|
|
3 |
const fs = require("fs");
|
4 |
const path = require("path");
|
5 |
const https = require("https");
|
6 |
-
const
|
|
|
|
|
|
|
|
|
7 |
|
8 |
const app = express();
|
9 |
const PORT = 7860;
|
@@ -44,19 +48,21 @@ const scheduleFileDeletion = (filePath, delay = 600000) => {
|
|
44 |
}, delay);
|
45 |
};
|
46 |
|
47 |
-
// Function to convert MKV to MP4 using
|
48 |
const convertToMp4 = (inputPath, outputPath) => {
|
49 |
return new Promise((resolve, reject) => {
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
reject(error);
|
55 |
-
} else {
|
56 |
console.log(`β
Conversion complete: ${outputPath}`);
|
57 |
resolve(outputPath);
|
58 |
-
}
|
59 |
-
|
|
|
|
|
|
|
|
|
60 |
});
|
61 |
};
|
62 |
|
|
|
3 |
const fs = require("fs");
|
4 |
const path = require("path");
|
5 |
const https = require("https");
|
6 |
+
const ffmpeg = require("fluent-ffmpeg");
|
7 |
+
const ffmpegStatic = require("ffmpeg-static");
|
8 |
+
|
9 |
+
// Set ffmpeg binary path (needed for fluent-ffmpeg)
|
10 |
+
ffmpeg.setFfmpegPath(ffmpegStatic);
|
11 |
|
12 |
const app = express();
|
13 |
const PORT = 7860;
|
|
|
48 |
}, delay);
|
49 |
};
|
50 |
|
51 |
+
// Function to convert MKV to MP4 using fluent-ffmpeg
|
52 |
const convertToMp4 = (inputPath, outputPath) => {
|
53 |
return new Promise((resolve, reject) => {
|
54 |
+
ffmpeg(inputPath)
|
55 |
+
.output(outputPath)
|
56 |
+
.outputOptions(["-c:v copy", "-c:a aac", "-strict experimental"]) // Fast conversion
|
57 |
+
.on("end", () => {
|
|
|
|
|
58 |
console.log(`β
Conversion complete: ${outputPath}`);
|
59 |
resolve(outputPath);
|
60 |
+
})
|
61 |
+
.on("error", (err) => {
|
62 |
+
console.error(`β FFmpeg conversion error: ${err.message}`);
|
63 |
+
reject(err);
|
64 |
+
})
|
65 |
+
.run();
|
66 |
});
|
67 |
};
|
68 |
|