diff --git a/BasicNodes/Scripting/BatScript.cs b/BasicNodes/Scripting/BatchScript.cs similarity index 92% rename from BasicNodes/Scripting/BatScript.cs rename to BasicNodes/Scripting/BatchScript.cs index 7a6497a6..72e038d6 100644 --- a/BasicNodes/Scripting/BatScript.cs +++ b/BasicNodes/Scripting/BatchScript.cs @@ -1,7 +1,5 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; -using System.Diagnostics; -using BasicNodes.Scripting; using FileFlows.Plugin; using FileFlows.Plugin.Attributes; @@ -10,12 +8,12 @@ namespace FileFlows.BasicNodes.Scripting; /// /// Flow element that executes a bat script /// -public class BatScript : ScriptBase +public class BatchScript : ScriptBase { /// public override string Icon => "svg:dos"; /// - public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/bat-script"; + public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/scripting/batch-script"; /// protected override ScriptLanguage Language => ScriptLanguage.Batch; diff --git a/BasicNodes/Scripting/CSharpScript.cs b/BasicNodes/Scripting/CSharpScript.cs index 889728b9..8224908e 100644 --- a/BasicNodes/Scripting/CSharpScript.cs +++ b/BasicNodes/Scripting/CSharpScript.cs @@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations; using FileFlows.Plugin; using FileFlows.Plugin.Attributes; -namespace BasicNodes.Scripting; +namespace FileFlows.BasicNodes.Scripting; /// /// Flow element that executes a CSharp script @@ -19,6 +19,9 @@ public class CSharpScript : ScriptBase /// protected override ScriptLanguage Language => ScriptLanguage.CSharp; + /// + public override string Group => "Scripting:1"; + /// /// Gets or sets the code to execute /// diff --git a/BasicNodes/Scripting/Function.cs b/BasicNodes/Scripting/Function.cs index f72b2dd1..46b262f1 100644 --- a/BasicNodes/Scripting/Function.cs +++ b/BasicNodes/Scripting/Function.cs @@ -19,10 +19,10 @@ public class Function : Node /// public override bool FailureNode => true; /// - public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/function"; + public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/scripting/function"; /// - public override string Group => "Scripting"; - + public override string Group => "Scripting:0"; + /// /// Gets or sets the number of outputs /// diff --git a/BasicNodes/Scripting/PowerShellScript.cs b/BasicNodes/Scripting/PowerShellScript.cs index c5f8ca1b..1996f818 100644 --- a/BasicNodes/Scripting/PowerShellScript.cs +++ b/BasicNodes/Scripting/PowerShellScript.cs @@ -1,7 +1,5 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; -using System.Diagnostics; -using BasicNodes.Scripting; using FileFlows.Plugin; using FileFlows.Plugin.Attributes; diff --git a/BasicNodes/Scripting/ScriptBase.cs b/BasicNodes/Scripting/ScriptBase.cs index d96132a3..9a21b481 100644 --- a/BasicNodes/Scripting/ScriptBase.cs +++ b/BasicNodes/Scripting/ScriptBase.cs @@ -2,7 +2,7 @@ using System.ComponentModel; using FileFlows.Plugin; using FileFlows.Plugin.Attributes; -namespace BasicNodes.Scripting; +namespace FileFlows.BasicNodes.Scripting; /// /// Base for a script @@ -46,6 +46,7 @@ public abstract class ScriptBase : Node var result = args.ScriptExecutor.Execute(new() { Args = args, + Logger = args.Logger, Code = Language is ScriptLanguage.CSharp or ScriptLanguage.JavaScript ? Code : args.ReplaceVariables(Code), ScriptType = ScriptType.Flow, Language = Language diff --git a/BasicNodes/Scripting/ShellScript.cs b/BasicNodes/Scripting/ShellScript.cs index 9e4d70b7..21c40026 100644 --- a/BasicNodes/Scripting/ShellScript.cs +++ b/BasicNodes/Scripting/ShellScript.cs @@ -1,6 +1,5 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; -using BasicNodes.Scripting; using FileFlows.Plugin; using FileFlows.Plugin.Attributes; diff --git a/BasicNodes/i18n/en.json b/BasicNodes/i18n/en.json index bce4658e..afa68a48 100644 --- a/BasicNodes/i18n/en.json +++ b/BasicNodes/i18n/en.json @@ -21,8 +21,8 @@ "1": "Library Folder" } }, - "BatScript": { - "Label": "Batch (.bat)", + "BatchScript": { + "Label": "Batch Script (.bat)", "Description": "Allows you to execute a batch (.bat) script in a Windows environment.", "Outputs": { "1": "returned 1", @@ -60,7 +60,7 @@ } }, "ShellScript": { - "Label": "Shell (.sh))", + "Label": "Shell Script (.sh)", "Description": "Allows you to execute a shell (.sh) script in a Unix-like environment.", "Outputs": { "1": "returned 1", @@ -79,7 +79,7 @@ } }, "PowerShellScript": { - "Label": "PowerShell (.ps1)", + "Label": "PowerShell Script (.ps1)", "Description": "Allows you to execute a PowerShell (.ps1) script in a Windows environment.", "Outputs": { "1": "returned 1", @@ -286,6 +286,7 @@ } }, "Function": { + "Label": "Function", "Outputs": { "1": "returned 1", "2": "returned 2", diff --git a/VideoNodes/VideoNodes/VideoNode.cs b/VideoNodes/VideoNodes/VideoNode.cs index 3789419d..1c18865b 100644 --- a/VideoNodes/VideoNodes/VideoNode.cs +++ b/VideoNodes/VideoNodes/VideoNode.cs @@ -186,6 +186,60 @@ namespace FileFlows.VideoNodes args.SetMetadata(metadata); } + private int Test(ILogger Logger) + { + + var MAX_BITRATE = 3_000_000; // bitrate is 3,000 KBps + + if(Variables.TryGetValue("vi.VideoInfo", out var oVideoInfo) == false || oVideoInfo is FileFlows.VideoNodes.VideoInfo videoInfo == false) + { + Logger.ILog("Failed to locate VideoInformation in variables"); + return -1; + } + Logger.ILog("Got video information."); + + var video = videoInfo.VideoStreams.FirstOrDefault(); + if(video == null) + { + Logger.ILog("No video streams detected."); + return -1; + } + +// get the video stream + var bitrate = video.Bitrate; + + if(bitrate < 1) + { + // video stream doesn't have bitrate information + // need to use the overall bitrate + var overall = videoInfo.Bitrate; + if(overall < 1) + return 0; // couldn't get overall bitrate either + + // overall bitrate includes all audio streams, so we try and subtract those + var calculated = overall; + if(videoInfo.AudioStreams.Count > 0) // check there are audio streams + { + foreach(var audio in videoInfo.AudioStreams) + { + if(audio.Bitrate > 0) + calculated -= audio.Bitrate; + else{ + // audio doesn't have bitrate either, so we just subtract 5% of the original bitrate + // this is a guess, but it should get us close + calculated -= (overall * 0.05f); + } + } + } + bitrate = calculated; + } + +// check if the bitrate is over the maximum bitrate + if(bitrate > MAX_BITRATE) + return 1; // it is, so call output 1 + return 2; // it isn't so call output 2 + } + protected VideoInfo GetVideoInfo(NodeParameters args, bool refreshIfFileChanged = true) { var vi = GetVideoInfoActual(args);