From e3ef87935ec131db3dc3c9ffcaffa6fbb271410e Mon Sep 17 00:00:00 2001 From: Bingus_Violet Date: Mon, 20 Nov 2023 14:44:35 -0600 Subject: [PATCH] ASD --- index.js | 23 +++++++++++++++++++++-- static/index.html | 6 ++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 35dd228..fc04b92 100644 --- a/index.js +++ b/index.js @@ -54,11 +54,30 @@ app.get("/download", async (req, res) => { } if ("mp3 ogg wav".includes(format)) { + console.log('audio') var audio = ytdl(url, { filter: 'audioonly', quality: quality }) + const ffmpegProcess = cp.spawn(ffmpeg, [ + '-i', `pipe:3`, + '-c:v', 'copy', + '-c:a', 'libmp3lame', + '-crf','27', + '-preset','veryfast', + '-movflags','frag_keyframe+empty_moov', + '-f', format, + '-loglevel','error', + '-' + ], { + stdio: [ + 'pipe', 'pipe', 'pipe', 'pipe', 'pipe', + ], + }) + + audio.pipe(ffmpegProcess.stdio[3]) + res.setHeader('Content-Disposition', `attachment; filename="${filename}.${formats[format] || format}"`); - - audio.pipe(res) + + ffmpegProcess.stdio[1].pipe(res) } else if (defin == "hd") { var video = ytdl(url, { filter: 'videoonly', quality: quality }) diff --git a/static/index.html b/static/index.html index 22b991a..3f3950c 100644 --- a/static/index.html +++ b/static/index.html @@ -39,16 +39,14 @@

Format: