Add an option to make ffmpeg, mkvmerge and rtmpdump running verbosely.

This commit is contained in:
Godzil 2018-06-08 21:51:25 +01:00
parent 978a3282a4
commit 65c9032839
5 changed files with 33 additions and 15 deletions

View File

@ -187,5 +187,6 @@ function parse(args: string[]): IConfigLine
'1080') '1080')
.option('-g, --rebuildcrp', 'Rebuild the crpersistant file.') .option('-g, --rebuildcrp', 'Rebuild the crpersistant file.')
.option('-b, --batch <s>', 'Batch file', 'CrunchyRoll.txt') .option('-b, --batch <s>', 'Batch file', 'CrunchyRoll.txt')
.option('--verbose', 'Make tool verbose')
.parse(args); .parse(args);
} }

View File

@ -141,7 +141,7 @@ function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, d
const isSubtited = Boolean(player.subtitle); const isSubtited = Boolean(player.subtitle);
log.dispEpisode(fileName, 'Merging...', false); log.dispEpisode(fileName, 'Merging...', false);
video.merge(config, isSubtited, player.video.file, filePath, player.video.mode, (errVM) => video.merge(config, isSubtited, player.video.file, filePath, player.video.mode, config.verbose, (errVM) =>
{ {
if (errVM) if (errVM)
{ {
@ -198,11 +198,11 @@ function downloadSubtitle(config: IConfig, player: IEpisodePlayer, filePath: str
/** /**
* Streams the video to disk. * Streams the video to disk.
*/ */
function downloadVideo(ignored/*config*/: IConfig, page: IEpisodePage, player: IEpisodePlayer, function downloadVideo(config: IConfig, page: IEpisodePage, player: IEpisodePlayer,
filePath: string, done: (err: Error) => void) filePath: string, done: (err: Error) => void)
{ {
video.stream(player.video.host, player.video.file, page.swf, filePath, video.stream(player.video.host, player.video.file, page.swf, filePath,
path.extname(player.video.file), player.video.mode, done); path.extname(player.video.file), player.video.mode, config.verbose, done);
} }
/** /**

View File

@ -19,4 +19,5 @@ interface IConfig {
video_quality?: string; video_quality?: string;
rebuildcrp?: boolean; rebuildcrp?: boolean;
batch?: string; batch?: string;
verbose?: boolean;
} }

View File

@ -10,10 +10,11 @@ import subtitle from '../subtitle/index';
* Merges the subtitle and video files into a Matroska Multimedia Container. * Merges the subtitle and video files into a Matroska Multimedia Container.
*/ */
export default function(config: IConfig, isSubtitled: boolean, rtmpInputPath: string, filePath: string, export default function(config: IConfig, isSubtitled: boolean, rtmpInputPath: string, filePath: string,
streamMode: string, done: (err: Error) => void) streamMode: string, verbose: boolean, done: (err: Error) => void)
{ {
const subtitlePath = filePath + '.' + (subtitle.formats[config.format] ? config.format : 'ass'); const subtitlePath = filePath + '.' + (subtitle.formats[config.format] ? config.format : 'ass');
let videoPath = filePath; let videoPath = filePath;
let cp;
if (streamMode === 'RTMP') if (streamMode === 'RTMP')
{ {
@ -24,7 +25,7 @@ export default function(config: IConfig, isSubtitled: boolean, rtmpInputPath: st
videoPath += '.mp4'; videoPath += '.mp4';
} }
childProcess.exec(command() + ' ' + cp = childProcess.exec(command() + ' ' +
'-o "' + filePath + '.mkv" ' + '-o "' + filePath + '.mkv" ' +
'"' + videoPath + '" ' + '"' + videoPath + '" ' +
(isSubtitled ? '"' + subtitlePath + '"' : ''), { (isSubtitled ? '"' + subtitlePath + '"' : ''), {
@ -46,6 +47,13 @@ export default function(config: IConfig, isSubtitled: boolean, rtmpInputPath: st
done(null); done(null);
}); });
}); });
if (verbose === true)
{
cp.stdin.pipe(process.stdin);
cp.stdout.pipe(process.stdout);
cp.stderr.pipe(process.stderr);
}
} }
/** /**

View File

@ -9,33 +9,41 @@ import log = require('../log');
* Streams the video to disk. * Streams the video to disk.
*/ */
export default function(rtmpUrl: string, rtmpInputPath: string, swfUrl: string, filePath: string, export default function(rtmpUrl: string, rtmpInputPath: string, swfUrl: string, filePath: string,
fileExt: string, mode: string, done: (err: Error) => void) fileExt: string, mode: string, verbose: boolean, done: (err: Error) => void)
{ {
let cp;
let cmd;
if (mode === 'RTMP') if (mode === 'RTMP')
{ {
childProcess.exec(command('rtmpdump') + ' ' + cmd = command('rtmpdump') + ' ' +
'-r "' + rtmpUrl + '" ' + '-r "' + rtmpUrl + '" ' +
'-y "' + rtmpInputPath + '" ' + '-y "' + rtmpInputPath + '" ' +
'-W "' + swfUrl + '" ' + '-W "' + swfUrl + '" ' +
'-o "' + filePath + fileExt + '"', { '-o "' + filePath + fileExt + '"';
maxBuffer: Infinity,
}, done);
} }
else if (mode === 'HLS') else if (mode === 'HLS')
{ {
const cmd = command('ffmpeg') + ' ' + cmd = command('ffmpeg') + ' ' +
'-i "' + rtmpInputPath + '" ' + '-i "' + rtmpInputPath + '" ' +
'-c copy -bsf:a aac_adtstoasc ' + '-c copy -bsf:a aac_adtstoasc ' +
'"' + filePath + '.mp4"'; '"' + filePath + '.mp4"';
childProcess.exec(cmd,
{
maxBuffer: Infinity,
}, done);
} }
else else
{ {
log.error('No such mode: ' + mode); log.error('No such mode: ' + mode);
} }
cp = childProcess.exec(cmd,
{
maxBuffer: Infinity,
}, done);
if (verbose === true)
{
cp.stdin.pipe(process.stdin);
cp.stdout.pipe(process.stdout);
cp.stderr.pipe(process.stderr);
}
} }
/** /**