ASD
This commit is contained in:
parent
72defd0e69
commit
e3ef87935e
2 changed files with 23 additions and 6 deletions
23
index.js
23
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 })
|
||||
|
|
|
@ -39,16 +39,14 @@
|
|||
<div class="setting">
|
||||
<p>Format:</p>
|
||||
<select required id="format" name="format">
|
||||
<option disabled>Video Options</option>
|
||||
<option disabled>Video Formats</option>
|
||||
<option value="mp4">.mp4</option>
|
||||
<option value="matroska">.mkv</option>
|
||||
<option value="flv">.flv</option>
|
||||
<option value="avi">.avi</option>
|
||||
<option value="mov">.mov</option>
|
||||
<option disabled>Audio Options</option>
|
||||
<option disabled>Audio Formats</option>
|
||||
<option value="mp3">.mp3</option>
|
||||
<option value="ogg">.ogg</option>
|
||||
<option value="wav">.wav</option>
|
||||
</select>
|
||||
</div>
|
||||
<br>
|
||||
|
|
Loading…
Reference in a new issue