mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 23:48:15 -07:00
1) New plugin that uses CPU to convert to H265. 2) Change to FFMPEG NVidia plugin to specifiy bitrate cutoff. 3) Fix random infolog "2" in CleanTitle 4) Update descriptive audio check in CleanAudio and CleanSubs to look for "sdh" 5) Correct OrderStreams mentioning that "Audio not first" when audio should be second.
137 lines
No EOL
4.2 KiB
JavaScript
137 lines
No EOL
4.2 KiB
JavaScript
function details() {
|
|
return {
|
|
id: "Tdarr_Plugin_MC93_Migz6OrderStreams",
|
|
Stage: "Pre-processing",
|
|
Name: "Migz-Organize Streams",
|
|
Type: "Streams",
|
|
Operation: "Organize",
|
|
Description: `[TESTING]Organizes streams into Video first, then Audio (2ch, 6ch, 8ch) and finally Subtitles. \n\n`,
|
|
Version: "1.00",
|
|
Link: "https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_Migz6OrderStreams.js",
|
|
Tags:'pre-processing,ffmpeg,'
|
|
}
|
|
}
|
|
|
|
function plugin(file) {
|
|
var response = {
|
|
processFile: false,
|
|
preset: '',
|
|
container: '.' + file.container,
|
|
handBrakeMode: false,
|
|
FFmpegMode: true,
|
|
infoLog: '',
|
|
}
|
|
|
|
var ffmpegCommandInsert = ''
|
|
var videoIdx = 0
|
|
var audioIdx = 0
|
|
var audio2Idx = 0
|
|
var audio6Idx = 0
|
|
var audio8Idx = 0
|
|
var subtitleIdx = 0
|
|
var convert = false
|
|
|
|
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
|
|
try {
|
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "video") {
|
|
if (audioIdx != "0" || subtitleIdx != "0") {
|
|
convert = true
|
|
response.infoLog += "☒ Video not first. \n"
|
|
}
|
|
videoIdx++
|
|
}
|
|
|
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio") {
|
|
if (subtitleIdx != "0") {
|
|
convert = true
|
|
response.infoLog += "☒ Audio not second. \n"
|
|
}
|
|
audioIdx++
|
|
if (file.ffProbeData.streams[i].channels == "2") {
|
|
if (audio6Idx != "0" || audio8Idx != "0") {
|
|
convert = true
|
|
response.infoLog += "☒ Audio 2ch not first. \n"
|
|
}
|
|
audio2Idx++
|
|
}
|
|
if (file.ffProbeData.streams[i].channels == "6") {
|
|
if (audio8Idx != "0") {
|
|
convert = true
|
|
response.infoLog += "☒ Audio 6ch not second. \n"
|
|
}
|
|
audio6Idx++
|
|
}
|
|
if (file.ffProbeData.streams[i].channels == "8") {
|
|
audio8Idx++
|
|
response.infoLog += "☒ Audio 8ch not last. \n"
|
|
}
|
|
}
|
|
|
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle") {
|
|
subtitleIdx++
|
|
}
|
|
} catch (err) { }
|
|
}
|
|
|
|
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
|
|
try {
|
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "video" && file.ffProbeData.streams[i].codec_name.toLowerCase() != "mjpeg") {
|
|
ffmpegCommandInsert += `-map 0:${i} `
|
|
}
|
|
} catch (err) { }
|
|
}
|
|
|
|
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
|
|
try {
|
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio" && file.ffProbeData.streams[i].channels == "2") {
|
|
ffmpegCommandInsert += `-map 0:${i} `
|
|
}
|
|
} catch (err) { }
|
|
}
|
|
|
|
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
|
|
try {
|
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio" && file.ffProbeData.streams[i].channels == "6") {
|
|
ffmpegCommandInsert += `-map 0:${i} `
|
|
}
|
|
} catch (err) { }
|
|
}
|
|
|
|
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
|
|
try {
|
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio" && file.ffProbeData.streams[i].channels == "8") {
|
|
ffmpegCommandInsert += `-map 0:${i} `
|
|
}
|
|
} catch (err) { }
|
|
}
|
|
|
|
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
|
|
try {
|
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio" && file.ffProbeData.streams[i].channels != "2" && file.ffProbeData.streams[i].channels != "6" && file.ffProbeData.streams[i].channels != "8") {
|
|
ffmpegCommandInsert += `-map 0:${i} `
|
|
}
|
|
} catch (err) { }
|
|
}
|
|
|
|
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
|
|
try {
|
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle") {
|
|
ffmpegCommandInsert += `-map 0:${i} `
|
|
}
|
|
} catch (err) { }
|
|
}
|
|
|
|
if (convert == true) {
|
|
response.processFile = true;
|
|
response.preset = `,${ffmpegCommandInsert} -c copy`
|
|
response.reQueueAfter = true;
|
|
response.infoLog += "☒ Streams are out of order, reorganizing streams. Video, Audio, Subtitles. \n"
|
|
} else {
|
|
response.infoLog += "☑ Streams are in expected order. \n "
|
|
response.processFile = false;
|
|
}
|
|
return response
|
|
|
|
}
|
|
module.exports.details = details;
|
|
module.exports.plugin = plugin; |