Mkvmerge
This commit is contained in:
parent
5a95739e33
commit
ed7f0c2dde
2 changed files with 45 additions and 28 deletions
7
funi.js
7
funi.js
|
|
@ -601,10 +601,8 @@ async function downloadStreams(){
|
|||
|
||||
video: if (!argv.novids) {
|
||||
if (plAud.uri && (purvideo.length > 1 || audioAndVideo.length > 1)) {
|
||||
console.log("break 1")
|
||||
break video;
|
||||
} else if (!plAud.uri && (audioAndVideo.some(a => a.lang === streamPath.lang) || puraudio.some(a => a.lang === streamPath.lang))) {
|
||||
console.log("break 2")
|
||||
break video;
|
||||
}
|
||||
// download video
|
||||
|
|
@ -701,8 +699,7 @@ async function downloadStreams(){
|
|||
}
|
||||
|
||||
// usage
|
||||
/* TODO MkvMerge */
|
||||
let usableMKVmerge = false;
|
||||
let usableMKVmerge = true;
|
||||
let usableFFmpeg = true;
|
||||
|
||||
// check exec path
|
||||
|
|
@ -725,7 +722,6 @@ async function downloadStreams(){
|
|||
if(!argv.mp4 && usableMKVmerge){
|
||||
let ffext = !argv.mp4 ? 'mkv' : 'mp4';
|
||||
let command = merger.buildCommandMkvMerge(audioAndVideo, purvideo, puraudio, stDlPath, `${path.join(cfg.dir.content, outName)}.${ffext}`);
|
||||
console.log(command);
|
||||
shlp.exec('mkvmerge', `"${mkvmergebinfile}"`, command);
|
||||
}
|
||||
else if(usableFFmpeg){
|
||||
|
|
@ -741,6 +737,7 @@ async function downloadStreams(){
|
|||
return;
|
||||
|
||||
audioAndVideo.concat(puraudio).concat(purvideo).forEach(a => fs.unlinkSync(a.path))
|
||||
stDlPath.forEach(file => fs.unlinkSync(subObject.file))
|
||||
console.log('\n[INFO] Done!\n');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ const argv = require('../funi').argv;
|
|||
/**
|
||||
* @param {Array<object>} videoAndAudio
|
||||
* @param {Array<object>} onlyVid
|
||||
* @param {Array<object>} onlyAuido
|
||||
* @param {Array<object>} onlyAudio
|
||||
* @param {Array<object>} subtitles
|
||||
* @param {string} output
|
||||
* @returns {string}
|
||||
*/
|
||||
const buildCommandFFmpeg = (videoAndAudio, onlyVid, onlyAuido, subtitles, output) => {
|
||||
const buildCommandFFmpeg = (videoAndAudio, onlyVid, onlyAudio, subtitles, output) => {
|
||||
let args = [];
|
||||
let metaData = [];
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ const buildCommandFFmpeg = (videoAndAudio, onlyVid, onlyAuido, subtitles, output
|
|||
}
|
||||
}
|
||||
|
||||
for (let aud of onlyAuido) {
|
||||
for (let aud of onlyAudio) {
|
||||
args.push(`-i "${aud.path}"`)
|
||||
metaData.push(`-map ${index}`)
|
||||
metaData.push(`-metadata:s:a:${index} language=${getLanguageCode(aud.lang, aud.lang)}`)
|
||||
|
|
@ -71,41 +71,61 @@ const buildCommandFFmpeg = (videoAndAudio, onlyVid, onlyAuido, subtitles, output
|
|||
* @param {Array<object>} subtitles
|
||||
* @returns {string}
|
||||
*/
|
||||
const buildCommandMkvMerge = (videoFile, audioSettings, subtitles, output) => {
|
||||
const buildCommandMkvMerge = (videoAndAudio, onlyVid, onlyAudio, subtitles, output) => {
|
||||
let args = [];
|
||||
|
||||
let hasVideo = false;
|
||||
|
||||
args.push(`-o "${output}"`);
|
||||
args.push(
|
||||
'--no-date',
|
||||
'--disable-track-statistics-tags',
|
||||
'--engage no_variable_data',
|
||||
'--track-name 0:[Funimation]'
|
||||
);
|
||||
|
||||
if (audioSettings.uri) {
|
||||
args.push(
|
||||
'--video-tracks 0',
|
||||
'--no-audio'
|
||||
);
|
||||
args.push(`"${videoFile}"`);
|
||||
args.push(`--language 0:${getLanguageCode(audioSettings.language, argv.todo ? 'jpn' : 'eng')}`);
|
||||
for (let vid of videoAndAudio) {
|
||||
if (!hasVideo) {
|
||||
args.push(
|
||||
'--video-tracks 0',
|
||||
'--audio-tracks 1'
|
||||
)
|
||||
args.push(`--track-name 0:[Funimation]`)
|
||||
args.push(`--language 1:${getLanguageCode(vid.lang, argv.todo ? 'jpn' : 'eng')}`);
|
||||
hasVideo = true
|
||||
} else {
|
||||
args.push(
|
||||
'--no-video',
|
||||
'--audio-tracks 1'
|
||||
)
|
||||
args.push(`--language 1:${getLanguageCode(vid.lang, argv.todo ? 'jpn' : 'eng')}`);
|
||||
}
|
||||
args.push(`"${vid.path}"`)
|
||||
}
|
||||
|
||||
for (let vid of onlyVid) {
|
||||
if (!hasVideo) {
|
||||
args.push(
|
||||
'--video-tracks 0',
|
||||
'--no-audio'
|
||||
)
|
||||
args.push(`--track-name 0:[Funimation]`)
|
||||
hasVideo = true
|
||||
args.push(`${vid.path}"`)
|
||||
}
|
||||
}
|
||||
|
||||
for (let aud of onlyAudio) {
|
||||
args.push(`--language 0:${getLanguageCode(aud.lang, argv.todo ? 'jpn' : 'eng')}`);
|
||||
args.push(
|
||||
'--no-video',
|
||||
'--audio-tracks 0'
|
||||
);
|
||||
args.push(`"${audioSettings.uri}"`);
|
||||
} else{
|
||||
args.push(`--language 1:${argv.todo ? 'jpn' : 'eng'}`);
|
||||
args.push(
|
||||
'--video-tracks 0',
|
||||
'--audio-tracks 1'
|
||||
);
|
||||
args.push(`"${videoFile}"`);
|
||||
args.push(`"${aud.path}"`)
|
||||
}
|
||||
|
||||
if(subtitles.length > 0){
|
||||
for (let index in subtitles) {
|
||||
let subObj = subtitles[index];
|
||||
args.push('--language',`${/*parseInt(index) + (audioSettings.uri ? 2 : 1)*/0}:${getLanguageCode(subObj.language)}`);
|
||||
for (let subObj of subtitles) {
|
||||
args.push('--language',`0:${getLanguageCode(subObj.language)}`);
|
||||
args.push(`"${subObj.file}"`);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue