diff --git a/AudioNodes/Nodes/ConvertFlowElements/ConvertNode.cs b/AudioNodes/Nodes/ConvertFlowElements/ConvertNode.cs index 852edc83..9b7da153 100644 --- a/AudioNodes/Nodes/ConvertFlowElements/ConvertNode.cs +++ b/AudioNodes/Nodes/ConvertFlowElements/ConvertNode.cs @@ -109,6 +109,11 @@ namespace FileFlows.AudioNodes "-ab", (bitrate == -1 ? GetSourceBitrate(args).ToString() : bitrate + "k") }); + if (Codec == "aac" && HighEfficiency) + { + extension = "m4a"; + ffArgs.AddRange(new[] { "-profile:a", "aac_he_v2" }); + } } if (SampleRate > 0) diff --git a/AudioNodes/Tests/AudioTestBase.cs b/AudioNodes/Tests/AudioTestBase.cs index a33569ed..8006e179 100644 --- a/AudioNodes/Tests/AudioTestBase.cs +++ b/AudioNodes/Tests/AudioTestBase.cs @@ -9,7 +9,7 @@ public abstract class AudioTestBase : TestBase { protected NodeParameters GetNodeParameters(string file, bool isDirectory = false) { - var args = new FileFlows.Plugin.NodeParameters(file, Logger, isDirectory, string.Empty, new LocalFileService()); + var args = new NodeParameters(file, Logger, isDirectory, string.Empty, new LocalFileService()); args.GetToolPathActual = (string tool) => { diff --git a/AudioNodes/Tests/ConvertTests.cs b/AudioNodes/Tests/ConvertTests.cs index 5401ef60..650cd0e9 100644 --- a/AudioNodes/Tests/ConvertTests.cs +++ b/AudioNodes/Tests/ConvertTests.cs @@ -112,6 +112,23 @@ public class ConvertTests : AudioTestBase } + [TestMethod] + public void Convert_AacHighEfficient() + { + var args = GetNodeParameters(TestFile_Mp3); + var af = new AudioFile(); + af.PreExecute(args); + af.Execute(args); // need to read the Audio info and set it + + ConvertToAAC ele = new(); + ele.HighEfficiency = true; + ele.Bitrate = 192; + ele.PreExecute(args); + int output = ele.Execute(args); + + Assert.AreEqual(1, output); + } + [TestMethod] public void Convert_Mp3ToMp3_Bitrate() { diff --git a/AudioNodes/Tests/EmbedArtworkTests.cs b/AudioNodes/Tests/EmbedArtworkTests.cs index 9520c6a6..d4b205b5 100644 --- a/AudioNodes/Tests/EmbedArtworkTests.cs +++ b/AudioNodes/Tests/EmbedArtworkTests.cs @@ -78,7 +78,6 @@ public class EmbedArtworkTests : AudioTestBase var result = convertNode.Execute(args); var log = Logger.ToString(); Assert.AreEqual(1, result); - Logger.Clear(); var ele = new EmbedArtwork(); var output = ele.Execute(args); diff --git a/AudioNodes/Tests/TestLogger.cs b/AudioNodes/Tests/TestLogger.cs index 919a0ca9..5be157f0 100644 --- a/AudioNodes/Tests/TestLogger.cs +++ b/AudioNodes/Tests/TestLogger.cs @@ -1,67 +1,95 @@ #if(DEBUG) -namespace FileFlows.AudioNodes.Tests +using FileFlows.Plugin; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FileFlows.AudioNodes.Tests; + +/// +/// A logger for tests that stores the logs in memory +/// +public class TestLogger : ILogger { - using FileFlows.Plugin; - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; + private readonly List Messages = new(); - internal class TestLogger : ILogger + /// + /// Writes an information log message + /// + /// the log parameters + public void ILog(params object[] args) + => Log(LogType.Info, args); + + /// + /// Writes an debug log message + /// + /// the log parameters + public void DLog(params object[] args) + => Log(LogType.Debug, args); + + /// + /// Writes an warning log message + /// + /// the log parameters + public void WLog(params object[] args) + => Log(LogType.Warning, args); + + /// + /// Writes an error log message + /// + /// the log parameters + public void ELog(params object[] args) + => Log(LogType.Error, args); + + /// + /// Gets the tail of the log + /// + /// the number of messages to get + public string GetTail(int length = 50) { - private List Messages = new List(); - - public void DLog(params object[] args) => Log("DBUG", args); - - public void ELog(params object[] args) => Log("ERRR", args); - - public void ILog(params object[] args) => Log("INFO", args); - - public void WLog(params object[] args) => Log("WARN", args); - - private void Log(string type, object[] args) - { - if (args == null || args.Length == 0) - return; - string message = type + " -> " + - string.Join(", ", args.Select(x => - x == null ? "null" : - x.GetType().IsPrimitive || x is string ? x.ToString() : - System.Text.Json.JsonSerializer.Serialize(x))); - Messages.Add(message); - } - - public bool Contains(string message) - { - if (string.IsNullOrWhiteSpace(message)) - return false; - - string log = string.Join(Environment.NewLine, Messages); - return log.Contains(message); - } - - public override string ToString() - { - return String.Join(Environment.NewLine, this.Messages.ToArray()); - } - - public string GetTail(int length = 50) - { - if (length <= 0) - length = 50; - if (Messages.Count <= length) - return string.Join(Environment.NewLine, Messages); - return string.Join(Environment.NewLine, Messages.TakeLast(length)); - } - - /// - /// Clears the log - /// - public void Clear() - => Messages.Clear(); + if (Messages.Count <= length) + return string.Join(Environment.NewLine, Messages); + return string.Join(Environment.NewLine, Messages.TakeLast(50)); } + + /// + /// Logs a message + /// + /// the type of log to record + /// the arguments of the message + private void Log(LogType type, params object[] args) + { + string message = type + " -> " + string.Join(", ", args.Select(x => + x == null ? "null" : + x.GetType().IsPrimitive ? x.ToString() : + x is string ? x.ToString() : + System.Text.Json.JsonSerializer.Serialize(x))); + Writer?.Invoke(message); + Messages.Add(message); + } + + /// + /// Gets or sets an optional writer + /// + public Action Writer { get; set; } + + /// + /// Returns the entire log as a string + /// + /// the entire log + public override string ToString() + => string.Join(Environment.NewLine, Messages); + + /// + /// Checks if the log contains the text + /// + /// the text to check for + /// true if it contains it, otherwise false + public bool Contains(string text) + => Messages.Any(x => x.Contains(text)); } #endif \ No newline at end of file diff --git a/AudioNodes/Tests/_LocalFileService.cs b/AudioNodes/Tests/_LocalFileService.cs index 43a20d62..e09fee2c 100644 --- a/AudioNodes/Tests/_LocalFileService.cs +++ b/AudioNodes/Tests/_LocalFileService.cs @@ -367,7 +367,7 @@ public class LocalFileService : IFileService public Result DirectorySize(string path) { - throw new NotImplementedException(); + return 0; } public Result SetCreationTimeUtc(string path, DateTime date) diff --git a/AudioNodes/Tests/_TestBase.cs b/AudioNodes/Tests/_TestBase.cs index cffa168e..d960ae90 100644 --- a/AudioNodes/Tests/_TestBase.cs +++ b/AudioNodes/Tests/_TestBase.cs @@ -39,6 +39,7 @@ public abstract class TestBase [TestInitialize] public void TestInitialize() { + Logger.Writer = (msg) => TestContext.WriteLine(msg); this.TestPath = this.TestPath?.EmptyAsNull() ?? (IsLinux ? "~/src/ff-files/test-files/audio" : @"d:\audio\testfiles"); this.TempPath = this.TempPath?.EmptyAsNull() ?? (IsLinux ? "~/src/ff-files/temp" : @"d:\audio\temp"); this.FfmpegPath = this.FfmpegPath?.EmptyAsNull() ?? (IsLinux ? "/usr/local/bin/ffmpeg" : @"C:\utils\ffmpeg\ffmpeg.exe"); diff --git a/FileFlows.Plugin.dll b/FileFlows.Plugin.dll index 73d037fe..8f56f74c 100644 Binary files a/FileFlows.Plugin.dll and b/FileFlows.Plugin.dll differ diff --git a/FileFlows.Plugin.pdb b/FileFlows.Plugin.pdb index 9387b8c8..cbcff748 100644 Binary files a/FileFlows.Plugin.pdb and b/FileFlows.Plugin.pdb differ