Fix .ts crash + better support for the ".tts" video ext - thx hepalin :)

This commit is contained in:
niksedk 2023-04-07 12:10:52 +02:00
parent 6c2053c0d5
commit 8d33ff3aad
3 changed files with 17 additions and 12 deletions

View File

@ -29,7 +29,7 @@ namespace Nikse.SubtitleEdit.Core.Common
private static readonly Regex RegexIsEpisodeNumber = new Regex("^\\d+x\\d+$", RegexOptions.Compiled);
private static readonly Regex RegexNumberSpacePeriod = new Regex(@"(\d) (\.)", RegexOptions.Compiled);
public static string[] VideoFileExtensions { get; } = { ".avi", ".mkv", ".wmv", ".mpg", ".mpeg", ".divx", ".mp4", ".asf", ".flv", ".mov", ".m4v", ".vob", ".ogv", ".webm", ".ts", ".m2ts", ".mts", ".avs", ".mxf" };
public static string[] VideoFileExtensions { get; } = { ".avi", ".mkv", ".wmv", ".mpg", ".mpeg", ".divx", ".mp4", ".asf", ".flv", ".mov", ".m4v", ".vob", ".ogv", ".webm", ".ts", ".tts", ".m2ts", ".mts", ".avs", ".mxf" };
public static string[] AudioFileExtensions { get; } = { ".mp3", ".wav", ".wma", ".ogg", ".mpa", ".m4a", ".ape", ".aiff", ".flac", ".aac", ".ac3", ".eac3", ".mka" };
public static bool IsInteger(string s)
@ -1731,10 +1731,10 @@ namespace Nikse.SubtitleEdit.Core.Common
public static Color GetColorFromAssa(string text, Color defaultColor)
{
var start = text.IndexOf(@"\c");
var start = text.IndexOf(@"\c", StringComparison.Ordinal);
if (start < 0)
{
start = text.IndexOf(@"\1c");
start = text.IndexOf(@"\1c", StringComparison.Ordinal);
}
if (start < 0 || text.Substring(start).StartsWith(@"\clip", StringComparison.Ordinal))
@ -1987,7 +1987,7 @@ namespace Nikse.SubtitleEdit.Core.Common
if (match.Index > 4)
{
var before = text.Substring(match.Index - 4, 4);
if (int.TryParse(before.Trim(), NumberStyles.None, CultureInfo.InvariantCulture, out var n) && n > 999)
if (int.TryParse(before.Trim(), NumberStyles.None, CultureInfo.InvariantCulture, out var n) && n > 999)
{
skip = false;
}

View File

@ -580,6 +580,11 @@ namespace Nikse.SubtitleEdit.Core.ContainerFormats.TransportStream
public void WriteToStream(Stream stream)
{
if (_dataBuffer == null)
{
return;
}
stream.Write(_dataBuffer, 0, _dataBuffer.Length);
}
}

View File

@ -2836,7 +2836,7 @@ namespace Nikse.SubtitleEdit.Forms
return;
}
if ((ext == ".ts" || ext == ".rec" || ext == ".mpeg" || ext == ".mpg") && file.Length > 10000 && FileUtil.IsTransportStream(fileName))
if ((ext == ".ts" || ext == ".tts" || ext == ".rec" || ext == ".mpeg" || ext == ".mpg") && file.Length > 10000 && FileUtil.IsTransportStream(fileName))
{
ImportSubtitleFromTransportStream(fileName);
return;
@ -2854,7 +2854,7 @@ namespace Nikse.SubtitleEdit.Forms
}
}
if (((ext == ".m2ts" || ext == ".ts" || ext == ".mts") && file.Length > 10000 && FileUtil.IsM2TransportStream(fileName)) ||
if (((ext == ".m2ts" || ext == ".ts" || ext == ".tts" || ext == ".mts") && file.Length > 10000 && FileUtil.IsM2TransportStream(fileName)) ||
(ext == ".textst" && FileUtil.IsMpeg2PrivateStream2(fileName)))
{
bool isTextSt = false;
@ -15421,11 +15421,11 @@ namespace Nikse.SubtitleEdit.Forms
{
OpenSubtitle(fileName, null);
}
else if ((ext == ".ts" || ext == ".rec" || ext == ".mpg" || ext == ".mpeg") && FileUtil.IsTransportStream(fileName))
else if ((ext == ".ts" || ext == ".tts" || ext == ".rec" || ext == ".mpg" || ext == ".mpeg") && FileUtil.IsTransportStream(fileName))
{
OpenSubtitle(fileName, null);
}
else if ((ext == ".m2ts" || ext == ".ts" || ext == ".mts") && FileUtil.IsM2TransportStream(fileName))
else if ((ext == ".m2ts" || ext == ".ts" || ext == ".tts" || ext == ".mts") && FileUtil.IsM2TransportStream(fileName))
{
OpenSubtitle(fileName, null);
}