Migz Plugins

1) Bug fix for CleanTitle where if the title of an audio/substeam didn't exist it would exit that loop but not increment the Id of the track. Was causing the plugin to loop in some cases.

2) Modify both FFMPEG plugins to treat VP9 codec in a similiar way to HEVC. I.e if a file is already in VP9 codec don't transcode it to HEVC as VP9 is already heavily compressed in a similiar way to HEVC. Plugin itself still outputs files as HEVC
make-only-subtitle-default
Migz93 5 years ago
parent c23066ff4a
commit 6ba398eaf4

@ -5,8 +5,8 @@ function details() {
Name: "Migz-Transcode Using Nvidia GPU & FFMPEG",
Type: "Video",
Operation: "Transcode",
Description: `Files not in H265 will be transcoded into H265 using Nvidia GPU with ffmpeg, settings are dependant on file bitrate, working by the logic that H265 can support the same ammount of data at half the bitrate of H264. NVDEC & NVENC compatable GPU required. \n\n`,
Version: "2.7",
Description: `Files not in H265 will be transcoded into H265 using Nvidia GPU with ffmpeg, settings are dependant on file bitrate, working by the logic that H265 can support the same ammount of data at half the bitrate of H264. NVDEC & NVENC compatable GPU required. \n This plugin will skip any files that are in the VP9 codec as these are already at a comparable compression level to H265. \n\n`,
Version: "2.8",
Link:
"https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_Migz1FFMPEG.js",
Tags: "pre-processing,ffmpeg,video only,nvenc h265,configurable",
@ -181,25 +181,25 @@ function plugin(file, librarySettings, inputs) {
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
// Check if stream is a video.
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "video") {
// Check if codec of stream is mjpeg/png, if so then remove this "video" stream. mjpeg/png are usually embedded pictures that can cause havoc with plugins.
// Check if codec of stream is mjpeg/png, if so then remove this "video" stream. mjpeg/png are usually embedded pictures that can cause havoc with plugins.
if (file.ffProbeData.streams[i].codec_name == "mjpeg" || file.ffProbeData.streams[i].codec_name == "png") {
extraArguments += `-map -v:${videoIdx} `;
}
// Check if codec of stream is hevc AND check if file.container matches inputs.container. If so nothing for plugin to do.
// Check if codec of stream is hevc or vp9 AND check if file.container matches inputs.container. If so nothing for plugin to do.
if (
file.ffProbeData.streams[i].codec_name == "hevc" &&
file.ffProbeData.streams[i].codec_name == "hevc" || file.ffProbeData.streams[i].codec_name == "vp9" &&
file.container == inputs.container
) {
response.processFile = false;
response.infoLog += `☑File is already hevc & in ${inputs.container}. \n`;
response.infoLog += `☑File is already hevc or vp9 & in ${inputs.container}. \n`;
return response;
}
// Check if codec of stream is hevc AND check if file.container does NOT match inputs.container. If so remux file.
// Check if codec of stream is hevc or vp9 AND check if file.container does NOT match inputs.container. If so remux file.
if (
file.ffProbeData.streams[i].codec_name == "hevc" &&
file.ffProbeData.streams[i].codec_name == "hevc" || file.ffProbeData.streams[i].codec_name == "vp9" &&
file.container != "${inputs.container}"
) {
response.infoLog += `☒File is hevc but is not in ${inputs.container} container. Remuxing. \n`;
response.infoLog += `☒File is hevc or vp9 but is not in ${inputs.container} container. Remuxing. \n`;
response.preset = `, -map 0 -c copy ${extraArguments}`;
response.processFile = true;
return response;
@ -242,13 +242,11 @@ function plugin(file, librarySettings, inputs) {
response.preset = `-c:v vc1_cuvid`;
} else if (file.video_codec_name == "vp8") {
response.preset = `-c:v vp8_cuvid`;
} else if (file.video_codec_name == "vp9") {
response.preset = `-c:v vp9_cuvid`;
}
response.preset += `,-map 0 -c:v hevc_nvenc -rc:v vbr_hq -cq:v 19 ${bitrateSettings} -spatial_aq:v 1 -rc-lookahead:v 32 -c:a copy -c:s copy -max_muxing_queue_size 9999 ${extraArguments}`;
response.processFile = true;
response.infoLog += `☒File is not hevc. Transcoding. \n`;
response.infoLog += `☒File is not hevc or vp9. Transcoding. \n`;
return response;
}
module.exports.details = details;

@ -5,8 +5,8 @@ function details() {
Name: "Migz-Transcode Using CPU & FFMPEG",
Type: "Video",
Operation: "Transcode",
Description: `Files not in H265 will be transcoded into H265 using CPU with ffmpeg, settings are dependant on file bitrate, working by the logic that H265 can support the same ammount of data at half the bitrate of H264. \n\n`,
Version: "1.6",
Description: `Files not in H265 will be transcoded into H265 using CPU with ffmpeg, settings are dependant on file bitrate, working by the logic that H265 can support the same ammount of data at half the bitrate of H264. \n This plugin will skip any files that are in the VP9 codec as these are already at a comparable compression level to H265.\n\n`,
Version: "1.7",
Link:
"https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_Migz1FFMPEG_CPU.js",
Tags: "pre-processing,ffmpeg,video only,configurable,h265",
@ -169,21 +169,21 @@ function plugin(file, librarySettings, inputs) {
if (file.ffProbeData.streams[i].codec_name == "mjpeg" || file.ffProbeData.streams[i].codec_name == "png") {
extraArguments += `-map -v:${videoIdx} `;
}
// Check if codec of stream is hevc AND check if file.container matches inputs.container. If so nothing for plugin to do.
// Check if codec of stream is hevc or vp9 AND check if file.container matches inputs.container. If so nothing for plugin to do.
if (
file.ffProbeData.streams[i].codec_name == "hevc" &&
file.ffProbeData.streams[i].codec_name == "hevc" || file.ffProbeData.streams[i].codec_name == "vp9" &&
file.container == inputs.container
) {
response.processFile = false;
response.infoLog += `☑File is already hevc & in ${inputs.container}. \n`;
response.infoLog += `☑File is already hevc or vp9 & in ${inputs.container}. \n`;
return response;
}
// Check if codec of stream is hevc AND check if file.container does NOT match inputs.container. If so remux file.
// Check if codec of stream is hevc or vp9 AND check if file.container does NOT match inputs.container. If so remux file.
if (
file.ffProbeData.streams[i].codec_name == "hevc" &&
file.ffProbeData.streams[i].codec_name == "hevc" || file.ffProbeData.streams[i].codec_name == "vp9" &&
file.container != "${inputs.container}"
) {
response.infoLog += `☒File is hevc but is not in ${inputs.container} container. Remuxing. \n`;
response.infoLog += `☒File is hevc or vp9 but is not in ${inputs.container} container. Remuxing. \n`;
response.preset = `, -map 0 -c copy ${extraArguments}`;
response.processFile = true;
return response;
@ -205,7 +205,7 @@ function plugin(file, librarySettings, inputs) {
response.preset += `,-map 0 -c:v libx265 ${bitrateSettings} -c:a copy -c:s copy -max_muxing_queue_size 9999 ${extraArguments}`;
response.processFile = true;
response.infoLog += `☒File is not hevc. Transcoding. \n`;
response.infoLog += `☒File is not hevc or vp9. Transcoding. \n`;
return response;
}
module.exports.details = details;

@ -6,7 +6,7 @@ function details() {
Type: "Video",
Operation: "Clean",
Description: `This plugin removes title metadata from video/audio/subtitles, if it exists. Video checking is mandatory, audio and subtitles are optional.\n\n`,
Version: "1.6",
Version: "1.7",
Link:
"https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_Migz2CleanTitle.js",
Tags: "pre-processing,ffmpeg,configurable",
@ -62,10 +62,10 @@ function plugin(file, librarySettings, inputs) {
var convert = false;
// Check if inputs.custom_title_matching has been configured. If it has then set variable
if (inputs.custom_title_matching != "")
try {
if (typeof inputs.custom_title_matching != "undefined")
{
var custom_title_matching = inputs.custom_title_matching.toLowerCase().split(",");
} catch (err) {}
}
// Check if file is a video. If it isn't then exit plugin.
if (file.fileMedium !== "video") {
@ -84,15 +84,16 @@ function plugin(file, librarySettings, inputs) {
// Go through each stream in the file.
for (var i = 0; i < file.ffProbeData.streams.length; i++)
try {
{
// Check if stream is a video.
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "video") {
// Check if stream title is not empty, if it's not empty set to "".
if (typeof file.ffProbeData.streams[i].tags.title != "undefined") {
if (typeof file.ffProbeData.streams[i].tags.title != "undefined")
try {
response.infoLog += `☒Video stream title is not empty, most likely junk metadata. Removing title from stream ${i} \n`;
ffmpegCommandInsert += ` -metadata:s:v:${videoIdx} title="" `;
convert = true;
}
} catch (err) {}
// Increment videoIdx.
videoIdx++;
}
@ -102,17 +103,24 @@ function plugin(file, librarySettings, inputs) {
file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio" &&
inputs.clean_audio.toLowerCase() == "true"
) {
if (file.ffProbeData.streams[i].tags.title.split(".").length - 1 > 3) {
response.infoLog += `☒More then 3 full stops detected in audio title, likely to be junk metadata. Removing title from stream ${i} \n`;
ffmpegCommandInsert += ` -metadata:s:a:${audioIdx} title="" `;
convert = true;
}
if (custom_title_matching.indexOf(file.ffProbeData.streams[i].tags.title.toLowerCase()) !== -1) {
response.infoLog += `☒Audio matched custom input. Removing title from stream ${i} \n`;
ffmpegCommandInsert += ` -metadata:s:a:${audioIdx} title="" `;
convert = true;
}
// Increment audioIdx.
if (typeof file.ffProbeData.streams[i].tags.title != "undefined") {
if (file.ffProbeData.streams[i].tags.title.split(".").length - 1 > 3)
try {
response.infoLog += `☒More then 3 full stops detected in audio title, likely to be junk metadata. Removing title from stream ${i} \n`;
ffmpegCommandInsert += ` -metadata:s:a:${audioIdx} title="" `;
convert = true;
} catch (err) {}
if (typeof inputs.custom_title_matching != "undefined")
try {
if (custom_title_matching.indexOf(file.ffProbeData.streams[i].tags.title.toLowerCase()) !== -1)
{
response.infoLog += `☒Audio matched custom input. Removing title from stream ${i} \n`;
ffmpegCommandInsert += ` -metadata:s:a:${audioIdx} title="" `;
convert = true;
}
} catch (err) {}
}
// Increment audioIdx.
audioIdx++;
}
@ -121,20 +129,26 @@ function plugin(file, librarySettings, inputs) {
file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle" &&
inputs.clean_subtitles.toLowerCase() == "true"
) {
if (file.ffProbeData.streams[i].tags.title.split(".").length - 1 > 3) {
response.infoLog += `☒More then 3 full stops detected in subtitle title, likely to be junk metadata. Removing title from stream ${i} \n`;
ffmpegCommandInsert += ` -metadata:s:s:${subtitleIdx} title="" `;
convert = true;
}
if (custom_title_matching.indexOf(file.ffProbeData.streams[i].tags.title.toLowerCase()) !== -1) {
response.infoLog += `☒Subtitle matched custom input. Removing title from stream ${i} \n`;
ffmpegCommandInsert += ` -metadata:s:s:${subtitleIdx} title="" `;
convert = true;
}
if (typeof file.ffProbeData.streams[i].tags.title != "undefined") {
if (file.ffProbeData.streams[i].tags.title.split(".").length - 1 > 3)
try {
response.infoLog += `☒More then 3 full stops detected in subtitle title, likely to be junk metadata. Removing title from stream ${i} \n`;
ffmpegCommandInsert += ` -metadata:s:s:${subtitleIdx} title="" `;
convert = true;
} catch (err) {}
if (typeof inputs.custom_title_matching != "undefined")
try {
if (custom_title_matching.indexOf(file.ffProbeData.streams[i].tags.title.toLowerCase()) !== -1) {
response.infoLog += `☒Subtitle matched custom input. Removing title from stream ${i} \n`;
ffmpegCommandInsert += ` -metadata:s:s:${subtitleIdx} title="" `;
convert = true;
}
} catch (err) {}
}
// Increment subtitleIdx.
subtitleIdx++;
}
} catch (err) {}
}
// Convert file if convert variable is set to true.
if (convert == true) {

Loading…
Cancel
Save