Skip to content
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

Open
wants to merge 2 commits into
base: aria2c_forRealNow
Choose a base branch
from

Conversation

oruamdalo
Copy link

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.

Copy link
Collaborator

@lukaarma lukaarma left a 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!

@@ -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
Copy link
Collaborator

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

Comment on lines 19 to 25
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
},
Copy link
Collaborator

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

}

// Create a file containg all videos path
await fs.promises.writeFile('files.txt', concatFiles);
Copy link
Collaborator

@lukaarma lukaarma Nov 2, 2020

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

Copy link
Author

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

Comment on lines 363 to 371
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
Copy link
Collaborator

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.

Copy link
Author

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.

Copy link
Owner

@snobu snobu Nov 4, 2020

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.

Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants