mirror of
https://github.com/snobu/destreamer.git
synced 2026-01-17 05:22:18 +00:00
Dropped youtube-dl and replaced with ffmpeg, however passing the URL to ffmpeg is broken
This commit is contained in:
@@ -10,6 +10,7 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import yargs from 'yargs';
|
||||
import sanitize from 'sanitize-filename';
|
||||
import ffmpeg from 'fluent-ffmpeg';
|
||||
|
||||
|
||||
/**
|
||||
@@ -178,17 +179,33 @@ async function downloadVideo(videoUrls: string[], outputDirectory: string, sessi
|
||||
// Very experimental inline thumbnail rendering
|
||||
await drawThumbnail(video.posterImage, session.AccessToken);
|
||||
|
||||
console.log('Spawning youtube-dl with cookie and HLS URL...');
|
||||
const format = argv.format ? `-f "${argv.format}"` : '';
|
||||
var youtubedlCmd = 'youtube-dl --no-call-home --no-warnings ' + format +
|
||||
` --output "${outputDirectory}/${video.title}.mp4" --add-header ` +
|
||||
`Authorization:"Bearer ${session.AccessToken}" "${video.playbackUrl}"`;
|
||||
|
||||
if (argv.simulate) {
|
||||
youtubedlCmd = youtubedlCmd + ' -s';
|
||||
}
|
||||
console.info('Spawning ffmpeg with access token and HLS URL...');
|
||||
ffmpeg()
|
||||
.input(video.playbackUrl)
|
||||
.inputOption([
|
||||
'-headers', `"Authorization:Bearer ${session.AccessToken}"`,
|
||||
])
|
||||
.format('mp4')
|
||||
.saveToFile(`"${outputDirectory}/${video.title}.mp4"`)
|
||||
.on('start', cmd => {
|
||||
console.log(`Spawned Ffmpeg with command: ${cmd}`);
|
||||
})
|
||||
.on('codecData', data => {
|
||||
console.log(`Input is ${data.video} with ${data.audio} audio.`);
|
||||
})
|
||||
.on('progress', progress => {
|
||||
console.log(`Processing: ${progress.percent} % done`);
|
||||
})
|
||||
.on('stderr', stderr => {
|
||||
console.log(`Stderr output: ${stderr}`);
|
||||
})
|
||||
.on('error', err => {
|
||||
console.log(`An error occurred: ${err.message}`);
|
||||
})
|
||||
.on('end', info => {
|
||||
console.log(`Processing finished: ${info}`);
|
||||
});
|
||||
|
||||
execSync(youtubedlCmd, { stdio: 'inherit' });
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
23
package-lock.json
generated
23
package-lock.json
generated
@@ -91,6 +91,15 @@
|
||||
"integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/fluent-ffmpeg": {
|
||||
"version": "2.1.14",
|
||||
"resolved": "https://registry.npmjs.org/@types/fluent-ffmpeg/-/fluent-ffmpeg-2.1.14.tgz",
|
||||
"integrity": "sha512-nJrAX9ODNI7mUB0b7Y0Stx1a6dOpV3zXsOnWoBuEd9/woQhepBNCMeCyOL6SLJD3jn5sLw5ciDGH0RwJenCoag==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/json-schema": {
|
||||
"version": "7.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.4.tgz",
|
||||
@@ -288,6 +297,11 @@
|
||||
"integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
|
||||
"dev": true
|
||||
},
|
||||
"async": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz",
|
||||
"integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw=="
|
||||
},
|
||||
"async-limiter": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
|
||||
@@ -782,6 +796,15 @@
|
||||
"integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==",
|
||||
"dev": true
|
||||
},
|
||||
"fluent-ffmpeg": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/fluent-ffmpeg/-/fluent-ffmpeg-2.1.2.tgz",
|
||||
"integrity": "sha1-yVLeIkD4EuvaCqgAbXd27irPfXQ=",
|
||||
"requires": {
|
||||
"async": ">=0.2.9",
|
||||
"which": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "1.5.10",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"author": "snobu",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/fluent-ffmpeg": "^2.1.14",
|
||||
"@types/jwt-decode": "^2.2.1",
|
||||
"@types/puppeteer": "^1.20.0",
|
||||
"@types/yargs": "^15.0.3",
|
||||
@@ -27,6 +28,7 @@
|
||||
"dependencies": {
|
||||
"axios": "^0.19.2",
|
||||
"colors": "^1.4.0",
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"jwt-decode": "^2.2.0",
|
||||
"puppeteer": "^2.1.1",
|
||||
"sanitize-filename": "^1.6.3",
|
||||
|
||||
Reference in New Issue
Block a user