using FileFlows.VideoNodes.FfmpegBuilderNodes.Models;
namespace FileFlows.VideoNodes.FfmpegBuilderNodes;
///
/// Node that adds custom parameters to the FFMPEG Builder
///
public class FfmpegBuilderCustomParameters : FfmpegBuilderNode
{
///
/// Gets the Help URL for this node
///
public override string HelpUrl => "https://fileflows.com/docs/plugins/video-nodes/ffmpeg-builder/custom-parameters";
///
/// Gets the icon for this node
///
public override string Icon => "fas fa-plus-square";
///
/// Gets the number of outputs for this node
///
public override int Outputs => 1;
///
/// Gets or sets the parameters to add
///
[TextVariable(1)]
[Required]
public string Parameters { get; set; }
///
/// Gets or sets if the video should be forcable encoded when these parameters are added
///
[Boolean(2)]
[DefaultValue(true)]
public bool ForceEncode { get; set; }
///
/// Executes the node
///
/// the node parameters
/// the output number to execute next
public override int Execute(NodeParameters args)
{
string parameters = args.ReplaceVariables(Parameters);
if (string.IsNullOrWhiteSpace(parameters))
return 1;
string[] split = Regex.Split(parameters, "(\"[^\"]+\"|[^\\s\"]+)");
foreach(var parameter in split)
{
if (string.IsNullOrWhiteSpace(parameter))
continue;
string actual = parameter;
if (parameter.StartsWith("\"") && parameter.EndsWith("\""))
actual = parameter[1..^1];
this.Model.CustomParameters.Add(actual);
}
this.Model.ForceEncode = ForceEncode;
return 1;
}
}