namespace FileFlows.VideoNodes.FfmpegBuilderNodes;
///
/// The FFmpeg Builder PreExecutor
///
public class PreExecutor
{
private readonly string code;
private readonly NodeParameters args;
///
/// Gets or sets the FFmpeg Arguments
///
public List Args { get; set; }
///
/// Constructs an instance of the pre-executor
///
/// the node parameters
/// the code to run
/// the current FFmpeg arguments
public PreExecutor(NodeParameters args, string code, List ffArgs)
{
this.args = args;
this.code = code;
this.Args = ffArgs;
}
///
/// Runs the pre-executor
///
/// if the execution was successful
public bool Run()
{
try
{
int exitCode = args.ScriptExecutor.Execute(new FileFlows.Plugin.Models.ScriptExecutionArgs
{
Args = args,
Code = code + "\n\n// automatically added return code\nreturn 1;",
AdditionalArguments = new ()
{
{ "FFmpeg", this }
}
});
args.Logger.ILog("PreExecute Exit Code: " + exitCode);
return exitCode >= 0;
}
catch (Exception ex)
{
args.Logger?.ELog("Failed executing pre-executor: " + ex.Message + Environment.NewLine + ex.StackTrace);
return false;
}
}
}