diff --git a/VideoNodes/LogicalNodes/VideoBitCheck.cs b/VideoNodes/LogicalNodes/VideoBitCheck.cs new file mode 100644 index 00000000..61e74d84 --- /dev/null +++ b/VideoNodes/LogicalNodes/VideoBitCheck.cs @@ -0,0 +1,65 @@ +using FileFlows.VideoNodes.FfmpegBuilderNodes; +using FileFlows.VideoNodes.FfmpegBuilderNodes.Models; +using FileFlows.VideoNodes.Helpers; + +namespace FileFlows.VideoNodes; + +/// +/// Flow element to test if a video is 8/10/12/Unknown bit or not +/// +public class VideoBitCheck : VideoNode +{ + /// + /// Gets the number of inputs + /// + public override int Inputs => 1; + /// + /// Gets the number of outputs + /// + public override int Outputs => 4; + /// + /// Gets the type of flow element + /// + public override FlowElementType Type => FlowElementType.Logic; + /// + /// Gets the help URL + /// + public override string HelpUrl => "https://fileflows.com/docs/plugins/video-nodes/logical-nodes/video-bit-check"; + + /// + /// Executes the flow element + /// + /// the arguments + /// the output to call next + public override int Execute(NodeParameters args) + { + var videoInfo = GetVideoInfo(args); + if (videoInfo == null) + { + args.FailureReason = "Failed to retrieve video info"; + args.Logger?.ELog(args.FailureReason); + return -1; + } + + bool is8Bit = videoInfo.VideoStreams?.Any(x => x.Bits == 8) == true; + if (is8Bit) + { + args.Logger?.ILog("Video is 12 bit"); + return 1; + } + bool is10Bit = videoInfo.VideoStreams?.Any(x => x.Bits == 10) == true; + if (is10Bit) + { + args.Logger?.ILog("Video is 10 bit"); + return 2; + } + bool is12Bit = videoInfo.VideoStreams?.Any(x => x.Bits == 12) == true; + if (is12Bit) + { + args.Logger?.ILog("Video is 12 bit"); + return 3; + } + args.Logger?.ILog("Video Bits unknonw"); + return 4; + } +} diff --git a/VideoNodes/LogicalNodes/VideoHasStream.cs b/VideoNodes/LogicalNodes/VideoHasStream.cs index c3c3e812..b72635d6 100644 --- a/VideoNodes/LogicalNodes/VideoHasStream.cs +++ b/VideoNodes/LogicalNodes/VideoHasStream.cs @@ -118,7 +118,11 @@ public class VideoHasStream : VideoNode { var videoInfo = GetVideoInfo(args); if (videoInfo == null) + { + args.FailureReason = "Failed to retrieve video info"; + args.Logger?.ELog(args.FailureReason); return -1; + } bool found = false; string title = args.ReplaceVariables(Title, stripMissing: true); diff --git a/VideoNodes/LogicalNodes/VideoIs10Bit.cs b/VideoNodes/LogicalNodes/VideoIs10Bit.cs new file mode 100644 index 00000000..752dc6a2 --- /dev/null +++ b/VideoNodes/LogicalNodes/VideoIs10Bit.cs @@ -0,0 +1,54 @@ +using FileFlows.VideoNodes.FfmpegBuilderNodes; +using FileFlows.VideoNodes.FfmpegBuilderNodes.Models; +using FileFlows.VideoNodes.Helpers; + +namespace FileFlows.VideoNodes; + +/// +/// Flow element to test if a video is 10 bit or not +/// +public class VideoIs10Bit : VideoNode +{ + /// + /// Gets the number of inputs + /// + public override int Inputs => 1; + /// + /// Gets the number of outputs + /// + public override int Outputs => 2; + /// + /// Gets the type of flow element + /// + public override FlowElementType Type => FlowElementType.Logic; + /// + /// Gets the help URL + /// + public override string HelpUrl => "https://fileflows.com/docs/plugins/video-nodes/logical-nodes/video-is-10-bit"; + + /// + /// Executes the flow element + /// + /// the arguments + /// the output to call next + public override int Execute(NodeParameters args) + { + var videoInfo = GetVideoInfo(args); + if (videoInfo == null) + { + args.FailureReason = "Failed to retrieve video info"; + args.Logger?.ELog(args.FailureReason); + return -1; + } + + bool is10Bit = videoInfo.VideoStreams?.Any(x => x.Bits == 10) == true; + if (is10Bit) + { + args.Logger?.ILog("Video is 10 bit"); + return 1; + } + + args.Logger?.ILog("Video is not 10 bit"); + return 2; + } +} diff --git a/VideoNodes/LogicalNodes/VideoIs12Bit.cs b/VideoNodes/LogicalNodes/VideoIs12Bit.cs new file mode 100644 index 00000000..59786620 --- /dev/null +++ b/VideoNodes/LogicalNodes/VideoIs12Bit.cs @@ -0,0 +1,54 @@ +using FileFlows.VideoNodes.FfmpegBuilderNodes; +using FileFlows.VideoNodes.FfmpegBuilderNodes.Models; +using FileFlows.VideoNodes.Helpers; + +namespace FileFlows.VideoNodes; + +/// +/// Flow element to test if a video is 12 bit or not +/// +public class VideoIs12Bit : VideoNode +{ + /// + /// Gets the number of inputs + /// + public override int Inputs => 1; + /// + /// Gets the number of outputs + /// + public override int Outputs => 2; + /// + /// Gets the type of flow element + /// + public override FlowElementType Type => FlowElementType.Logic; + /// + /// Gets the help URL + /// + public override string HelpUrl => "https://fileflows.com/docs/plugins/video-nodes/logical-nodes/video-is-12-bit"; + + /// + /// Executes the flow element + /// + /// the arguments + /// the output to call next + public override int Execute(NodeParameters args) + { + var videoInfo = GetVideoInfo(args); + if (videoInfo == null) + { + args.FailureReason = "Failed to retrieve video info"; + args.Logger?.ELog(args.FailureReason); + return -1; + } + + bool is12Bit = videoInfo.VideoStreams?.Any(x => x.Bits == 12) == true; + if (is12Bit) + { + args.Logger?.ILog("Video is 12 bit"); + return 1; + } + + args.Logger?.ILog("Video is not 12 bit"); + return 2; + } +} diff --git a/VideoNodes/LogicalNodes/VideoIs8Bit.cs b/VideoNodes/LogicalNodes/VideoIs8Bit.cs new file mode 100644 index 00000000..ee2b0775 --- /dev/null +++ b/VideoNodes/LogicalNodes/VideoIs8Bit.cs @@ -0,0 +1,54 @@ +using FileFlows.VideoNodes.FfmpegBuilderNodes; +using FileFlows.VideoNodes.FfmpegBuilderNodes.Models; +using FileFlows.VideoNodes.Helpers; + +namespace FileFlows.VideoNodes; + +/// +/// Flow element to test if a video is 8 bit or not +/// +public class VideoIs8Bit : VideoNode +{ + /// + /// Gets the number of inputs + /// + public override int Inputs => 1; + /// + /// Gets the number of outputs + /// + public override int Outputs => 2; + /// + /// Gets the type of flow element + /// + public override FlowElementType Type => FlowElementType.Logic; + /// + /// Gets the help URL + /// + public override string HelpUrl => "https://fileflows.com/docs/plugins/video-nodes/logical-nodes/video-is-8-bit"; + + /// + /// Executes the flow element + /// + /// the arguments + /// the output to call next + public override int Execute(NodeParameters args) + { + var videoInfo = GetVideoInfo(args); + if (videoInfo == null) + { + args.FailureReason = "Failed to retrieve video info"; + args.Logger?.ELog(args.FailureReason); + return -1; + } + + bool is8Bit = videoInfo.VideoStreams?.Any(x => x.Bits == 8) == true; + if (is8Bit) + { + args.Logger?.ILog("Video is 8 bit"); + return 1; + } + + args.Logger?.ILog("Video is not 8 bit"); + return 2; + } +} diff --git a/VideoNodes/LogicalNodes/VideoIsInterlaced.cs b/VideoNodes/LogicalNodes/VideoIsInterlaced.cs index b4447957..8aba14a7 100644 --- a/VideoNodes/LogicalNodes/VideoIsInterlaced.cs +++ b/VideoNodes/LogicalNodes/VideoIsInterlaced.cs @@ -48,6 +48,14 @@ public class VideoIsInterlaced : VideoNode return 2; } + var localFile = args.FileService.GetLocalPath(args.WorkingFile); + if (localFile.Failed(out string error)) + { + args.FailureReason = "Failed to get local file: " + error; + args.Logger?.ELog(args.FailureReason); + return -1; + } + var ffOutput = args.Execute(new() { Command = ffmpeg, @@ -55,7 +63,7 @@ public class VideoIsInterlaced : VideoNode ArgumentList = new[] { "-hide_banner", - "-i", args.WorkingFile, + "-i", localFile.Value, "-vf", "idet", "-f", "null", "-" } diff --git a/VideoNodes/VideoNodes.en.json b/VideoNodes/VideoNodes.en.json index 537fab62..e856d2a8 100644 --- a/VideoNodes/VideoNodes.en.json +++ b/VideoNodes/VideoNodes.en.json @@ -705,6 +705,40 @@ "ExtractAll-Help": "If all matching subtitles should be extracted." } }, + "VideoBitCheck": { + "Label": "Video Bit Check", + "Description": "Checks if a video if 8-Bit, 10-Bit, 12-Bit or unknown.", + "Ouputs": { + "1": "Video is 8-Bit", + "2": "Video is 10-Bit", + "3": "Video is 12-Bit", + "4": "Unknown" + } + }, + "VideoIs8Bit": { + "Label": "Video Is 8-Bit", + "Description": "Tests if a video file is 8-Bit", + "Outputs": { + "1": "Video is 8-Bit", + "2": "Video is not 8-Bit" + } + }, + "VideoIs10Bit": { + "Label": "Video Is 10-Bit", + "Description": "Tests if a video file is 10-Bit", + "Outputs": { + "1": "Video is 10-Bit", + "2": "Video is not 10-Bit" + } + }, + "VideoIs12Bit": { + "Label": "Video Is 12-Bit", + "Description": "Tests if a video file is 12-Bit", + "Outputs": { + "1": "Video is 12-Bit", + "2": "Video is not 12-Bit" + } + }, "VideoIsInterlaced": { "Label": "Video Is Interlaced", "Description": "Tests if a video file is interlaced",