diff --git a/Community/Tdarr_Plugin_MC93_MigzImageRemoval.js b/Community/Tdarr_Plugin_MC93_MigzImageRemoval.js new file mode 100644 index 0000000..2fd4094 --- /dev/null +++ b/Community/Tdarr_Plugin_MC93_MigzImageRemoval.js @@ -0,0 +1,60 @@ +function details() { + return { + id: "Tdarr_Plugin_MC93_MigzImageRemoval", + Stage: "Pre-processing", + Name: "Migz-Remove image formats from file", + Type: "Video", + Operation:"Clean", + Description: `Identify any unwanted image formats in the file and remove those streams. MJPEG & PNG \n\n`, + Version: "1.0", + Link: "https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_MigzImageRemoval.js", + Tags:'pre-processing,ffmpeg,video only' + } +} + +function plugin(file, librarySettings, inputs) { + var response = { + processFile: false, + preset: '', + handBrakeMode: false, + container: '.' + file.container, + FFmpegMode: true, + reQueueAfter: true, + infoLog: '' + } + + if (file.fileMedium !== "video") { + response.processFile = false + response.infoLog += "☒File is not a video. \n" + return response + } + + var videoIdx = 0 + var extraArguments = "" + var convert = false + + for (var i = 0; i < file.ffProbeData.streams.length; i++) { + if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "video") { + if (file.ffProbeData.streams[i].codec_name == 'mjpeg' || file.ffProbeData.streams[i].codec_name == 'png') { + convert = true + extraArguments += `-map -v:${videoIdx} ` + } + videoIdx++ + } + } + + if (convert === true ) { + response.preset += `,-map 0 -c copy -max_muxing_queue_size 4096 ${extraArguments}` + response.infoLog += `☒File has image format stream, removing. \n` + response.processFile = true; + } else { + response.processFile = false; + response.infoLog += "☑File doesn't contain any unwanted image format streams.\n" + } + return response +} + + + +module.exports.details = details; +module.exports.plugin = plugin; diff --git a/Community/Tdarr_Plugin_d5d4_iiDrakeii_Not_A_Video_Mjpeg_Fix.js b/Community/Tdarr_Plugin_d5d4_iiDrakeii_Not_A_Video_Mjpeg_Fix.js deleted file mode 100644 index f226984..0000000 --- a/Community/Tdarr_Plugin_d5d4_iiDrakeii_Not_A_Video_Mjpeg_Fix.js +++ /dev/null @@ -1,78 +0,0 @@ -function details() { - return { - id: "Tdarr_Plugin_d5d4_iiDrakeii_Not_A_Video_Mjpeg_Fix", - Stage: "Pre-processing", - Name: "Mjpeg Stream False Not A Video Fixer", - Type: "Video", - Operation:"", - Description: `Checks if file is not a video file due to Mjpeg stream. Removes Mjpeg Stream \n\n`, - Version: "1.00", - Tags:'pre-processing,ffmpeg,' - } -} - -function plugin(file) { - var transcode = 0; //if this var changes to 1 the file will be transcoded -//default values that will be returned - var response = { - processFile: false, - preset: '', - container: '.mp4', - handBrakeMode: false, - FFmpegMode: false, - reQueueAfter: true, - infoLog: '' - } - response.container = '.' + file.container - - for (var i = 0; i < file.ffProbeData.streams.length; i++) { -//check for mjpeg streams and set the preset if mjpeg streams are found - try { - if ((file.ffProbeData.streams[i].codec_name.toLowerCase() == "mjpeg") && file.ffProbeData.streams[i].codec_type.toLowerCase() == "video" ) { - response.preset = `,-map 0 -map -0:v:1 -c:v copy -c:a copy -c:s copy` - response.infoLog = "☒File is not a video but has Mjpeg Stream! \n" - } - } - catch (err) { } - } - //If preset is not set check if file is video and stop (reque if it is a video) - if (response.preset != `,-map 0 -map -0:v:1 -c:v copy -c:a copy -c:s copy`) { - if (file.fileMedium !== "video") { - console.log("File is not video!") - response.infoLog += " File is not video\n" - response.processFile = false; - - return response - } - else { - response.infoLog += "☑File is a video Without Mjpeg! \n" - response.processFile = false - response.reQueueAfter = true - return response - } - } - //Process mjpeg removal if video found to not be a video and have mjpeg stream - else { - if (file.fileMedium !== "video") { - transcode = 1 - } - else { - response.infoLog += "☑File is a video With Mjpeg! \n" - response.processFile = false - response.reQueueAfter = true - return response - } - } -//check if the file is eligible for transcoding -//if true the neccessary response values will be changed - if (transcode == 1) { - response.processFile = true; - response.FFmpegMode = true - response.reQueueAfter = true; - response.infoLog += `Mjpeg Stream is being removed!\n` - } - - return response -} -module.exports.details = details; -module.exports.plugin = plugin;