From 606ca243b3b66156591799ce7ed7455c6916b677 Mon Sep 17 00:00:00 2001 From: Christian Crill Date: Mon, 25 Nov 2019 01:01:01 -0600 Subject: [PATCH] Created slow,fast,veryfast Updated names to reflect Subs being kept --- ...0ab_TheRealShadoh_FFmpeg_Subs_H264_Fast.js | 164 ++++++++++++++++++ ..._TheRealShadoh_FFmpeg_Subs_H264_Medium.js} | 8 +- ...0ab_TheRealShadoh_FFmpeg_Subs_H264_Slow.js | 163 +++++++++++++++++ ...TheRealShadoh_FFmpeg_Subs_H264_VeryFast.js | 163 +++++++++++++++++ 4 files changed, 494 insertions(+), 4 deletions(-) create mode 100644 Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Fast.js rename Community/{Tdarr_Plugin_z0ab_TheRealShadoh_FFMPEG_H264_Medium.js => Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Medium.js} (93%) create mode 100644 Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Slow.js create mode 100644 Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_VeryFast.js diff --git a/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Fast.js b/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Fast.js new file mode 100644 index 0000000..2219c43 --- /dev/null +++ b/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Fast.js @@ -0,0 +1,164 @@ + + + +function details() { + + return { + id: "Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Fast.js", + Name: "TheRealShadoh FFmpeg Subs Fast, video MP4, audio AAC, keep subs. ", + Type: "Video", + Description: `[Contains built-in filter] This plugin transcodes into H264 using FFmpeg's 'Fast' preset if the file is not in H264 already. It maintains all subtitles. It removes metadata (if a title exists), and maintains all audio tracks. The output container is MP4. \n\n +`, + Version: "1.00", + Link: "https://github.com/TheRealShadoh/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Fast.js" + } + +} + +function plugin(file) { + + + //Must return this object + + var response = { + + processFile : false, + preset : '', + container : '.mp4', + handBrakeMode : false, + FFmpegMode : false, + FFmpegMode : false, + reQueueAfter : false, + infoLog : '', + + } + + if (file.fileMedium !== "video"){ + + + console.log("File is not video") + + response.infoLog += "☒File is not video \n" + response.processFile = false; + + return response + + } else { + + var jsonString = JSON.stringify(file) + + + var hasSubs = false + + + for (var i = 0; i < file.ffProbeData.streams.length; i++) { + + try { + + if(file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle"){ + + hasSubs = true + + } + } catch (err) { } + } + + + if(file.ffProbeData.streams[0].codec_name != 'h264'){ + + response.infoLog += "☒File is not in h264! \n" + response.preset = ', -map_metadata -1 -map 0:v -map 0:s? -map 0:a -c:v libx264 -preset fast -c:a aac -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + + }else{ + response.infoLog += "☑File is already in h264! \n" + } + + + /// + + if((file.meta.Title != "undefined") && !jsonString.includes("aac") && hasSubs){ + + response.infoLog += "☒File has title metadata and no aac and subs \n" + response.preset = ', -map_metadata -1 -map 0:v -map 0:s? -map 0:a -c:v copy -c:a aac -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + } + + if(!jsonString.includes("aac") && hasSubs){ + + response.infoLog += "☒File has no aac track and has subs \n" + response.preset = ', -map 0:v -map 0:s? -map 0:a -c:v copy -c:a aac -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + } + + + if(file.meta.Title != "undefined" && hasSubs){ + + response.infoLog += "☒File has title and has subs \n" + response.preset = ', -map_metadata -1 -map 0:v -map 0:s? -map 0:a -c:v copy -c:a copy -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + } + + + + /// + if(file.meta.Title != undefined ){ + + response.infoLog += "☒File has title metadata \n" + response.preset = ', -map_metadata -1 -map 0:v -map 0:s? -map 0:a -c:v copy -c:a copy -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + }else{ + response.infoLog += "☑File has no title metadata" + } + + if(!jsonString.includes("aac")){ + + response.infoLog += "☒File has no aac track \n" + response.preset = ', -map 0:v -map 0:s? -map 0:a -c:v copy -c:a aac -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + + }else{ + response.infoLog += "☑File has aac track \n" + } + + if(hasSubs){ + + response.infoLog += "☒File has subs \n" + response.preset = ', -map 0:v -map 0:s? -map 0:a -c:v copy -c:a copy -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + + }else{ + response.infoLog += "☑File has no subs \n" + } + + + response.infoLog += "☑File meets conditions! \n" + return response + + } +} + +module.exports.details = details; + +module.exports.plugin = plugin; diff --git a/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFMPEG_H264_Medium.js b/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Medium.js similarity index 93% rename from Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFMPEG_H264_Medium.js rename to Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Medium.js index 2892a7e..5434681 100644 --- a/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFMPEG_H264_Medium.js +++ b/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Medium.js @@ -4,13 +4,13 @@ function details() { return { - id: "Tdarr_Plugin_z0ab_TheRealShadoh_FFMPEG_H264_Medium.js", - Name: "TheRealShadoh FFMPEG Medium, video MP4, audio AAC, keep subs. ", + id: "Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Medium.js", + Name: "TheRealShadoh FFmpeg Subs Medium, video MP4, audio AAC, keep subs. ", Type: "Video", - Description: `[Contains built-in filter] This plugin transcodes into H264 using FFMPEG's 'Medium' preset if the file is not in H264 already. It maintains all subtitles. It removes metadata (if a title exists), and maintains all audio tracks. The output container is MP4. \n\n + Description: `[Contains built-in filter] This plugin transcodes into H264 using FFmpeg's 'Medium' preset if the file is not in H264 already. It maintains all subtitles. It removes metadata (if a title exists), and maintains all audio tracks. The output container is MP4. \n\n `, Version: "1.00", - Link: "https://github.com/TheRealShadoh/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFMPEG_H264_Medium.js" + Link: "https://github.com/TheRealShadoh/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Medium.js" } } diff --git a/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Slow.js b/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Slow.js new file mode 100644 index 0000000..66f71ba --- /dev/null +++ b/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Slow.js @@ -0,0 +1,163 @@ + + + +function details() { + + return { + id: "Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Slow.js", + Name: "TheRealShadoh FFmpeg Subs Slow, video MP4, audio AAC, keep subs. ", + Type: "Video", + Description: `[Contains built-in filter] This plugin transcodes into H264 using FFmpeg's 'Slow' preset if the file is not in H264 already. It maintains all subtitles. It removes metadata (if a title exists), and maintains all audio tracks. The output container is MP4. \n\n +`, + Version: "1.00", + Link: "https://github.com/TheRealShadoh/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Slow.js" + } + +} + +function plugin(file) { + + + //Must return this object + + var response = { + + processFile : false, + preset : '', + container : '.mp4', + handBrakeMode : false, + FFmpegMode : false, + reQueueAfter : false, + infoLog : '', + + } + + if (file.fileMedium !== "video"){ + + + console.log("File is not video") + + response.infoLog += "☒File is not video \n" + response.processFile = false; + + return response + + } else { + + var jsonString = JSON.stringify(file) + + + var hasSubs = false + + + for (var i = 0; i < file.ffProbeData.streams.length; i++) { + + try { + + if(file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle"){ + + hasSubs = true + + } + } catch (err) { } + } + + + if(file.ffProbeData.streams[0].codec_name != 'h264'){ + + response.infoLog += "☒File is not in h264! \n" + response.preset = ', -map_metadata -1 -map 0:v -map 0:s? -map 0:a -c:v libx264 -preset slow -c:a aac -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + + }else{ + response.infoLog += "☑File is already in h264! \n" + } + + + /// + + if((file.meta.Title != "undefined") && !jsonString.includes("aac") && hasSubs){ + + response.infoLog += "☒File has title metadata and no aac and subs \n" + response.preset = ', -map_metadata -1 -map 0:v -map 0:s? -map 0:a -c:v copy -c:a aac -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + } + + if(!jsonString.includes("aac") && hasSubs){ + + response.infoLog += "☒File has no aac track and has subs \n" + response.preset = ', -map 0:v -map 0:s? -map 0:a -c:v copy -c:a aac -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + } + + + if(file.meta.Title != "undefined" && hasSubs){ + + response.infoLog += "☒File has title and has subs \n" + response.preset = ', -map_metadata -1 -map 0:v -map 0:s? -map 0:a -c:v copy -c:a copy -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + } + + + + /// + if(file.meta.Title != undefined ){ + + response.infoLog += "☒File has title metadata \n" + response.preset = ', -map_metadata -1 -map 0:v -map 0:s? -map 0:a -c:v copy -c:a copy -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + }else{ + response.infoLog += "☑File has no title metadata" + } + + if(!jsonString.includes("aac")){ + + response.infoLog += "☒File has no aac track \n" + response.preset = ', -map 0:v -map 0:s? -map 0:a -c:v copy -c:a aac -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + + }else{ + response.infoLog += "☑File has aac track \n" + } + + if(hasSubs){ + + response.infoLog += "☒File has subs \n" + response.preset = ', -map 0:v -map 0:s? -map 0:a -c:v copy -c:a copy -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + + }else{ + response.infoLog += "☑File has no subs \n" + } + + + response.infoLog += "☑File meets conditions! \n" + return response + + } +} + +module.exports.details = details; + +module.exports.plugin = plugin; diff --git a/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_VeryFast.js b/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_VeryFast.js new file mode 100644 index 0000000..6bbd312 --- /dev/null +++ b/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_VeryFast.js @@ -0,0 +1,163 @@ + + + +function details() { + + return { + id: "Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_VeryFast.js", + Name: "TheRealShadoh FFmpeg Subs VeryFast, video MP4, audio AAC, keep subs. ", + Type: "Video", + Description: `[Contains built-in filter] This plugin transcodes into H264 using FFmpeg's 'VeryFast' preset if the file is not in H264 already. It maintains all subtitles. It removes metadata (if a title exists), and maintains all audio tracks. The output container is MP4. \n\n +`, + Version: "1.00", + Link: "https://github.com/TheRealShadoh/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_z0ab_TheRealShadoh_FFmpeg_Subs_H264_Veryfast.js" + } + +} + +function plugin(file) { + + + //Must return this object + + var response = { + + processFile : false, + preset : '', + container : '.mp4', + handBrakeMode : false, + FFmpegMode : false, + reQueueAfter : false, + infoLog : '', + + } + + if (file.fileMedium !== "video"){ + + + console.log("File is not video") + + response.infoLog += "☒File is not video \n" + response.processFile = false; + + return response + + } else { + + var jsonString = JSON.stringify(file) + + + var hasSubs = false + + + for (var i = 0; i < file.ffProbeData.streams.length; i++) { + + try { + + if(file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle"){ + + hasSubs = true + + } + } catch (err) { } + } + + + if(file.ffProbeData.streams[0].codec_name != 'h264'){ + + response.infoLog += "☒File is not in h264! \n" + response.preset = ', -map_metadata -1 -map 0:v -map 0:s? -map 0:a -c:v libx264 -preset veryfast -c:a aac -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + + }else{ + response.infoLog += "☑File is already in h264! \n" + } + + + /// + + if((file.meta.Title != "undefined") && !jsonString.includes("aac") && hasSubs){ + + response.infoLog += "☒File has title metadata and no aac and subs \n" + response.preset = ', -map_metadata -1 -map 0:v -map 0:s? -map 0:a -c:v copy -c:a aac -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + } + + if(!jsonString.includes("aac") && hasSubs){ + + response.infoLog += "☒File has no aac track and has subs \n" + response.preset = ', -map 0:v -map 0:s? -map 0:a -c:v copy -c:a aac -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + } + + + if(file.meta.Title != "undefined" && hasSubs){ + + response.infoLog += "☒File has title and has subs \n" + response.preset = ', -map_metadata -1 -map 0:v -map 0:s? -map 0:a -c:v copy -c:a copy -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + } + + + + /// + if(file.meta.Title != undefined ){ + + response.infoLog += "☒File has title metadata \n" + response.preset = ', -map_metadata -1 -map 0:v -map 0:s? -map 0:a -c:v copy -c:a copy -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + }else{ + response.infoLog += "☑File has no title metadata" + } + + if(!jsonString.includes("aac")){ + + response.infoLog += "☒File has no aac track \n" + response.preset = ', -map 0:v -map 0:s? -map 0:a -c:v copy -c:a aac -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + + }else{ + response.infoLog += "☑File has aac track \n" + } + + if(hasSubs){ + + response.infoLog += "☒File has subs \n" + response.preset = ', -map 0:v -map 0:s? -map 0:a -c:v copy -c:a copy -c:s mov_text' + response.reQueueAfter = true; + response.processFile = true; + response.FFmpegMode = true + return response + + }else{ + response.infoLog += "☑File has no subs \n" + } + + + response.infoLog += "☑File meets conditions! \n" + return response + + } +} + +module.exports.details = details; + +module.exports.plugin = plugin;