Add Tdarr_Plugin_da11_Dallas_FFmpeg_Presets_H264_MP4 test

make-only-subtitle-default
HaveAGitGat 4 years ago
parent 1160d52631
commit 8a768ab63a

@ -1,5 +1,4 @@
/* eslint-disable */
// tdarrSkipTest
const details = () => {
return {
id: "Tdarr_Plugin_da11_Dallas_FFmpeg_Presets_H264_MP4",
@ -63,6 +62,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
const lib = require('../methods/lib')();
// eslint-disable-next-line no-unused-vars,no-param-reassign
inputs = lib.loadDefaultValues(inputs, details);
var response = {
processFile: false,
preset: "",
@ -71,15 +71,17 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
FFmpegMode: false,
reQueueAfter: false,
infoLog: "",
addInfo(status, info) {
this.infoLog += (status ? "☑" : "☒") + " " + info + "\n";
},
};
const addInfo = (status, info) => {
response.infoLog += (status ? "☑" : "☒") + " " + info + "\n";
}
// Check the file is a video
if (file.fileMedium !== "video") {
console.log("File is not video");
response.addInfo(BAD, `File is not video`);
addInfo(BAD, `File is not video`);
response.processFile = false;
return response;
}
@ -88,7 +90,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
let preset = getPreset(inputs.FFmpeg_preset);
if (preset === null) {
response.addInfo(
addInfo(
BAD,
`Invalid Preset, \"${inputs.FFmpeg_preset}\" please select from (slow,medium,fast,veryfast)`
);
@ -126,10 +128,10 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
}
if (hasBadSubs)
response.addInfo(BAD, "File contains unsupported sub(s), dropping these!");
addInfo(BAD, "File contains unsupported sub(s), dropping these!");
if (file.ffProbeData.streams[0].codec_name != "h264") {
response.addInfo(BAD, "File is not in h264!");
addInfo(BAD, "File is not in h264!");
response.preset =
", -map_metadata -1 -map 0:V " +
subMap +
@ -140,11 +142,11 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
response.FFmpegMode = true;
return response;
} else {
response.addInfo(GOOD, "File is already in h264!");
addInfo(GOOD, "File is already in h264!");
}
if (file.meta.Title != undefined && !jsonString.includes("aac") && hasSubs) {
response.addInfo(BAD, "File has title metadata and no aac and subs");
addInfo(BAD, "File has title metadata and no aac and subs");
response.preset =
", -map_metadata -1 -map 0:v " +
subMap +
@ -157,7 +159,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
}
if (!jsonString.includes("aac") && hasSubs) {
response.addInfo(BAD, "File has no aac track and has subs");
addInfo(BAD, "File has no aac track and has subs");
response.preset =
", -map 0:v " +
subMap +
@ -170,7 +172,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
}
if (file.meta.Title != undefined && hasSubs) {
response.addInfo(BAD, "File has title and has subs");
addInfo(BAD, "File has title and has subs");
response.preset =
", -map_metadata -1 -map 0:v " +
subMap +
@ -183,7 +185,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
}
if (file.meta.Title != undefined) {
response.addInfo(BAD, "File has title metadata");
addInfo(BAD, "File has title metadata");
response.preset =
", -map_metadata -1 -map 0:v " +
subMap +
@ -194,11 +196,11 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
response.FFmpegMode = true;
return response;
} else {
response.addInfo(GOOD, "File has no title metadata");
addInfo(GOOD, "File has no title metadata");
}
if (!jsonString.includes("aac")) {
response.addInfo(BAD, "File has no aac track");
addInfo(BAD, "File has no aac track");
response.preset =
", -map 0:v " +
subMap +
@ -209,14 +211,14 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
response.FFmpegMode = true;
return response;
} else {
response.addInfo(GOOD, "File has aac track");
addInfo(GOOD, "File has aac track");
}
if (hasSubs) {
if (hasBadSubs) {
response.addInfo(BAD, "File has incompatible subs, dropping these...");
addInfo(BAD, "File has incompatible subs, dropping these...");
} else {
response.addInfo(BAD, "File has compatible subs, copying...");
addInfo(BAD, "File has compatible subs, copying...");
}
response.preset =
", -map 0:v " + subMap + " -map 0:a -c:v copy -c:a copy " + subType;
@ -224,10 +226,10 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
response.FFmpegMode = true;
return response;
} else {
response.addInfo(GOOD, "File has no/compatible subs");
addInfo(GOOD, "File has no/compatible subs");
}
response.addInfo(GOOD, "File meets conditions!");
addInfo(GOOD, "File meets conditions!");
return response;
}

@ -0,0 +1,62 @@
/* eslint max-len: 0 */
const _ = require('lodash');
const run = require('../helpers/run');
const tests = [
{
input: {
file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')),
librarySettings: {},
inputs: {},
otherArguments: {},
},
output: {
processFile: true,
preset: ', -map_metadata -1 -map 0:v -map 0:a -c:v copy -c:a copy -c:s mov_text',
container: '.mp4',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: '☑ File is already in h264!\n☒ File has title metadata\n',
},
},
{
input: {
file: _.cloneDeep(require('../sampleData/media/sampleH265_1.json')),
librarySettings: {},
inputs: {
},
otherArguments: {},
},
output: {
processFile: true,
preset: ', -map_metadata -1 -map 0:V -map 0:a -c:v libx264 -preset medium -c:a aac -strict -2 -c:s mov_text',
container: '.mp4',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: '☒ File is not in h264!\n',
},
},
{
input: {
file: _.cloneDeep(require('../sampleData/media/sampleH265_1.json')),
librarySettings: {},
inputs: {
FFmpeg_preset: 'fast',
},
otherArguments: {},
},
output: {
processFile: true,
preset: ', -map_metadata -1 -map 0:V -map 0:a -c:v libx264 -preset fast -c:a aac -strict -2 -c:s mov_text',
container: '.mp4',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: '☒ File is not in h264!\n',
},
},
];
run(tests);
Loading…
Cancel
Save