mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-02-05 01:58:36 -06:00
FF-1667: ConvertAudio AAC High Efficiency not used on fixed bitrate
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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) =>
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// A logger for tests that stores the logs in memory
|
||||
/// </summary>
|
||||
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<string> Messages = new();
|
||||
|
||||
internal class TestLogger : ILogger
|
||||
/// <summary>
|
||||
/// Writes an information log message
|
||||
/// </summary>
|
||||
/// <param name="args">the log parameters</param>
|
||||
public void ILog(params object[] args)
|
||||
=> Log(LogType.Info, args);
|
||||
|
||||
/// <summary>
|
||||
/// Writes an debug log message
|
||||
/// </summary>
|
||||
/// <param name="args">the log parameters</param>
|
||||
public void DLog(params object[] args)
|
||||
=> Log(LogType.Debug, args);
|
||||
|
||||
/// <summary>
|
||||
/// Writes an warning log message
|
||||
/// </summary>
|
||||
/// <param name="args">the log parameters</param>
|
||||
public void WLog(params object[] args)
|
||||
=> Log(LogType.Warning, args);
|
||||
|
||||
/// <summary>
|
||||
/// Writes an error log message
|
||||
/// </summary>
|
||||
/// <param name="args">the log parameters</param>
|
||||
public void ELog(params object[] args)
|
||||
=> Log(LogType.Error, args);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the tail of the log
|
||||
/// </summary>
|
||||
/// <param name="length">the number of messages to get</param>
|
||||
public string GetTail(int length = 50)
|
||||
{
|
||||
private List<string> Messages = new List<string>();
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the log
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
=> Messages.Clear();
|
||||
if (Messages.Count <= length)
|
||||
return string.Join(Environment.NewLine, Messages);
|
||||
return string.Join(Environment.NewLine, Messages.TakeLast(50));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs a message
|
||||
/// </summary>
|
||||
/// <param name="type">the type of log to record</param>
|
||||
/// <param name="args">the arguments of the message</param>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an optional writer
|
||||
/// </summary>
|
||||
public Action<string> Writer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the entire log as a string
|
||||
/// </summary>
|
||||
/// <returns>the entire log</returns>
|
||||
public override string ToString()
|
||||
=> string.Join(Environment.NewLine, Messages);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the log contains the text
|
||||
/// </summary>
|
||||
/// <param name="text">the text to check for</param>
|
||||
/// <returns>true if it contains it, otherwise false</returns>
|
||||
public bool Contains(string text)
|
||||
=> Messages.Any(x => x.Contains(text));
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -367,7 +367,7 @@ public class LocalFileService : IFileService
|
||||
|
||||
public Result<long> DirectorySize(string path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Result<bool> SetCreationTimeUtc(string path, DateTime date)
|
||||
|
||||
@@ -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");
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user