Merge pull request #108 from Migz93/master

Migz Plugins
make-only-subtitle-default
HaveAGitGat 5 years ago committed by GitHub
commit 3286b51dcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,8 +5,8 @@ function details() {
Name: "Migz-Transcode Using Nvidia GPU & FFMPEG", Name: "Migz-Transcode Using Nvidia GPU & FFMPEG",
Type: "Video", Type: "Video",
Operation: "Transcode", 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`, 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.7", Version: "2.8",
Link: Link:
"https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_Migz1FFMPEG.js", "https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_Migz1FFMPEG.js",
Tags: "pre-processing,ffmpeg,video only,nvenc h265,configurable", 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++) { for (var i = 0; i < file.ffProbeData.streams.length; i++) {
// Check if stream is a video. // Check if stream is a video.
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "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") { if (file.ffProbeData.streams[i].codec_name == "mjpeg" || file.ffProbeData.streams[i].codec_name == "png") {
extraArguments += `-map -v:${videoIdx} `; 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 ( 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 file.container == inputs.container
) { ) {
response.processFile = false; 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; 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 ( 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}" 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.preset = `, -map 0 -c copy ${extraArguments}`;
response.processFile = true; response.processFile = true;
return response; return response;
@ -242,13 +242,11 @@ function plugin(file, librarySettings, inputs) {
response.preset = `-c:v vc1_cuvid`; response.preset = `-c:v vc1_cuvid`;
} else if (file.video_codec_name == "vp8") { } else if (file.video_codec_name == "vp8") {
response.preset = `-c:v vp8_cuvid`; 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.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.processFile = true;
response.infoLog += `☒File is not hevc. Transcoding. \n`; response.infoLog += `☒File is not hevc or vp9. Transcoding. \n`;
return response; return response;
} }
module.exports.details = details; module.exports.details = details;

@ -5,8 +5,8 @@ function details() {
Name: "Migz-Transcode Using CPU & FFMPEG", Name: "Migz-Transcode Using CPU & FFMPEG",
Type: "Video", Type: "Video",
Operation: "Transcode", 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`, 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.6", Version: "1.7",
Link: Link:
"https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_Migz1FFMPEG_CPU.js", "https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_Migz1FFMPEG_CPU.js",
Tags: "pre-processing,ffmpeg,video only,configurable,h265", 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") { if (file.ffProbeData.streams[i].codec_name == "mjpeg" || file.ffProbeData.streams[i].codec_name == "png") {
extraArguments += `-map -v:${videoIdx} `; 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 ( 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 file.container == inputs.container
) { ) {
response.processFile = false; 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; 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 ( 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}" 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.preset = `, -map 0 -c copy ${extraArguments}`;
response.processFile = true; response.processFile = true;
return response; 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.preset += `,-map 0 -c:v libx265 ${bitrateSettings} -c:a copy -c:s copy -max_muxing_queue_size 9999 ${extraArguments}`;
response.processFile = true; response.processFile = true;
response.infoLog += `☒File is not hevc. Transcoding. \n`; response.infoLog += `☒File is not hevc or vp9. Transcoding. \n`;
return response; return response;
} }
module.exports.details = details; module.exports.details = details;

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

Loading…
Cancel
Save