FF-1679: Fixed issue reading metadata in WAV files

This commit is contained in:
John Andrews
2024-07-31 08:45:15 +12:00
parent 4a22906ff0
commit 42c35b791c
4 changed files with 25 additions and 13 deletions

View File

@@ -32,7 +32,16 @@ public class AudioInfoHelper
if (result.IsFailed == false)
mi = result.Value;
else
mi = ReadMetaData(filename);
{
try
{
mi = ReadMetaData(filename);
}
catch (Exception)
{
mi = new AudioInfo();
}
}
try
{
@@ -363,9 +372,10 @@ public class AudioInfoHelper
public void ParseFileNameInfo(string filename, AudioInfo mi)
{
using var tfile = TagLib.File.Create(filename);
try
{
using var tfile = TagLib.File.Create(filename);
var fileInfo = new System.IO.FileInfo(filename);
bool dirty = false;
@@ -458,10 +468,6 @@ public class AudioInfoHelper
{
Logger?.WLog("Failed parsing Audio info from filename: " + ex.Message + Environment.NewLine + ex.StackTrace);
}
finally
{
tfile.Dispose();
}
}
}

View File

@@ -32,19 +32,25 @@ public class AudioInfoTests: AudioTestBase
[TestMethod]
public void AudioInfo_NormalTrack()
{
const string file = @"\\oracle\Audio\Taylor Swift\Speak Now\Taylor Swift - Speak Now - 08 - Never Grow Up.mp3";
const string ffmpegExe = @"C:\utils\ffmpeg\ffmpeg.exe";
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger(), false, string.Empty, null);;
args.GetToolPathActual = (string tool) => ffmpegExe;
args.TempPath = @"D:\music\temp";
var AudioInfo = new AudioInfoHelper(ffmpegExe, ffprobe, args.Logger).Read(args.WorkingFile);
var args = GetNodeParameters(file, false);
var AudioInfo = new AudioInfoHelper(ffmpeg, ffprobe, args.Logger).Read(args.WorkingFile);
Assert.AreEqual(8, AudioInfo.Value.Track);
}
[TestMethod]
public void AudioInfo_LargeWav()
{
string file = Path.Combine(TestPath, "large-wav.wav");
var args = GetNodeParameters(file, false);
var AudioInfo = new AudioInfoHelper(ffmpeg, ffprobe, args.Logger).Read(args.WorkingFile);
Assert.AreEqual(96000, AudioInfo.Value.Frequency);
}
[TestMethod]
public void AudioInfo_GetMetaData()
{