namespace FileFlows.VideoNodes;
///
/// Flow element to test a video is a specific codec
///
public abstract class VideoIsCodec: VideoNode
{
///
public override int Inputs => 1;
///
public override int Outputs => 2;
///
public override FlowElementType Type => FlowElementType.Logic;
///
public override string Icon => "fas fa-question";
///
/// Executes the flow element
///
/// the arguments
/// the output to call next
public override int Execute(NodeParameters args)
{
var videoInfo = GetVideoInfo(args);
if (videoInfo == null)
return args.Fail("Failed to retrieve video info");
var matches = videoInfo.VideoStreams.Any(x => CodecMatches(x.Codec));
args.Logger?.ILog($"Codec is {(matches ? "" : "not ")}a match");
return matches ? 1 : 2;
}
///
/// Performs the check if the codec matches, return true if a match, otherwise false
///
/// the codec to test
/// true if matches, otherwise false
protected abstract bool CodecMatches(string codec);
}