mirror of
https://github.com/anidl/multi-downloader-nx.git
synced 2026-01-11 20:10:20 +00:00
FFmpeg can add fonts to mkv file
This commit is contained in:
parent
595b407b22
commit
5c5f0c73d2
5 changed files with 23 additions and 10 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -21,4 +21,5 @@ test.*
|
|||
updates.json
|
||||
funi_token.yml
|
||||
cr_token.yml
|
||||
archive.json
|
||||
archive.json
|
||||
fonts
|
||||
|
|
@ -873,7 +873,7 @@ async function muxStreams(data: DownloadedMedia[], output: string) {
|
|||
console.log('\n[INFO] Done!\n');
|
||||
return;
|
||||
}
|
||||
if (isMuxed)
|
||||
if (isMuxed && !argv.nocleanup)
|
||||
merger.cleanUp();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ const args: TAppArg<boolean|number|string|unknown[]>[] = [
|
|||
default: {
|
||||
default: undefined
|
||||
}
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
export {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { fontFamilies, fontMime } from './module.fontsData';
|
|||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { LanguageItem } from './module.langsData';
|
||||
import { AvailableMuxer } from './module.args';
|
||||
|
||||
export type MergerInput = {
|
||||
path: string,
|
||||
|
|
@ -31,7 +32,8 @@ export type MergerOptions = {
|
|||
output: string,
|
||||
simul?: boolean,
|
||||
fonts?: ParsedFont[],
|
||||
skipSubMux?: boolean
|
||||
skipSubMux?: boolean,
|
||||
coustomOptions?: string,
|
||||
}
|
||||
|
||||
class Merger {
|
||||
|
|
@ -87,16 +89,26 @@ class Merger {
|
|||
args.push(`-i "${sub.file}"`);
|
||||
}
|
||||
|
||||
if (this.options.output.split('.').pop() === 'mkv')
|
||||
if (this.options.fonts) {
|
||||
let fontIndex = 0;
|
||||
for (const font of this.options.fonts) {
|
||||
args.push(`-attach ${font.path} -metadata:s:t:${fontIndex} mimetype=${font.mime}`);
|
||||
fontIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
args.push(...metaData);
|
||||
args.push(...this.options.subtitles.map((_, subIndex) => `-map ${subIndex + index}`));
|
||||
args.push(
|
||||
'-c:v copy',
|
||||
'-c:a copy'
|
||||
'-c:a copy',
|
||||
this.options.output.split('.').pop()?.toLowerCase() === 'mp4' ? '-c:s mov_text' : '-c:s ass',
|
||||
...this.options.subtitles.map((sub, subindex) => `-metadata:s:s:${subindex} title="${
|
||||
(sub.language.language || sub.language.name) + `${sub.closedCaption === true ? ' CC' : ''}`
|
||||
}" -metadata:s:s:${subindex} language=${sub.language.code}`),
|
||||
this.options.coustomOptions ?? ''
|
||||
);
|
||||
args.push(this.options.output.split('.').pop()?.toLowerCase() === 'mp4' ? '-c:s mov_text' : '-c:s ass');
|
||||
args.push(...this.options.subtitles.map((sub, subindex) => `-metadata:s:s:${subindex} title="${
|
||||
(sub.language.language || sub.language.name) + `${sub.closedCaption === true ? ' CC' : ''}`
|
||||
}" -metadata:s:s:${subindex} language=${sub.language.code}`));
|
||||
args.push(`"${this.options.output}"`);
|
||||
return args.join(' ');
|
||||
}
|
||||
|
|
|
|||
2
tsc.ts
2
tsc.ts
|
|
@ -12,7 +12,7 @@ const ignore = [
|
|||
path.join('config', 'token.yml'),
|
||||
path.join('config', 'updates.json'),
|
||||
path.join('config', 'cr_token.yml'),
|
||||
path.join('config', 'token.yml'),
|
||||
path.join('config', 'funi_token.yml'),
|
||||
'.eslint',
|
||||
].map(a => path.join(__dirname, a));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue