diff --git a/index.js b/index.js index f3bbcb5..323af88 100644 --- a/index.js +++ b/index.js @@ -14,6 +14,8 @@ var formats = { "mkv": "matroska" } +var fastFormats = ["mp4", "mkv", "mp3", "wav"] + app.get("/convert", async (req, res) => { var file = req.query.file || "" var format = req.query.format @@ -26,17 +28,6 @@ app.get("/convert", async (req, res) => { var name = ytdlpProcess.stdout.toString() name = name.substring(0, name.lastIndexOf("[") - 1) res.setHeader('Content-Disposition', `attachment; filename="${encodeURIComponent(name)}.${format}"`); - const ffmpegProcess = cp.spawn(ffmpeg, [ - '-i', filePath, - '-f', formats[format] || format, - '-movflags', 'frag_keyframe+empty_moov', - '-c', 'copy', - '-' - ], { - stdio: [ - 'pipe', 'pipe', 'pipe', 'pipe', 'pipe', - ], - }) // ffmpegProcess.stderr.setEncoding('utf-8') // ffmpegProcess.stderr.on('data', (data) => { @@ -140,7 +131,7 @@ app.get("/download", async (req, res) => { } exited = true }) - } else if (["mp3", "wav", "ogx"].includes(format)) { + } else if (["mp3", "wav", "opus"].includes(format)) { res.setHeader('Content-Disposition', `attachment; filename="${encodeURIComponent(videoName)}.${format}"`); var ytdlpProcess = cp.spawn('yt-dlp', [ @@ -156,7 +147,6 @@ app.get("/download", async (req, res) => { '-i', 'pipe:3', '-f', formats[format] || format, '-movflags', 'frag_keyframe+empty_moov', - '-c:a', 'libmp3lame', '-preset','ultrafast', '-crf', '23', '-loglevel', 'error', @@ -213,6 +203,14 @@ app.get("/download", async (req, res) => { }) +process.on('uncaughtException', (err, origin) => { + fs.writeSync( + process.stderr.fd, + `Caught exception: ${err}\n` + + `Exception origin: ${origin}`, + ); +}); + app.use(express.static(path.join(__dirname, 'static'))) app.listen(PORT, function () { diff --git a/static/index.html b/static/index.html index 3146c48..fee6be3 100644 --- a/static/index.html +++ b/static/index.html @@ -46,6 +46,7 @@ + @@ -56,14 +57,7 @@

Univerter was designed for youtube, but if you need something different please consult this list to see if your site is there. Be warned, though, they are mostly untested!

-

Notable supported sites include:

-

For a full list of things that have been tested you can find them here

-

Please consider donating or host the website yourself! Anything helps! (Check Codeberg for more info)