mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-01-07 14:30:35 -06:00
FF-1851: Added special case for 8.0 and 6.0 to be 7.1 and 5.1 in set track titles
This commit is contained in:
@@ -303,9 +303,7 @@ public class FfmpegBuilderSetTrackTitles: FfmpegBuilderNode
|
||||
formatter = Replace(formatter, "hearingimpared", hi ? "Hearing Impared" : string.Empty);
|
||||
formatter = Replace(formatter, "sdh", sdh ? "SDH" : string.Empty);
|
||||
formatter = Replace(formatter, "numchannels", channels.ToString("N1"));
|
||||
formatter = Replace(formatter, "channels", Math.Abs(channels - 1) < 0.05f ? "Mono" :
|
||||
Math.Abs(channels - 2) < 0.05f ? "Stereo" :
|
||||
channels > 0 ? channels.ToString("0.0") : null);
|
||||
formatter = Replace(formatter, "channels", GetChannelString(channels));
|
||||
|
||||
formatter = Replace(formatter, "bitrate", bitrate < 1 ? null : ((bitrate / 1000f).ToString("0.0").Replace(".0", string.Empty) + "Kbps"));
|
||||
formatter = Replace(formatter, "samplerate", sampleRate < 1 ? null : ((sampleRate / 1000f).ToString("0.0").Replace(".0", string.Empty) + "kHz"));
|
||||
@@ -413,6 +411,25 @@ public class FfmpegBuilderSetTrackTitles: FfmpegBuilderNode
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the channel string
|
||||
/// </summary>
|
||||
/// <param name="channels">the number of channels</param>
|
||||
/// <returns>the channels string</returns>
|
||||
private static string GetChannelString(float channels)
|
||||
{
|
||||
if (Math.Abs(channels - 1) < 0.05f)
|
||||
return "Mono";
|
||||
if(Math.Abs(channels - 2) < 0.05f)
|
||||
return "Stereo";
|
||||
if (Math.Abs(channels - 6) < 0.05f)
|
||||
return "5.1";
|
||||
if (Math.Abs(channels - 8) < 0.05f)
|
||||
return "7.1";
|
||||
return channels > 0 ? channels.ToString("0.0") : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the commercial name for a codec.
|
||||
/// </summary>
|
||||
|
||||
@@ -206,6 +206,132 @@ public class FFmpegBuilder_SetTrackTitlesTests : VideoTestBase
|
||||
Assert.AreEqual("Track: English / Stereo / AAC", result);
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void FormatTitle_5dot1Channel_Success()
|
||||
{
|
||||
// Arrange
|
||||
string formatter = "Track: lang / channels / codec";
|
||||
string separator = " / ";
|
||||
string language = "English";
|
||||
string codec = "AAC";
|
||||
bool isDefault = true;
|
||||
float bitrate = 128_000;
|
||||
float channels = 6.0f; // 5.1
|
||||
int sampleRate = 44_100;
|
||||
bool isForced = false;
|
||||
|
||||
// Act
|
||||
string result = FfmpegBuilderSetTrackTitles.FormatTitle(formatter, separator, language, codec, isDefault, bitrate, channels, sampleRate, isForced);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Track: English / 5.1 / AAC", result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FormatTitle_5dot1Channel2_Success()
|
||||
{
|
||||
// Arrange
|
||||
string formatter = "Track: lang / channels / codec";
|
||||
string separator = " / ";
|
||||
string language = "English";
|
||||
string codec = "AAC";
|
||||
bool isDefault = true;
|
||||
float bitrate = 128_000;
|
||||
float channels = 5.1f; // 5.1
|
||||
int sampleRate = 44_100;
|
||||
bool isForced = false;
|
||||
|
||||
// Act
|
||||
string result = FfmpegBuilderSetTrackTitles.FormatTitle(formatter, separator, language, codec, isDefault, bitrate, channels, sampleRate, isForced);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Track: English / 5.1 / AAC", result);
|
||||
}
|
||||
[TestMethod]
|
||||
public void FormatTitle_7dot1Channel_Success()
|
||||
{
|
||||
// Arrange
|
||||
string formatter = "Track: lang / channels / codec";
|
||||
string separator = " / ";
|
||||
string language = "English";
|
||||
string codec = "AAC";
|
||||
bool isDefault = true;
|
||||
float bitrate = 128_000;
|
||||
float channels = 8.0f; // 7.1
|
||||
int sampleRate = 44_100;
|
||||
bool isForced = false;
|
||||
|
||||
// Act
|
||||
string result = FfmpegBuilderSetTrackTitles.FormatTitle(formatter, separator, language, codec, isDefault, bitrate, channels, sampleRate, isForced);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Track: English / 7.1 / AAC", result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FormatTitle_7dot1Channel2_Success()
|
||||
{
|
||||
// Arrange
|
||||
string formatter = "Track: lang / channels / codec";
|
||||
string separator = " / ";
|
||||
string language = "English";
|
||||
string codec = "AAC";
|
||||
bool isDefault = true;
|
||||
float bitrate = 128_000;
|
||||
float channels = 7.1f; // 7.1
|
||||
int sampleRate = 44_100;
|
||||
bool isForced = false;
|
||||
|
||||
// Act
|
||||
string result = FfmpegBuilderSetTrackTitles.FormatTitle(formatter, separator, language, codec, isDefault, bitrate, channels, sampleRate, isForced);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Track: English / 7.1 / AAC", result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FormatTitle_7dot0Channel_Success()
|
||||
{
|
||||
// Arrange
|
||||
string formatter = "Track: lang / channels / codec";
|
||||
string separator = " / ";
|
||||
string language = "English";
|
||||
string codec = "AAC";
|
||||
bool isDefault = true;
|
||||
float bitrate = 128_000;
|
||||
float channels = 7.0f;
|
||||
int sampleRate = 44_100;
|
||||
bool isForced = false;
|
||||
|
||||
// Act
|
||||
string result = FfmpegBuilderSetTrackTitles.FormatTitle(formatter, separator, language, codec, isDefault, bitrate, channels, sampleRate, isForced);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Track: English / 7.0 / AAC", result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FormatTitle_5dot0Channel_Success()
|
||||
{
|
||||
// Arrange
|
||||
string formatter = "Track: lang / channels / codec";
|
||||
string separator = " / ";
|
||||
string language = "English";
|
||||
string codec = "AAC";
|
||||
bool isDefault = true;
|
||||
float bitrate = 128_000;
|
||||
float channels = 5.0f;
|
||||
int sampleRate = 44_100;
|
||||
bool isForced = false;
|
||||
|
||||
// Act
|
||||
string result = FfmpegBuilderSetTrackTitles.FormatTitle(formatter, separator, language, codec, isDefault, bitrate, channels, sampleRate, isForced);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Track: English / 5.0 / AAC", result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FormatTitle_ZeroBitrateAndSampleRate_Success()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user