diff --git a/Community/Tdarr_Plugin_MC93_Migz1FFMPEG.js b/Community/Tdarr_Plugin_MC93_Migz1FFMPEG.js index e42c1fe..381d69c 100644 --- a/Community/Tdarr_Plugin_MC93_Migz1FFMPEG.js +++ b/Community/Tdarr_Plugin_MC93_Migz1FFMPEG.js @@ -5,7 +5,7 @@ function details() { Name: "Migz-Transcode Using Nvidia GPU & FFMPEG", Type: "Video", Operation:"Transcode", - Description: `[TESTING]Files will be transcoded using Nvidia GPU with ffmpeg, settings are dependant on current file size. NVDEC & NVENC compatable GPU required. \n\n`, + Description: `[TESTING]Files will be transcoded 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.00", Link: "", Inputs: [ @@ -34,8 +34,6 @@ function plugin(file, librarySettings, inputs) { infoLog: '' } - var bitrateSettings = "" - if (inputs.container == "") { response.infoLog += "☒Container has not been configured within plugin settings, please configure required options. Skipping this plugin. \n" response.processFile = false @@ -49,8 +47,27 @@ function plugin(file, librarySettings, inputs) { response.infoLog += "☒File is not a video. \n" return response } + + if (typeof file.meta.Duration != 'undefined') { + var duration = (file.meta.Duration * 0.0166667) + } else { + var duration = (file.ffProbeData.streams[0].duration * 0.0166667) + } + + var bitrateSettings = "" + var filesize = (file.file_size / 1000) + var targetBitrate = ~~((file.file_size / (duration * 0.0075)) / 2) + var minimumBitrate = ~~(targetBitrate * 0.7) + var maximumBitrate = ~~(targetBitrate * 1.3) - response.infoLog += `Container for video selected as ${inputs.container}. \n` + if (targetBitrate == "0") { + response.processFile = false + response.infoLog += "☒Target bitrate could not be calculated. Skipping this plugin. \n" + return response + } + + bitrateSettings = `-b:v ${targetBitrate}k -minrate ${minimumBitrate}k -maxrate ${maximumBitrate}k` + response.infoLog += `Container for output selected as ${inputs.container}. \n Current bitrate = ${~~(file.file_size / (duration * 0.0075))} \n Bitrate settings: \nTarget = ${targetBitrate} \nMinimum = ${minimumBitrate} \nMaximum = ${maximumBitrate} \n` if (file.ffProbeData.streams[0].codec_name == 'hevc' && file.container == inputs.container) { response.processFile = false @@ -93,29 +110,11 @@ function plugin(file, librarySettings, inputs) { response.preset = `-c:v vp9_cuvid` } - if (file.file_size >= "30000") { - bitrateSettings = "-b:v 30M -minrate 20M" - } else if (file.file_size < "30000" && file.file_size >= "25000") { - bitrateSettings = "-b:v 15M -minrate 10M -maxrate 20M" - } else if (file.file_size < "25000" && file.file_size >= "20000") { - bitrateSettings = "-b:v 12M -minrate 8M -maxrate 16M" - } else if (file.file_size < "20000" && file.file_size >= "15000") { - bitrateSettings = "-b:v 10M -minrate 7M -maxrate 13M" - } else if (file.file_size < "15000" && file.file_size >= "10000") { - bitrateSettings = "-b:v 8M -minrate 6M -maxrate 10M" - } else if (file.file_size < "10000" && file.file_size >= "8000") { - bitrateSettings = "-b:v 5M -minrate 3M -maxrate 8M" - } else if (file.file_size < "8000" && file.file_size >= "6000") { - bitrateSettings = "-b:v 4M -minrate 2M -maxrate 6M" - } else if (file.file_size < "6000" && file.file_size >= "2000") { - bitrateSettings = "-b:v 3M -minrate 1M -maxrate 5M" - } else if (file.file_size < "2000" && file.file_size >= "500") { - bitrateSettings = "-b:v 1M -minrate 500k -maxrate 2M" - } else if (file.file_size < "500" ) { - bitrateSettings = "-b:v 250K -minrate 100k -maxrate 500k" - } - - response.preset += `,-map 0 -c:v hevc_nvenc -rc:v vbr_hq ${bitrateSettings} -bufsize 2M -spatial_aq:v 1 -c:a copy -c:s copy -max_muxing_queue_size 4096` + if (inputs.container == "mkv") { + extraArguments = "-map -0:d " + } + + response.preset += `,-map 0 -c:v hevc_nvenc -rc:v vbr_hq ${bitrateSettings} -bufsize 2M -spatial_aq:v 1 -c:a copy -c:s copy -max_muxing_queue_size 4096 ${extraArguments}` response.processFile = true response.infoLog += `☒File is not hevc. Transcoding. \n` return response diff --git a/Community/Tdarr_Plugin_MC93_Migz2CleanTitle.js b/Community/Tdarr_Plugin_MC93_Migz2CleanTitle.js index ef3a9b3..0b84ce1 100644 --- a/Community/Tdarr_Plugin_MC93_Migz2CleanTitle.js +++ b/Community/Tdarr_Plugin_MC93_Migz2CleanTitle.js @@ -6,14 +6,13 @@ function details() { Type: "Video", Operation: "Clean", Description: `[TESTING]This plugin removes video title metadata if it exists. \n\n`, - Version: "1.00", + Version: "1.10", Link: "" } } function plugin(file) { var response = { - processFile : false, preset : '', container: '.' + file.container, @@ -35,18 +34,24 @@ function plugin(file) { return response } - if(file.meta.Title != undefined ){ - ffmpegCommandInsert += ` -metadata title="" ` - convert = true - } + try { + if (typeof file.meta.Title != 'undefined' ){ + ffmpegCommandInsert += ` -metadata title="" ` + response.infoLog += "1" + convert = true + } + } catch (err) { } for (var i = 0; i < file.ffProbeData.streams.length; i++) { if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "video") { - if (file.ffProbeData.streams[i].tags.title != undefined) { - ffmpegCommandInsert += ` -metadata:s:v:${videoIdx} title="" ` - convert = true - } - videoIdx++ + try { + if (typeof file.ffProbeData.streams[i].tags.title != 'undefined') { + ffmpegCommandInsert += ` -metadata:s:v:${videoIdx} title="" ` + response.infoLog += "2" + convert = true + } + } catch (err) { } + videoIdx++ } }