diff --git a/Community/Tdarr_Plugin_b38x_Nosirus_h265_aac_no_meta.js b/Community/Tdarr_Plugin_b38x_Nosirus_h265_aac_no_meta.js index 5508c70..26924d1 100644 --- a/Community/Tdarr_Plugin_b38x_Nosirus_h265_aac_no_meta.js +++ b/Community/Tdarr_Plugin_b38x_Nosirus_h265_aac_no_meta.js @@ -9,7 +9,7 @@ function details() { Type: "Video", Description: `If the file is not in h265 it will be trancoded into h265 with HandBrake using the following command '-e x265 -q 22 --encoder-preset slow --all-audio --all-subtitles copy:aac -E fdk_aac -Q 4 -x aq-mode=3'. If no aac, aac track will be added. Subtitles are kept. Metadata is removed.\n\n `, - Version: "1.00", + Version: "1.01", Link: "https://github.com/HaveAGitGat/Tdarr_Plugin_b38x_Nosirus_h265_aac_no_meta" } @@ -22,13 +22,13 @@ function plugin(file) { var response = { - processFile : false, - preset : '', - container : '.mp4', - handBrakeMode : false, - FFmpegMode : false, - reQueueAfter : false, - infoLog : '', + processFile: false, + preset: '', + container: '.mp4', + handBrakeMode: false, + FFmpegMode: false, + reQueueAfter: false, + infoLog: '', } @@ -43,42 +43,86 @@ function plugin(file) { return response - } else { + } else { - var jsonString = JSON.stringify(file) + if(file.ffProbeData.streams[0].codec_name != 'hevc'){ - if(file.ffProbeData.streams[0].codec_name != 'hevc'){ + response.processFile = true; + response.preset = ', -map 0 -c copy -c:v:0 libx265 -preset:v slow -pix_fmt yuv420p10le -x265-params "crf=22:aq-mode=3"' + response.container = '.mkv' + response.FFmpegMode = true + response.reQueueAfter = true; + response.infoLog += "☒File is not in hevc! \n" + return response + + }else{ + response.infoLog += "☑File is already in hevc! \n" + } + + + + + + var audioIdx = -1 + var ffmpegCommandInsert = '' + var hasnonAACTrack = false + + for (var i = 0; i < file.ffProbeData.streams.length; i++) { + + try { + if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio") { + audioIdx++ + } + } catch (err) { } + + + try { + if (file.ffProbeData.streams[i].codec_name !== 'aac' && file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio" ) { + ffmpegCommandInsert += ` -c:a:${audioIdx} aac -vbr 4 ` + hasnonAACTrack = true - response.processFile = true; - response.preset = '-e x265 -q 22 --encoder-preset slow --all-audio --all-subtitles copy:aac -E fdk_aac -Q 4 -x aq-mode=3' - response.container = '.mkv' - response.handBrakeMode =true - response.FFmpegMode = false - response.reQueueAfter = true; - response.infoLog += "☒File is not in hevc! \n" - return response + } + } catch (err) { } - }else{ - response.infoLog += "☑File is already in hevc! \n" - } + } + var ffmpegCommand = `,-map 0 -c:v copy -c:a copy ${ffmpegCommandInsert} -c:s copy -c:d copy` - if(file.meta.Title != undefined ){ + if (hasnonAACTrack == true) { + + response.processFile = true; + response.preset = ffmpegCommand + response.container = '.mkv' + response.handBrakeMode = false + response.FFmpegMode = true + response.reQueueAfter = true; + response.infoLog += "☒ File has audio which is not in aac! \n" + return response + + + + } else { + response.infoLog += "☑ All audio streams are in aac! \n" + } + + + + if (file.meta.Title != undefined) { response.infoLog += "☒File has title metadata \n" - response.preset = ',-map_metadata -1 -c:v copy -c:a copy' + response.preset = ',-metadata title="" -metadata comment="" -map 0 -c copy' + response.container = '.mkv' response.reQueueAfter = true; response.processFile = true; response.FFmpegMode = true return response - }else{ + } else { response.infoLog += "☑File has no title metadata \n" - } - + } - response.infoLog += "☑File meets conditions! \n" - return response + response.infoLog += "☑File meets conditions! \n" + return response } }