FF-1763: Added numchannels track title formatter

This commit is contained in:
John Andrews
2024-09-23 02:46:38 +12:00
parent 4e73fefea7
commit 70f48076f1
2 changed files with 24 additions and 0 deletions

View File

@@ -300,6 +300,7 @@ public class FfmpegBuilderSetTrackTitles: FfmpegBuilderNode
formatter = Replace(formatter, "hi", hi ? "HI" : string.Empty);
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);

View File

@@ -99,6 +99,29 @@ public class FFmpegBuilder_SetTrackTitlesTests : VideoTestBase
Assert.AreEqual("Track: English / Digital Theater Systems / Stereo / Default / 128Kbps / 44.1kHz", result);
}
[TestMethod]
public void FormatTitle_Codec_CommericalName_FF1763()
{
// Arrange
string formatter = "lang - codec-cc - numchannels";
string separator = " - ";
string language = "English";
string codec = "DTS";
bool isDefault = true;
float bitrate = 128_000;
float channels = 2.0f;
int sampleRate = 44100;
bool isForced = false;
// Act
string result = FfmpegBuilderSetTrackTitles.FormatTitle(formatter, separator, language, codec, isDefault, bitrate,
channels, sampleRate, isForced);
// Assert
Assert.AreEqual("English - Digital Theater Systems - 2.0", result);
}
[TestMethod]
public void FormatTitle_EmptyFormatter_ReturnsEmptyString()
{