mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-24 20:22:41 +01:00
parent
0333813033
commit
a6aaca56df
@ -14,6 +14,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using Nikse.SubtitleEdit.Core.VobSub;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Common
|
||||
{
|
||||
@ -2799,6 +2800,30 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
return format;
|
||||
}
|
||||
|
||||
public static void ParseMatroskaTextSt(MatroskaTrackInfo trackInfo, List<MatroskaSubtitle> subtitleLines, Subtitle subtitle)
|
||||
{
|
||||
for (var indexTextSt = 0; indexTextSt < subtitleLines.Count; indexTextSt++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var matroskaSubtitle = subtitleLines[indexTextSt];
|
||||
var idx = -6; // MakeMKV starts at DialogPresentationSegment
|
||||
var data = matroskaSubtitle.GetData(trackInfo);
|
||||
if (VobSubParser.IsPrivateStream2(data, 0))
|
||||
{
|
||||
idx = 0; // starts with MPEG2 private stream 2 (just to be sure)
|
||||
}
|
||||
|
||||
var dps = new TextST.DialogPresentationSegment(data, idx);
|
||||
subtitle.Paragraphs[indexTextSt].Text = dps.Text;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
subtitle.Paragraphs[indexTextSt].Text = exception.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void FixShortDisplayTime(Subtitle s, int i)
|
||||
{
|
||||
Paragraph p = s.Paragraphs[i];
|
||||
|
@ -824,6 +824,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
var mkvSrt = new List<string>();
|
||||
var mkvSsa = new List<string>();
|
||||
var mkvAss = new List<string>();
|
||||
var mkvTextST = new List<string>();
|
||||
var mkvCount = 0;
|
||||
var isTs = false;
|
||||
var isMp4 = false;
|
||||
@ -912,11 +913,15 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
mkvAss.Add(MakeMkvTrackInfoString(track));
|
||||
}
|
||||
else if (track.CodecId.Equals("S_HDMV/TEXTST", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
mkvTextST.Add(MakeMkvTrackInfoString(track));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mkvVobSub.Count + mkvPgs.Count + mkvSrt.Count + mkvSsa.Count + mkvAss.Count <= 0)
|
||||
if (mkvVobSub.Count + mkvPgs.Count + mkvSrt.Count + mkvSsa.Count + mkvAss.Count + mkvTextST.Count <= 0)
|
||||
{
|
||||
item.SubItems.Add(LanguageSettings.Current.UnknownSubtitle.Title);
|
||||
}
|
||||
@ -974,7 +979,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{ "VobSub", mkvVobSub },
|
||||
{ "SRT", mkvSrt },
|
||||
{ "SSA", mkvSsa },
|
||||
{ "ASS", mkvAss }
|
||||
{ "ASS", mkvAss },
|
||||
{ "TextST", mkvTextST },
|
||||
};
|
||||
|
||||
foreach (var mkvSubFormat in mkvSubFormats)
|
||||
@ -1559,6 +1565,26 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
fromFormat = new AdvancedSubStationAlpha();
|
||||
}
|
||||
|
||||
mkvFileNames.Add(fileName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (track.CodecId.Equals("S_HDMV/TEXTST", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (trackId == track.TrackNumber.ToString(CultureInfo.InvariantCulture))
|
||||
{
|
||||
var mkvSub = matroska.GetSubtitle(track.TrackNumber, null);
|
||||
Utilities.LoadMatroskaTextSubtitle(track, matroska, mkvSub, sub);
|
||||
Utilities.ParseMatroskaTextSt(track, mkvSub, sub);
|
||||
|
||||
fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + "." + GetMkvLanguage(track.Language).Replace("undefined.", string.Empty) + "mkv";
|
||||
if (mkvFileNames.Contains(fileName))
|
||||
{
|
||||
fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".#" + trackId + "." + GetMkvLanguage(track.Language) + "mkv";
|
||||
}
|
||||
|
||||
fromFormat = new SubRip();
|
||||
|
||||
mkvFileNames.Add(fileName);
|
||||
break;
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
|
||||
using CheckForUpdatesHelper = Nikse.SubtitleEdit.Logic.CheckForUpdatesHelper;
|
||||
using MessageBox = Nikse.SubtitleEdit.Forms.SeMsgBox.MessageBox;
|
||||
using Timer = System.Windows.Forms.Timer;
|
||||
@ -15076,26 +15077,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_subtitle.Paragraphs.Clear();
|
||||
|
||||
Utilities.LoadMatroskaTextSubtitle(matroskaSubtitleInfo, matroska, sub, _subtitle);
|
||||
for (int index = 0; index < sub.Count; index++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var msub = sub[index];
|
||||
int idx = -6; // MakeMKV starts at DialogPresentationSegment
|
||||
var data = msub.GetData(matroskaSubtitleInfo);
|
||||
if (VobSubParser.IsPrivateStream2(data, 0))
|
||||
{
|
||||
idx = 0; // starts with MPEG2 private stream 2 (just to be sure)
|
||||
}
|
||||
|
||||
var dps = new TextST.DialogPresentationSegment(data, idx);
|
||||
_subtitle.Paragraphs[index].Text = dps.Text;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
_subtitle.Paragraphs[index].Text = exception.Message;
|
||||
}
|
||||
}
|
||||
Utilities.ParseMatroskaTextSt(matroskaSubtitleInfo, sub, _subtitle);
|
||||
|
||||
if (_networkSession == null)
|
||||
{
|
||||
|
@ -671,6 +671,11 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
||||
var ss = matroska.GetSubtitle(track.TrackNumber, null);
|
||||
format = Utilities.LoadMatroskaTextSubtitle(track, matroska, ss, sub);
|
||||
|
||||
if (track.CodecId.Contains("S_HDMV/TEXTST", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Utilities.ParseMatroskaTextSt(track, ss, sub);
|
||||
}
|
||||
|
||||
var newFileName = fileName.Substring(0, fileName.LastIndexOf('.')) + "." + lang + ".mkv";
|
||||
if (!mkvFileNames.Add(newFileName))
|
||||
{
|
||||
@ -723,7 +728,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
||||
else if (!done && FileUtil.IsVobSub(fileName))
|
||||
{
|
||||
_stdOutWriter.WriteLine("Found VobSub subtitle format");
|
||||
ConvertVobSubSubtitle(fileName, targetFormat, offset, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, forcedOnly, ocrEngine, ocrDb, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
||||
ConvertVobSubSubtitle(fileName, targetFormat, offset, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, forcedOnly, ocrEngine, ocrDb, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
||||
done = true;
|
||||
}
|
||||
|
||||
@ -1753,7 +1758,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
||||
List<IBinaryParagraph> bin = null;
|
||||
if (bin != null)
|
||||
{
|
||||
bin = binaryParagraphs.Cast<IBinaryParagraph>().ToList();
|
||||
bin = binaryParagraphs.Cast<IBinaryParagraph>().ToList();
|
||||
}
|
||||
|
||||
BdSupSaver.SaveBdSup(fileName, sub, bin, form, width, height, isImageBased, binarySubtitleFile, format, cancellationToken);
|
||||
|
Loading…
Reference in New Issue
Block a user