-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added concatenation function to downloadVideo #274
base: aria2c_forRealNow
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple of changes that I would like.
There is also a suggestion on how this could be improved but if you don't have time/don't want it's perfectly fine like this and after those 2/3 minor changes I'll approve it, let me know.
Thanks for the PR!
src/CommandLineParser.ts
Outdated
@@ -16,6 +16,13 @@ export const argv: any = yargs.options({ | |||
describe: 'The username used to log into Microsoft Stream (enabling this will fill in the email field for you).', | |||
demandOption: false | |||
}, | |||
concat: { // FOR CONCATENATING VIDEOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code it's clear, there's no need for a comment here :D
src/CommandLineParser.ts
Outdated
concat: { // FOR CONCATENATING VIDEOS | ||
alias: 'c', | ||
describe: 'If enabled concatenate videos in the order they are typed in the file', | ||
type: 'boolean', | ||
default: false, | ||
demandOption: false | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move it down the options list, below closedCaptions, so that the required/most important options can be seen first
src/destreamer.ts
Outdated
} | ||
|
||
// Create a file containg all videos path | ||
await fs.promises.writeFile('files.txt', concatFiles); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use fs.writeFileSync for consistency please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the moment I did this and fixed CommandLineParser. I will try to figure out how to work with stream and pipelines to merge file using "Nodejs vanilla" without ffmpeg
src/destreamer.ts
Outdated
const concatCommand = ( | ||
// set video concat settings | ||
`ffmpeg -f concat -safe 0 -protocol_whitelist file,http,https,tcp,tls,crypto ` + | ||
// add video list | ||
`-i files.txt ` + | ||
// copy codec and output path | ||
`-c copy videos/${concatName}.mkv` | ||
); | ||
execSync(concatCommand, {stdio: 'ignore'}); //TODO: remove video files after they have been concateated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using FFmpeg you could concatenate the video by literally concatenating the file byte per byte.
You could take a look at pipes in node to handle file redirection, if your up to the task.
If not this way is perfectly fine and I'll approve, let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will look at this and see if I can do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, no! What are we concatenating here, segments or entire finished videos? If the latter, you can't simply concatenate bytes together since every .mkv or .mp4 file has its own header with track/codec/atoms information so you absolutely positively need ffmpeg to handle the concat as it will require reencoding almost every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are concatenating finished videos, but at the end of the concatenation the code won't delete single video files.
Added a flag ("-c" stands for concatenate). If enabled, destreamer (when downloads are completed) concatenate videos into a single one (using "FFmpeg concat" command).
It doesn't remove single videos after concatenation yet.