FF-1362 - New Flow Element: Is 8 Bit

This commit is contained in:
John Andrews
2024-02-22 15:45:26 +13:00
parent bcf10d21e1
commit d09ac1804d
7 changed files with 274 additions and 1 deletions

View File

@@ -0,0 +1,65 @@
using FileFlows.VideoNodes.FfmpegBuilderNodes;
using FileFlows.VideoNodes.FfmpegBuilderNodes.Models;
using FileFlows.VideoNodes.Helpers;
namespace FileFlows.VideoNodes;
/// <summary>
/// Flow element to test if a video is 8/10/12/Unknown bit or not
/// </summary>
public class VideoBitCheck : VideoNode
{
/// <summary>
/// Gets the number of inputs
/// </summary>
public override int Inputs => 1;
/// <summary>
/// Gets the number of outputs
/// </summary>
public override int Outputs => 4;
/// <summary>
/// Gets the type of flow element
/// </summary>
public override FlowElementType Type => FlowElementType.Logic;
/// <summary>
/// Gets the help URL
/// </summary>
public override string HelpUrl => "https://fileflows.com/docs/plugins/video-nodes/logical-nodes/video-bit-check";
/// <summary>
/// Executes the flow element
/// </summary>
/// <param name="args">the arguments</param>
/// <returns>the output to call next</returns>
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;
}
}

View File

@@ -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);

View File

@@ -0,0 +1,54 @@
using FileFlows.VideoNodes.FfmpegBuilderNodes;
using FileFlows.VideoNodes.FfmpegBuilderNodes.Models;
using FileFlows.VideoNodes.Helpers;
namespace FileFlows.VideoNodes;
/// <summary>
/// Flow element to test if a video is 10 bit or not
/// </summary>
public class VideoIs10Bit : VideoNode
{
/// <summary>
/// Gets the number of inputs
/// </summary>
public override int Inputs => 1;
/// <summary>
/// Gets the number of outputs
/// </summary>
public override int Outputs => 2;
/// <summary>
/// Gets the type of flow element
/// </summary>
public override FlowElementType Type => FlowElementType.Logic;
/// <summary>
/// Gets the help URL
/// </summary>
public override string HelpUrl => "https://fileflows.com/docs/plugins/video-nodes/logical-nodes/video-is-10-bit";
/// <summary>
/// Executes the flow element
/// </summary>
/// <param name="args">the arguments</param>
/// <returns>the output to call next</returns>
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;
}
}

View File

@@ -0,0 +1,54 @@
using FileFlows.VideoNodes.FfmpegBuilderNodes;
using FileFlows.VideoNodes.FfmpegBuilderNodes.Models;
using FileFlows.VideoNodes.Helpers;
namespace FileFlows.VideoNodes;
/// <summary>
/// Flow element to test if a video is 12 bit or not
/// </summary>
public class VideoIs12Bit : VideoNode
{
/// <summary>
/// Gets the number of inputs
/// </summary>
public override int Inputs => 1;
/// <summary>
/// Gets the number of outputs
/// </summary>
public override int Outputs => 2;
/// <summary>
/// Gets the type of flow element
/// </summary>
public override FlowElementType Type => FlowElementType.Logic;
/// <summary>
/// Gets the help URL
/// </summary>
public override string HelpUrl => "https://fileflows.com/docs/plugins/video-nodes/logical-nodes/video-is-12-bit";
/// <summary>
/// Executes the flow element
/// </summary>
/// <param name="args">the arguments</param>
/// <returns>the output to call next</returns>
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;
}
}

View File

@@ -0,0 +1,54 @@
using FileFlows.VideoNodes.FfmpegBuilderNodes;
using FileFlows.VideoNodes.FfmpegBuilderNodes.Models;
using FileFlows.VideoNodes.Helpers;
namespace FileFlows.VideoNodes;
/// <summary>
/// Flow element to test if a video is 8 bit or not
/// </summary>
public class VideoIs8Bit : VideoNode
{
/// <summary>
/// Gets the number of inputs
/// </summary>
public override int Inputs => 1;
/// <summary>
/// Gets the number of outputs
/// </summary>
public override int Outputs => 2;
/// <summary>
/// Gets the type of flow element
/// </summary>
public override FlowElementType Type => FlowElementType.Logic;
/// <summary>
/// Gets the help URL
/// </summary>
public override string HelpUrl => "https://fileflows.com/docs/plugins/video-nodes/logical-nodes/video-is-8-bit";
/// <summary>
/// Executes the flow element
/// </summary>
/// <param name="args">the arguments</param>
/// <returns>the output to call next</returns>
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;
}
}

View File

@@ -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", "-"
}

View File

@@ -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",