diff --git a/Community/Tdarr_Plugin_ER01_Transcode audio and video with HW (PC and Mac).js b/Community/Tdarr_Plugin_ER01_Transcode audio and video with HW (PC and Mac).js index e52695c..cfab9f6 100644 --- a/Community/Tdarr_Plugin_ER01_Transcode audio and video with HW (PC and Mac).js +++ b/Community/Tdarr_Plugin_ER01_Transcode audio and video with HW (PC and Mac).js @@ -172,7 +172,9 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { // figure out final bitrate // Check if duration info is filled, if so times it by 0.0166667 to get time in minutes. // If not filled then get duration of stream 0 and do the same. - if (typeof file.meta.Duration !== 'undefined') { + if (parseFloat(file.ffProbeData?.format?.duration) > 0) { + duration = parseFloat(file.ffProbeData?.format?.duration) * 0.0166667; + } else if (typeof file.meta.Duration !== 'undefined') { duration = file.meta.Duration * 0.0166667; } else { duration = file.ffProbeData.streams[0].duration * 0.0166667; diff --git a/Community/Tdarr_Plugin_JB69_JBHEVCQSV_MinimalFile.js b/Community/Tdarr_Plugin_JB69_JBHEVCQSV_MinimalFile.js index 2b685a3..767018c 100644 --- a/Community/Tdarr_Plugin_JB69_JBHEVCQSV_MinimalFile.js +++ b/Community/Tdarr_Plugin_JB69_JBHEVCQSV_MinimalFile.js @@ -396,8 +396,15 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { streamBR = file.mediaInfo.track[MILoc].extra.FromStats_BitRate * 1; } + let duration = 0; + if (parseFloat(file.ffProbeData?.format?.duration) > 0) { + duration = parseFloat(file.ffProbeData?.format?.duration); + } else { + duration = file.meta.Duration; + } + response.infoLog - += `Video stream ${i}:${Math.floor(file.meta.Duration / 60)}:` + += `Video stream ${i}:${Math.floor(duration / 60)}:` + `${file.ffProbeData.streams[i].codec_name}${(bolSource10bit) ? '(10)' : ''}`; response.infoLog += `:${streamWidth}x${streamHeight}x${streamFPS}:${streamBR}bps \n`; diff --git a/Community/Tdarr_Plugin_JB69_JBHEVCQSZ_PostFix.js b/Community/Tdarr_Plugin_JB69_JBHEVCQSZ_PostFix.js index 50277de..e055894 100644 --- a/Community/Tdarr_Plugin_JB69_JBHEVCQSZ_PostFix.js +++ b/Community/Tdarr_Plugin_JB69_JBHEVCQSZ_PostFix.js @@ -269,7 +269,14 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { var intChapNum = 0; var strChapNum = ""; - for (var i = 0; i < file.meta.Duration; i += chapterlengthlong) { + let duration = 0; + if (parseFloat(file.ffProbeData?.format?.duration) > 0) { + duration = parseFloat(file.ffProbeData?.format?.duration) + } else { + duration = file.meta.Duration + } + + for (var i = 0; i < duration; i += chapterlengthlong) { intChapNum += 1; strChapNum = String(intChapNum).padStart(2, '0'); @@ -283,7 +290,8 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { intChapNum += 1; strChapNum = String(intChapNum).padStart(2, "0"); - var timeString = new Date((Math.floor(file.meta.Duration) - 1) * 1000).toISOString().substr(11, 12); + + var timeString = new Date((Math.floor(duration) - 1) * 1000).toISOString().substr(11, 12); strChapterFile += "CHAPTER" + strChapNum + "=" + timeString + "\n"; strChapterFile += "CHAPTER" + strChapNum + "NAME=CHAPTER " + intChapNum + "\n"; diff --git a/Community/Tdarr_Plugin_MC93_Migz1FFMPEG.js b/Community/Tdarr_Plugin_MC93_Migz1FFMPEG.js index a8e47dd..c6627e4 100644 --- a/Community/Tdarr_Plugin_MC93_Migz1FFMPEG.js +++ b/Community/Tdarr_Plugin_MC93_Migz1FFMPEG.js @@ -139,7 +139,9 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { // Check if duration info is filled, if so times it by 0.0166667 to get time in minutes. // If not filled then get duration of stream 0 and do the same. - if (typeof file.meta.Duration !== 'undefined') { + if (parseFloat(file.ffProbeData?.format?.duration) > 0) { + duration = parseFloat(file.ffProbeData?.format?.duration) * 0.0166667; + } else if (typeof file.meta.Duration !== 'undefined') { duration = file.meta.Duration * 0.0166667; } else { duration = file.ffProbeData.streams[0].duration * 0.0166667; diff --git a/Community/Tdarr_Plugin_MC93_Migz1FFMPEG_CPU.js b/Community/Tdarr_Plugin_MC93_Migz1FFMPEG_CPU.js index 6e68585..04ff7fc 100644 --- a/Community/Tdarr_Plugin_MC93_Migz1FFMPEG_CPU.js +++ b/Community/Tdarr_Plugin_MC93_Migz1FFMPEG_CPU.js @@ -118,7 +118,9 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { // Check if duration info is filled, if so times it by 0.0166667 to get time in minutes. // If not filled then get duration of stream 0 and do the same. - if (typeof file.meta.Duration !== 'undefined') { + if (parseFloat(file.ffProbeData?.format?.duration) > 0) { + duration = parseFloat(file.ffProbeData?.format?.duration) * 0.0166667; + } else if (typeof file.meta.Duration !== 'undefined') { duration = file.meta.Duration * 0.0166667; } else { duration = file.ffProbeData.streams[0].duration * 0.0166667; diff --git a/Community/Tdarr_Plugin_Mthr_VaapiHEVCTranscode.js b/Community/Tdarr_Plugin_Mthr_VaapiHEVCTranscode.js index 701aa70..4530e48 100644 --- a/Community/Tdarr_Plugin_Mthr_VaapiHEVCTranscode.js +++ b/Community/Tdarr_Plugin_Mthr_VaapiHEVCTranscode.js @@ -85,7 +85,16 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { // Bitrate = file size / (stream duration * .0075) // Calculations were made based on the formula from this site: // https://blog.frame.io/2017/03/06/calculate-video-bitrates/ - duration = (file.meta.Duration !== `undefined` ? file.meta.Duration : stream.duration) * 0.0166667; + + if (parseFloat(file.ffProbeData?.format?.duration) > 0) { + duration = parseFloat(file.ffProbeData?.format?.duration) * 0.0166667; + } else if(file.meta.Duration !== `undefined`){ + duration = file.meta.Duration* 0.0166667; + }else{ + duration = stream.duration * 0.0166667; + } + + currentBitrate = ~~(file.file_size / (duration * 0.0075)); targetBitrate = ~~(currentBitrate / 2); minimumBitrate = ~~(targetBitrate * 0.7); diff --git a/Community/Tdarr_Plugin_bsh1_Boosh_FFMPEG_QSV_HEVC.js b/Community/Tdarr_Plugin_bsh1_Boosh_FFMPEG_QSV_HEVC.js index 7035c3d..7793614 100644 --- a/Community/Tdarr_Plugin_bsh1_Boosh_FFMPEG_QSV_HEVC.js +++ b/Community/Tdarr_Plugin_bsh1_Boosh_FFMPEG_QSV_HEVC.js @@ -331,7 +331,9 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { // Check if duration info is filled, if so times it by 0.0166667 to get time in minutes. // If not filled then get duration of stream 0 and do the same. - if (typeof file.meta.Duration !== 'undefined') { + if (parseFloat(file.ffProbeData?.format?.duration) > 0) { + duration = parseFloat(file.ffProbeData?.format?.duration) * 0.0166667; + } else if (typeof file.meta.Duration !== 'undefined') { duration = file.meta.Duration * 0.0166667; } else { duration = file.ffProbeData.streams[0].duration * 0.0166667; diff --git a/Community/Tdarr_Plugin_drdd_standardise_all_in_one.js b/Community/Tdarr_Plugin_drdd_standardise_all_in_one.js index ea8dc7c..75330f3 100644 --- a/Community/Tdarr_Plugin_drdd_standardise_all_in_one.js +++ b/Community/Tdarr_Plugin_drdd_standardise_all_in_one.js @@ -142,6 +142,10 @@ class Configurator { * Returns the duration of the file in minutes. */ function getFileDurationInMinutes(file) { + if (parseFloat(file.ffProbeData?.format?.duration) > 0) { + return parseFloat(file.ffProbeData?.format?.duration) * 0.0166667; + } + return typeof file.meta.Duration != undefined ? file.meta.Duration * 0.0166667 : file.ffProbeData.streams[0].duration * 0.0166667; @@ -409,8 +413,8 @@ function buildVideoConfiguration(inputs, file, logger) { // eslint-disable-next-line no-unused-vars const plugin = (file, librarySettings, inputs, otherArguments) => { - - const lib = require('../methods/lib')(); + + const lib = require('../methods/lib')(); // eslint-disable-next-line no-unused-vars,no-param-reassign inputs = lib.loadDefaultValues(inputs, details); var response = { diff --git a/Community/Tdarr_Plugin_e5c3_CnT_Remove_Letterbox.js b/Community/Tdarr_Plugin_e5c3_CnT_Remove_Letterbox.js index d4b8266..2a47266 100644 --- a/Community/Tdarr_Plugin_e5c3_CnT_Remove_Letterbox.js +++ b/Community/Tdarr_Plugin_e5c3_CnT_Remove_Letterbox.js @@ -284,7 +284,14 @@ function crop_decider(file, crop_height) { function size_check(file, min_bitrate) { const fs = require("fs"); - var duration = file.meta.Duration; //duration of video in seconds + + let duration = 0; + if (parseFloat(file.ffProbeData?.format?.duration) > 0) { + duration = parseFloat(file.ffProbeData?.format?.duration) + }else{ + duration = file.meta.Duration; //duration of video in seconds + } + var source = file.meta.SourceFile; //source file var stats = fs.statSync(source); var size = stats["size"] / 1000000000;