forked from HaveAGitGat/Tdarr_Plugins
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
80 lines (73 loc) · 2.15 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { promises as fs } from 'fs';
import {
IpluginDetails,
IpluginInputArgs,
IpluginOutputArgs,
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';
import { CLI } from '../../../../FlowHelpers/1.0.0/cliUtils';
import { getFileName, getPluginWorkDir } from '../../../../FlowHelpers/1.0.0/fileUtils';
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
const details = (): IpluginDetails => ({
name: 'Package DoVi mp4',
description: 'Package HEVC stream with injected DoVi RPU in mp4',
style: {
borderColor: 'orange',
},
tags: 'video',
isStartPlugin: false,
pType: '',
requiresVersion: '2.11.01',
sidebarPosition: -1,
icon: '',
inputs: [],
outputs: [
{
number: 1,
tooltip: 'Continue to next plugin',
},
],
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
const lib = require('../../../../../methods/lib')();
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
args.inputs = lib.loadDefaultValues(args.inputs, details);
const outputFilePath = `${getPluginWorkDir(args)}/${getFileName(args.originalLibraryFile._id)}.rpu.hevc.mp4`;
const cliArgs: string[] = [
'-add', `${args.inputFileObj.file}:dvp=8.1:xps_inband:hdr=none`,
'-tmp', `${getPluginWorkDir(args)}/tmp`,
'-brand', 'mp42isom',
'-ab', 'dby1',
'-no-iod',
'-enable', '1',
`${outputFilePath}`,
];
const spawnArgs = cliArgs.map((row) => row.trim()).filter((row) => row !== '');
const cli = new CLI({
cli: '/usr/local/bin/MP4Box',
spawnArgs,
spawnOpts: {},
jobLog: args.jobLog,
outputFilePath,
inputFileObj: args.inputFileObj,
logFullCliOutput: args.logFullCliOutput,
updateWorker: args.updateWorker,
});
const res = await cli.runCli();
if (res.cliExitCode !== 0) {
args.jobLog('Packaging stream into mp4 failed');
throw new Error('MP4Box failed');
}
args.logOutcome('tSuc');
return {
outputFileObj: {
_id: outputFilePath,
},
outputNumber: 1,
variables: args.variables,
};
};
export {
details,
plugin,
};