diff --git a/pipes/MultiFileStream.cs b/pipes/MultiFileStream.cs index b0a343f..5a667a8 100644 --- a/pipes/MultiFileStream.cs +++ b/pipes/MultiFileStream.cs @@ -183,8 +183,7 @@ private void GenerateVttContent(IList inputBoxes, MP4Writer mp4Writer) if (vttText != null) { - byte[] contentBytes = Encoding.UTF8.GetBytes(RemoveXmlControlCharacters(vttText)); - mp4Writer.Write(contentBytes); + mp4Writer.Write(vttText); } else { @@ -197,22 +196,6 @@ private void GenerateVttContent(IList inputBoxes, MP4Writer mp4Writer) } } - private string RemoveXmlControlCharacters(string input) - { - StringBuilder output = new StringBuilder(); - - foreach (char c in input) - { - // Exclude XML control characters (0x00 to 0x1F, except for whitespace characters) - if (c >= 0x20 || char.IsWhiteSpace(c)) - { - output.Append(c); - } - } - - return output.ToString(); - } - private async Task DownloadClearBlobContent(BlockBlobClient sourceBlob, Stream outputStream, CancellationToken cancellationToken) { using var tmpStream = new MemoryStream(); diff --git a/transform/CTtml2WebVttConv.cs b/transform/CTtml2WebVttConv.cs index 5779ee3..42367e4 100644 --- a/transform/CTtml2WebVttConv.cs +++ b/transform/CTtml2WebVttConv.cs @@ -7,7 +7,7 @@ public static class TtmlToVttConverter { - public static string? Convert(byte[]? ttmlText) + public static byte[]? Convert(byte[]? ttmlText) { if (ttmlText == null) { @@ -127,7 +127,12 @@ public static class TtmlToVttConverter webVttContentRes= webVttContent.ToString(); } - return !string.IsNullOrEmpty(webVttContentRes) ? webVttContentRes: null; //webVttContentRes;Regex.Replace(webVttContentRes, @"[\x00-\x1F\x7F]", "\n") + byte[]? contentBytes = null; + if (!string.IsNullOrEmpty(webVttContentRes)) + { + contentBytes = Encoding.UTF8.GetBytes(webVttContentRes); + } + return contentBytes; } private static void ParseRegionAttributes(XmlReader pReader, out string strStartCue, out string strCueSize, out string strAlign)