mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2025-12-31 18:20:25 -06:00
updated FFMPEG node to not add input/ouput nodes
This commit is contained in:
@@ -26,7 +26,7 @@ namespace FileFlows.VideoNodes
|
||||
this.Logger = logger;
|
||||
}
|
||||
|
||||
public (bool successs, string output) Encode(string input, string output, List<string> arguments, bool dontAddInputFile = false)
|
||||
public (bool successs, string output) Encode(string input, string output, List<string> arguments, bool dontAddInputFile = false, bool dontAddOutputFile = false)
|
||||
{
|
||||
arguments ??= new List<string> ();
|
||||
|
||||
@@ -37,10 +37,13 @@ namespace FileFlows.VideoNodes
|
||||
arguments.Insert(2, "-y");
|
||||
}
|
||||
|
||||
if (arguments.Last() != "-")
|
||||
arguments.Add(output);
|
||||
else
|
||||
Logger.ILog("Last argument '-' skipping adding output file");
|
||||
if (dontAddOutputFile == false)
|
||||
{
|
||||
if (arguments.Last() != "-")
|
||||
arguments.Add(output);
|
||||
else
|
||||
Logger.ILog("Last argument '-' skipping adding output file");
|
||||
}
|
||||
|
||||
string argsString = String.Join(" ", arguments.Select(x => x.IndexOf(" ") > 0 ? "\"" + x + "\"" : x));
|
||||
Logger.ILog(new string('=', ("FFMpeg.Arguments: " + argsString).Length));
|
||||
|
||||
@@ -30,14 +30,14 @@ namespace VideoNodes.Tests
|
||||
node.CommandLine = "-i {workingFile} {SomeVars} -o {output}";
|
||||
node.Extension = ".mkv";
|
||||
|
||||
var results = node.GetFFMPEGArgs(args);
|
||||
var results = node.GetFFMPEGArgs(args, "file");
|
||||
Assert.AreEqual("-i", results[0]);
|
||||
Assert.AreEqual(args.WorkingFile, results[1]);
|
||||
Assert.AreEqual("i", results[2]);
|
||||
Assert.AreEqual("am", results[3]);
|
||||
Assert.AreEqual("batman", results[4]);
|
||||
Assert.AreEqual("-o", results[5]);
|
||||
Assert.IsTrue(results[6].EndsWith(".mkv"));
|
||||
Assert.AreEqual("file", results[6]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ namespace FileFlows.VideoNodes
|
||||
|
||||
private FFMpegEncoder Encoder;
|
||||
|
||||
protected bool Encode(NodeParameters args, string ffmpegExe, List<string> ffmpegParameters, string extension = "mkv", string outputFile = "", bool updateWorkingFile = true, bool dontAddInputFile = false)
|
||||
protected bool Encode(NodeParameters args, string ffmpegExe, List<string> ffmpegParameters, string extension = "mkv", string outputFile = "", bool updateWorkingFile = true, bool dontAddInputFile = false, bool dontAddOutputFile = false)
|
||||
{
|
||||
string output;
|
||||
return Encode(args, ffmpegExe, ffmpegParameters, out output, extension, outputFile, updateWorkingFile, dontAddInputFile);
|
||||
return Encode(args, ffmpegExe, ffmpegParameters, out output, extension, outputFile, updateWorkingFile, dontAddInputFile: dontAddInputFile, dontAddOutputFile: dontAddOutputFile);
|
||||
}
|
||||
|
||||
protected bool Encode(NodeParameters args, string ffmpegExe, List<string> ffmpegParameters, out string ouput, string extension = "mkv", string outputFile = "", bool updateWorkingFile = true, bool dontAddInputFile = false)
|
||||
protected bool Encode(NodeParameters args, string ffmpegExe, List<string> ffmpegParameters, out string ouput, string extension = "mkv", string outputFile = "", bool updateWorkingFile = true, bool dontAddInputFile = false, bool dontAddOutputFile = false)
|
||||
{
|
||||
if (string.IsNullOrEmpty(extension))
|
||||
extension = "mkv";
|
||||
@@ -46,7 +46,7 @@ namespace FileFlows.VideoNodes
|
||||
}
|
||||
}
|
||||
|
||||
var success = Encoder.Encode(args.WorkingFile, outputFile, ffmpegParameters, dontAddInputFile: dontAddInputFile);
|
||||
var success = Encoder.Encode(args.WorkingFile, outputFile, ffmpegParameters, dontAddInputFile: dontAddInputFile, dontAddOutputFile: dontAddOutputFile);
|
||||
args.Logger.ILog("Encoding successful: " + success.successs);
|
||||
if (success.successs && updateWorkingFile)
|
||||
{
|
||||
|
||||
@@ -21,10 +21,8 @@ namespace FileFlows.VideoNodes
|
||||
|
||||
public override string Icon => "far fa-file-video";
|
||||
|
||||
public List<string> GetFFMPEGArgs(NodeParameters args)
|
||||
public List<string> GetFFMPEGArgs(NodeParameters args, string outputFile)
|
||||
{
|
||||
string outputFile = Path.Combine(args.TempPath, Guid.NewGuid().ToString() + "." + Extension);
|
||||
|
||||
string cmdLine = args.ReplaceVariables(CommandLine);
|
||||
|
||||
List<string> ffArgs = cmdLine.SplitCommandLine().Select(x =>
|
||||
@@ -57,11 +55,18 @@ namespace FileFlows.VideoNodes
|
||||
if (string.IsNullOrEmpty(Extension))
|
||||
Extension = "mkv";
|
||||
|
||||
var ffArgs = GetFFMPEGArgs(args);
|
||||
string outputFile = Path.Combine(args.TempPath, Guid.NewGuid().ToString() + "." + Extension);
|
||||
var ffArgs = GetFFMPEGArgs(args, outputFile);
|
||||
|
||||
if (Encode(args, ffmpegExe, ffArgs) == false)
|
||||
if (Encode(args, ffmpegExe, ffArgs, updateWorkingFile: false, dontAddInputFile: true, dontAddOutputFile: true) == false)
|
||||
return -1;
|
||||
|
||||
if (File.Exists(outputFile))
|
||||
{
|
||||
args.Logger?.ILog("Output file exists, updating working file: " + outputFile);
|
||||
args.SetWorkingFile(outputFile);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user