Update to mkv command

This commit is contained in:
walcutt 2025-06-24 15:52:10 -04:00
parent 9f1b694535
commit 44fdad9863
2 changed files with 30 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import { addSubtitleTrack } from "./commands/add-subs.js";
import { extractToEpisodeNumber } from "./commands/extract-to-se.js";
import { finalizeFileNames } from "./commands/finalize-filenames.js";
import { convertToMkv } from "./commands/to-mkv.js";
export const CommandConfig = [
{
@ -20,5 +21,11 @@ export const CommandConfig = [
commands: ['-s'],
params: ['SubtitleDirectory'],
func: addSubtitleTrack,
},
{
name: 'Repackage to Mkv',
commands: ['-m'],
params: [],
func: convertToMkv,
}
];

23
src/commands/to-mkv.js Normal file
View File

@ -0,0 +1,23 @@
import { getFilenameObject } from "../parsing/parse-filename.js";
import { exec } from "../shell/exec.js";
const AcceptedMovieExtensions = [
'.mp4',
'.avi',
'.mkv',
'.mov',
'.webm'
];
export async function convertToMkv(inputDir, inputFile, outputDir, options) {
const filenameObject = getFilenameObject(inputFile);
if(!AcceptedMovieExtensions.includes(filenameObject.extension)) {
return false;
}
await exec(
`ffmpeg -i ${inputDir}${inputFile} -map 0 -c copy ${outputDir}${filenameObject.prefix}.mkv`
);
return true;
}