diff --git a/BasicNodes/File/DeleteSourceDirectory.cs b/BasicNodes/File/DeleteSourceDirectory.cs index b8534fc0..8d150895 100644 --- a/BasicNodes/File/DeleteSourceDirectory.cs +++ b/BasicNodes/File/DeleteSourceDirectory.cs @@ -59,19 +59,19 @@ namespace FileFlows.BasicNodes.File { args.Logger?.ILog("Checking directory to delete: " + path); DirectoryInfo dir = new DirectoryInfo(path); - if (dir.Parent.FullName.ToLower() == root.ToLower()) + if (dir.FullName.ToLower() == root.ToLower()) { args.Logger?.ILog("At root, stopping deleting: " + root); return 1; } - if (dir.Parent.FullName.Length <= root.Length) + if (dir.FullName.Length <= root.Length) { args.Logger?.ILog("At root2, stopping deleting: " + root); return 1; } if (deleteSubFolders == false && dir.GetDirectories().Any()) { - args.Logger?.ILog("Directory is contains subfolders, cannot delete: " + dir.FullName); + args.Logger?.ILog("Directory contains subfolders, cannot delete: " + dir.FullName); return 2; } diff --git a/BasicNodes/Tests/FunctionTests.cs b/BasicNodes/Tests/FunctionTests.cs index a5c2efc8..2dd42cff 100644 --- a/BasicNodes/Tests/FunctionTests.cs +++ b/BasicNodes/Tests/FunctionTests.cs @@ -466,6 +466,52 @@ return 1; Assert.AreEqual(1, result); Assert.AreEqual("hevc_qsv -preset slow -tune film -global_quality 19 -look_ahead 1", args.Variables["VideoCodecParameters"]); } + + [TestMethod] + public void Function_FFMPEG() + { + Function pm = new Function(); + var logger = new TestLogger(); + var args = new FileFlows.Plugin.NodeParameters(@"D:\videos\unprocessed\dummy.mkv", logger, false, string.Empty); + args.GetToolPathActual = (string name) => @"C:\utils\ffmpeg\ffmpeg.exe"; + args.TempPath = @"D:\videos\temp"; + pm.Code = @" +let output = Flow.TempPath + '/' + Flow.NewGuid() + '.mkv'; +let ffmpeg = Flow.GetToolPath('ffmpeg'); +let process = Flow.Execute({ + command: ffmpeg, + argumentList: [ + '-i', + Variables.file.FullName, + '-c:v', + 'libx265', + '-c:a:1', + 'aac', + '-ac', + '2', + '-filter:a:0', + '""acompressor = ratio = 4""', + + output + ] +}); + +if(process.standardOutput) + Logger.ILog('Standard output: ' + process.standardOutput); +if(process.starndardError) + Logger.ILog('Standard error: ' + process.starndardError); + +if(process.exitCode !== 0){ + Logger.ELog('Failed processing ffmpeg: ' + process.exitCode); + return -1; +} + + Flow.SetWorkingFile(output); +return 1; + ; "; + var result = pm.Execute(args); + Assert.AreEqual(1, result); + } } } diff --git a/VideoNodes/Tests/AudioNormalizationTests.cs b/VideoNodes/Tests/AudioNormalizationTests.cs index 3d3d4108..8a75dc81 100644 --- a/VideoNodes/Tests/AudioNormalizationTests.cs +++ b/VideoNodes/Tests/AudioNormalizationTests.cs @@ -68,7 +68,7 @@ namespace VideoNodes.Tests AudioNormalization node = new(); node.AllAudio = true; - node.Pattern = "commentary"; + node.Pattern = ""; node.NotMatching = true; //node.OutputFile = file + ".sup"; var args = new FileFlows.Plugin.NodeParameters(file, logger, false, string.Empty); @@ -81,6 +81,58 @@ namespace VideoNodes.Tests string log = logger.ToString(); Assert.AreEqual(1, output); } + + [TestMethod] + public void AudioNormalization_Pattern_Test3() + { + const string file = @"D:\videos\unprocessed\test_orig.mkv"; + var logger = new TestLogger(); + var vi = new VideoInfoHelper(@"C:\utils\ffmpeg\ffmpeg.exe", logger); + var vii = vi.Read(file); + + const string ffmpeg = @"C:\utils\ffmpeg\ffmpeg.exe"; + + AudioNormalization node = new(); + node.AllAudio = true; + node.Pattern = "flac"; + node.NotMatching = false; + //node.OutputFile = file + ".sup"; + var args = new FileFlows.Plugin.NodeParameters(file, logger, false, string.Empty); + args.GetToolPathActual = (string tool) => ffmpeg; + args.TempPath = @"D:\videos\temp"; + + new VideoFile().Execute(args); + + int output = node.Execute(args); + string log = logger.ToString(); + Assert.AreEqual(2, output); + } + + [TestMethod] + public void AudioNormalization_Pattern_Test4() + { + const string file = @"D:\videos\unprocessed\test_orig.mkv"; + var logger = new TestLogger(); + var vi = new VideoInfoHelper(@"C:\utils\ffmpeg\ffmpeg.exe", logger); + var vii = vi.Read(file); + + const string ffmpeg = @"C:\utils\ffmpeg\ffmpeg.exe"; + + AudioNormalization node = new(); + node.AllAudio = true; + //node.Pattern = "truehd"; + //node.NotMatching = false; + //node.OutputFile = file + ".sup"; + var args = new FileFlows.Plugin.NodeParameters(file, logger, false, string.Empty); + args.GetToolPathActual = (string tool) => ffmpeg; + args.TempPath = @"D:\videos\temp"; + + new VideoFile().Execute(args); + + int output = node.Execute(args); + string log = logger.ToString(); + Assert.AreEqual(1, output); + } } } diff --git a/VideoNodes/Tests/AudoTrackRemovalTests.cs b/VideoNodes/Tests/AudioTrackRemovalTests.cs similarity index 96% rename from VideoNodes/Tests/AudoTrackRemovalTests.cs rename to VideoNodes/Tests/AudioTrackRemovalTests.cs index 09c72dc4..71a9d1a7 100644 --- a/VideoNodes/Tests/AudoTrackRemovalTests.cs +++ b/VideoNodes/Tests/AudioTrackRemovalTests.cs @@ -11,7 +11,7 @@ namespace VideoNodes.Tests using System.Threading.Tasks; [TestClass] - public class AudoTrackRemovalTests + public class AudioTrackRemovalTests { [TestMethod] public void AudoTrackRemoval_Test_01()