FF-377 - added option same as source to audio nodes bitrate

This commit is contained in:
john
2022-12-05 21:12:43 +13:00
parent 8f972e3de5
commit 3a41d0552e
3 changed files with 10 additions and 4 deletions

View File

@@ -16,6 +16,9 @@ namespace FileFlows.AudioNodes
/// Gets or sets duration in SECONDS
/// </summary>
public long Duration { get; set; }
/// <summary>
/// Gets or sets the bitrate (in bytes per second)
/// </summary>
public long Bitrate { get; set; }
public string Codec { get; set; }
public long Channels { get; set; }

View File

@@ -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;
}
}

View File

@@ -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;
}
}