mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2025-12-31 01:20:00 -06:00
fixing music files missing codec
This commit is contained in:
@@ -39,14 +39,14 @@ namespace FileFlows.MusicNodes
|
||||
try
|
||||
{
|
||||
|
||||
var videoInfo = new MusicInfoHelper(ffmpegExe, args.Logger).Read(args.WorkingFile);
|
||||
if (videoInfo.Duration == 0)
|
||||
var musicInfo = new MusicInfoHelper(ffmpegExe, args.Logger).Read(args.WorkingFile);
|
||||
if (musicInfo.Duration == 0)
|
||||
{
|
||||
args.Logger.ILog("Failed to load music information.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SetMusicInfo(args, videoInfo, Variables);
|
||||
SetMusicInfo(args, musicInfo, Variables);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,24 @@ namespace FileFlows.MusicNodes
|
||||
return mi;
|
||||
}
|
||||
|
||||
foreach(string line in output.Split('\n'))
|
||||
if (output.ToLower().Contains("mp3"))
|
||||
mi.Codec = "mp3";
|
||||
else if (output.ToLower().Contains("ogg"))
|
||||
mi.Codec = "ogg";
|
||||
else if (output.ToLower().Contains("flac"))
|
||||
mi.Codec = "flac";
|
||||
else if (output.ToLower().Contains("wav"))
|
||||
mi.Codec = "wav";
|
||||
else if (filename.ToLower().EndsWith(".mp3"))
|
||||
mi.Codec = "mp3";
|
||||
else if (filename.ToLower().EndsWith(".ogg"))
|
||||
mi.Codec = "ogg";
|
||||
else if (filename.ToLower().EndsWith(".flac"))
|
||||
mi.Codec = "flac";
|
||||
else if (filename.ToLower().EndsWith(".wav"))
|
||||
mi.Codec = "wav";
|
||||
|
||||
foreach (string line in output.Split('\n'))
|
||||
{
|
||||
int colonIndex = line.IndexOf(":");
|
||||
if(colonIndex < 1)
|
||||
|
||||
@@ -93,6 +93,26 @@ namespace FileFlows.MusicNodes.Tests
|
||||
|
||||
Assert.AreEqual(1, output);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Convert_Mp3_AlreadyMp3()
|
||||
{
|
||||
|
||||
const string file = @"D:\videos\music\13-the_cranberries-why.mp3";
|
||||
|
||||
ConvertAudio node = new();
|
||||
node.SkipIfCodecMatches = true;
|
||||
node.Codec = "mp3";
|
||||
|
||||
node.Bitrate = 192;
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger(), false, string.Empty);
|
||||
args.GetToolPathActual = (string tool) => @"C:\utils\ffmpeg\ffmpeg.exe";
|
||||
args.TempPath = @"D:\music\temp";
|
||||
new MusicFile().Execute(args); // need to read the music info and set it
|
||||
int output = node.Execute(args);
|
||||
|
||||
Assert.AreEqual(2, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user