Fix SD mp4s
This commit is contained in:
parent
d7edce0c95
commit
ad0e0ff1e6
1 changed files with 32 additions and 26 deletions
22
index.js
22
index.js
|
@ -23,13 +23,13 @@ var uploads = multer({ dest: 'uploads/' })
|
|||
|
||||
const characters = "abcdefghijklmnopqrstuvwxyz!@$%^*()[]_-=+ "
|
||||
|
||||
process.on('uncaughtException', (err, origin) => {
|
||||
fs.writeSync(
|
||||
process.stderr.fd,
|
||||
`Caught exception: ${err}\n` +
|
||||
`Exception origin: ${origin}`,
|
||||
);
|
||||
});
|
||||
// process.on('uncaughtException', (err, origin) => {
|
||||
// fs.writeSync(
|
||||
// process.stderr.fd,
|
||||
// `Caught exception: ${err}\n` +
|
||||
// `Exception origin: ${origin}`,
|
||||
// );
|
||||
// });
|
||||
|
||||
app.use(bodyParser.urlencoded({ extended: false }))
|
||||
|
||||
|
@ -139,7 +139,8 @@ app.get("/download", async (req, res) => {
|
|||
ffmpegProcess.stdio[1].pipe(res)
|
||||
|
||||
} else {
|
||||
var video = ytdl(url, { filter: 'videoandaudio', quality: quality })
|
||||
if (format != 'mp4') {
|
||||
var video = ytdl(url, { filter: 'videoandaudio', quality: quality, highWaterMark: 1 << 25 })
|
||||
|
||||
const ffmpegProcess = cp.spawn(ffmpeg, [
|
||||
'-i', `pipe:3`,
|
||||
|
@ -159,6 +160,11 @@ app.get("/download", async (req, res) => {
|
|||
// res.setHeader('Content-Length', fs.readFileSync(dest).length)
|
||||
|
||||
ffmpegProcess.stdio[1].pipe(res)
|
||||
} else {
|
||||
var video = ytdl(url, { filter: 'videoandaudio', quality: quality, highWaterMark: 1 << 25 })
|
||||
res.setHeader('Content-Disposition', `attachment; filename="${filename}.${formats[format] || format}"`);
|
||||
video.pipe(res)
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue