diff --git a/AudioNodes/AudioInfo.cs b/AudioNodes/AudioInfo.cs index becafcea..4711ceba 100644 --- a/AudioNodes/AudioInfo.cs +++ b/AudioNodes/AudioInfo.cs @@ -16,6 +16,9 @@ namespace FileFlows.AudioNodes /// Gets or sets duration in SECONDS /// public long Duration { get; set; } + /// + /// Gets or sets the bitrate (in bytes per second) + /// public long Bitrate { get; set; } public string Codec { get; set; } public long Channels { get; set; } diff --git a/AudioNodes/AudioInfoHelper.cs b/AudioNodes/AudioInfoHelper.cs index d148ce3e..2ba7d841 100644 --- a/AudioNodes/AudioInfoHelper.cs +++ b/AudioNodes/AudioInfoHelper.cs @@ -161,9 +161,12 @@ namespace FileFlows.AudioNodes string br = line.Substring(line.ToLower().IndexOf("bitrate:") + "bitrate:".Length).Trim(); if (br.IndexOf(" ") > 0) { + int multiplier = br.ToLower().IndexOf("kb/s", StringComparison.Ordinal) > 0 ? 1024 : + br.ToLower().IndexOf("mb/s", StringComparison.Ordinal) > 0 ? 1024 * 1024 : + 1; br = br.Substring(0, br.IndexOf(" ")); if (long.TryParse(br, out long value)) - mi.Bitrate = value; + mi.Bitrate = value * multiplier; } } diff --git a/AudioNodes/Nodes/ConvertNode.cs b/AudioNodes/Nodes/ConvertNode.cs index c80f19a1..725ca753 100644 --- a/AudioNodes/Nodes/ConvertNode.cs +++ b/AudioNodes/Nodes/ConvertNode.cs @@ -211,13 +211,13 @@ namespace FileFlows.AudioNodes { if (SkipIfCodecMatches) { - args.Logger?.ILog($"Audio file already '{Codec}' at bitrate '{AudioInfo.Bitrate}', and set to skip if codec matches"); + args.Logger?.ILog($"Audio file already '{Codec}' at bitrate '{AudioInfo.Bitrate} bps', and set to skip if codec matches"); return 2; } - if(AudioInfo.Bitrate <= Bitrate) + if(AudioInfo.Bitrate <= Bitrate * 1024) // this bitrate is in Kbps, whereas AudioInfo.Bitrate is bytes per second { - args.Logger?.ILog($"Audio file already '{Codec}' at bitrate '{AudioInfo.Bitrate}'"); + args.Logger?.ILog($"Audio file already '{Codec}' at bitrate '{AudioInfo.Bitrate} bps'"); return 2; } }