From 4ecbf50c5243aa4c844e7d2e9e6b730ca82e39d0 Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Sat, 22 Feb 2020 08:44:05 +0000 Subject: [PATCH] new --- ...in_raf4_Floorpie_FFmpeg_Tiered_HEVC_MKV.js | 170 ++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 Community/Tdarr_Plugin_raf4_Floorpie_FFmpeg_Tiered_HEVC_MKV.js diff --git a/Community/Tdarr_Plugin_raf4_Floorpie_FFmpeg_Tiered_HEVC_MKV.js b/Community/Tdarr_Plugin_raf4_Floorpie_FFmpeg_Tiered_HEVC_MKV.js new file mode 100644 index 0000000..e7e5ad2 --- /dev/null +++ b/Community/Tdarr_Plugin_raf4_Floorpie_FFmpeg_Tiered_HEVC_MKV.js @@ -0,0 +1,170 @@ +function details() { + return { + id: "Tdarr_Plugin_raf4_Floorpie_FFmpeg_Tiered_HEVC_MKV", + Name: "FFmpeg Tiered HEVC MKV", + Type: "Video", + Operation:"Transcode", + Description: `[Contains built-in filter] This plugin uses different Handbrake transcoding settings for 480p,576p,720p and 1080p. If files are not in hevc they will be transcoded. The output container is mkv. \n\n`, + Version: "1.01", + Link: "", + Tags:"pre-processing,h265,video only," + } +} + +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: '.mkv', + handBrakeMode: false, + FFmpegMode: true, + reQueueAfter: true, + infoLog: '' + } + +//check if the file is a video, if not the function will be stopped immediately + if (file.fileMedium !== "video") { + response.processFile = false + response.infoLog += "☒File is not a video! \n" + return response + } else { + response.infoLog += "☑File is a video! \n" + } + +//check if the file is already hevc, it will not be transcoded if true and the function will be stopped immediately + if (file.ffProbeData.streams[0].codec_name == 'hevc') { + response.processFile = false + response.infoLog += "☑File is already in hevc! \n" + return response + } + +//file will be encoded if the resolution is 480p or 576p +//codec will be checked so it can be transcoded correctly + if(file.video_resolution === "480p" || file.video_resolution === "576p" ) { + if (file.video_codec_name == 'h263') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27' + } + else if (file.video_codec_name == 'h264') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27' + } + else if (file.video_codec_name == 'mjpeg') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27' + } + else if (file.video_codec_name == 'mpeg1') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27' + } + else if (file.video_codec_name == 'mpeg2') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27' + } + else if (file.video_codec_name == 'mpeg4') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27' + } + else if (file.video_codec_name == 'vc1') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27' + } + else if (file.video_codec_name == 'vp8') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27' + } + else if (file.video_codec_name == 'vp9') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27' + } + else { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27' + } + + transcode = 1; + } + +//file will be encoded if the resolution is 720p +//codec will be checked so it can be transcoded correctly + if(file.video_resolution === "720p") { + if (file.video_codec_name == 'h263') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25' + } + else if (file.video_codec_name == 'h264') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25' + } + else if (file.video_codec_name == 'mjpeg') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25' + } + else if (file.video_codec_name == 'mpeg1') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25' + } + else if (file.video_codec_name == 'mpeg2') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25' + } + else if (file.video_codec_name == 'mpeg4') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25' + } + else if (file.video_codec_name == 'vc1') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25' + } + else if (file.video_codec_name == 'vp8') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25' + } + else if (file.video_codec_name == 'vp9') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25' + } + else { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25' + } + + transcode = 1; + } + +//file will be encoded if the resolution is 1080p +//codec will be checked so it can be transcoded correctly + if(file.video_resolution === "1080p") { + if (file.video_codec_name == 'h263') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23' + } + else if (file.video_codec_name == 'h264') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23' + } + else if (file.video_codec_name == 'mjpeg') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23' + } + else if (file.video_codec_name == 'mpeg1') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23' + } + else if (file.video_codec_name == 'mpeg2') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23' + } + else if (file.video_codec_name == 'mpeg4') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23' + } + else if (file.video_codec_name == 'vc1') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23' + } + else if (file.video_codec_name == 'vp8') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23' + } + else if (file.video_codec_name == 'vp9') { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23' + } + else { + response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23' + } + + transcode = 1; + } + +//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 += `☒File is ${file.video_resolution} but is not hevc!\n` + response.infoLog += `☒File will be transcoded!\n` + } + + return response +} + +module.exports.details = details; + +module.exports.plugin = plugin; \ No newline at end of file