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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/CommandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,14 @@ export const argv: any = yargs.options({
type: 'boolean',
default: false,
demandOption: false
}
},
concat: {
alias: 'c',
describe: 'If enabled concatenate videos in the order they are typed in the file',
type: 'boolean',
default: false,
demandOption: false
},
})
.wrap(120)
.check(() => noArguments())
Expand Down
30 changes: 30 additions & 0 deletions src/destreamer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,36 @@ async function downloadVideo(videoGUIDs: Array<string>,
logger.info(`Video no.${videos.indexOf(video) + 1} downloaded!!\n\n`);
}

// START CONCATENATE
if(argv.concat){
logger.info("Concatenating videos...");

let concatFiles = "";
let concatName = `videos_concatenated ${videos.length}`;
for(const video of videos){
concatFiles += ("file '" + video.outPath + "'\n");
logger.info("file " + video.outPath);
}

// Create a file containg all videos path
fs.writeFileSync('files.txt', concatFiles);

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`
);
try{
execSync(concatCommand, {stdio: 'ignore'});
}catch(err){
logger.error("There was an error during video merging");
}
}
// END CONCATENATE

logger.info('Exiting, this will take some seconds...');

logger.debug('[destreamer] closing downloader socket');
Expand Down