mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-01-06 11:50:20 -06:00
FF-1392: Added codec-cc which adds the commerical name of a codec
This commit is contained in:
@@ -254,9 +254,16 @@ public class FfmpegBuilderSetTrackTitles: FfmpegBuilderNode
|
||||
formatter = Replace(formatter, "lang", english);
|
||||
formatter = Replace(formatter, "lang-iso2", iso2);
|
||||
formatter = Replace(formatter, "lang-iso1", iso1);
|
||||
|
||||
var codecCommericalName = GetCodecCommercialName(codec);
|
||||
formatter = Replace(formatter, "!codec-cc", codecCommericalName.ToLowerInvariant());
|
||||
formatter = Replace(formatter, "codec-cc!", codecCommericalName.ToUpperInvariant());
|
||||
formatter = Replace(formatter, "codec-cc", codecCommericalName);
|
||||
|
||||
formatter = Replace(formatter, "!codec", codec.ToLowerInvariant());
|
||||
formatter = Replace(formatter, "!codec!", codec);
|
||||
formatter = Replace(formatter, "codec", codec.ToUpperInvariant());
|
||||
|
||||
formatter = Replace(formatter, "default", isDefault ? "Default" : string.Empty);
|
||||
formatter = Replace(formatter, "forced", isForced ? "Forced" : string.Empty);
|
||||
formatter = Replace(formatter, "cc", cc ? "CC" : string.Empty);
|
||||
@@ -344,4 +351,31 @@ public class FfmpegBuilderSetTrackTitles: FfmpegBuilderNode
|
||||
return input;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the commercial name for a codec.
|
||||
/// </summary>
|
||||
/// <param name="codec">The codec name.</param>
|
||||
/// <returns>The commercial name.</returns>
|
||||
private static string GetCodecCommercialName(string codec)
|
||||
{
|
||||
// Convert codec name to uppercase for case-insensitive comparison
|
||||
return codec.ToUpper() switch
|
||||
{
|
||||
"DTS" => "Digital Theater Systems",
|
||||
"DOLBY DIGITAL" => "Dolby Digital",
|
||||
"DOLBY DIGITAL PLUS" => "Dolby Digital Plus",
|
||||
"DOLBY DIGITAL ATMOS" => "Dolby Digital Atmos",
|
||||
"DOLBY TRUEHD" => "Dolby TrueHD",
|
||||
"DTS-HD MASTER AUDIO" => "DTS-HD Master Audio",
|
||||
"PCM" => "Pulse-code Modulation",
|
||||
"AAC" => "Advanced Audio Coding",
|
||||
"MP3" => "MPEG-1 Audio Layer III",
|
||||
"WMA" => "Windows Media Audio",
|
||||
"FLAC" => "Free Lossless Audio Codec",
|
||||
"ALAC" => "Apple Lossless Audio Codec",
|
||||
"VORBIS" => "Vorbis",
|
||||
_ => codec.ToUpperInvariant()
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,6 +54,29 @@ public class FFmpegBuilder_SetTrackTtitlesTests
|
||||
Assert.AreEqual("Track: English / AAC / Stereo / Default / 128Kbps / 44.1kHz / CC / SDH", result);
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void FormatTitle_Codec_CommericalName()
|
||||
{
|
||||
// Arrange
|
||||
string formatter = "Track: lang / codec-cc / channels / default / bitrate / samplerate / cc / sdh / hi";
|
||||
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("Track: English / Digital Theater Systems / Stereo / Default / 128Kbps / 44.1kHz", result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FormatTitle_EmptyFormatter_ReturnsEmptyString()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user