mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
parent
0333813033
commit
a6aaca56df
@ -14,6 +14,7 @@ using System.Text;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
using Nikse.SubtitleEdit.Core.VobSub;
|
||||||
|
|
||||||
namespace Nikse.SubtitleEdit.Core.Common
|
namespace Nikse.SubtitleEdit.Core.Common
|
||||||
{
|
{
|
||||||
@ -2799,6 +2800,30 @@ namespace Nikse.SubtitleEdit.Core.Common
|
|||||||
return format;
|
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)
|
private static void FixShortDisplayTime(Subtitle s, int i)
|
||||||
{
|
{
|
||||||
Paragraph p = s.Paragraphs[i];
|
Paragraph p = s.Paragraphs[i];
|
||||||
|
@ -824,6 +824,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
var mkvSrt = new List<string>();
|
var mkvSrt = new List<string>();
|
||||||
var mkvSsa = new List<string>();
|
var mkvSsa = new List<string>();
|
||||||
var mkvAss = new List<string>();
|
var mkvAss = new List<string>();
|
||||||
|
var mkvTextST = new List<string>();
|
||||||
var mkvCount = 0;
|
var mkvCount = 0;
|
||||||
var isTs = false;
|
var isTs = false;
|
||||||
var isMp4 = false;
|
var isMp4 = false;
|
||||||
@ -912,11 +913,15 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
{
|
{
|
||||||
mkvAss.Add(MakeMkvTrackInfoString(track));
|
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);
|
item.SubItems.Add(LanguageSettings.Current.UnknownSubtitle.Title);
|
||||||
}
|
}
|
||||||
@ -974,7 +979,8 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
{ "VobSub", mkvVobSub },
|
{ "VobSub", mkvVobSub },
|
||||||
{ "SRT", mkvSrt },
|
{ "SRT", mkvSrt },
|
||||||
{ "SSA", mkvSsa },
|
{ "SSA", mkvSsa },
|
||||||
{ "ASS", mkvAss }
|
{ "ASS", mkvAss },
|
||||||
|
{ "TextST", mkvTextST },
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var mkvSubFormat in mkvSubFormats)
|
foreach (var mkvSubFormat in mkvSubFormats)
|
||||||
@ -1559,6 +1565,26 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
fromFormat = new AdvancedSubStationAlpha();
|
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);
|
mkvFileNames.Add(fileName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ using System.Text.RegularExpressions;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
|
||||||
using CheckForUpdatesHelper = Nikse.SubtitleEdit.Logic.CheckForUpdatesHelper;
|
using CheckForUpdatesHelper = Nikse.SubtitleEdit.Logic.CheckForUpdatesHelper;
|
||||||
using MessageBox = Nikse.SubtitleEdit.Forms.SeMsgBox.MessageBox;
|
using MessageBox = Nikse.SubtitleEdit.Forms.SeMsgBox.MessageBox;
|
||||||
using Timer = System.Windows.Forms.Timer;
|
using Timer = System.Windows.Forms.Timer;
|
||||||
@ -15076,27 +15077,8 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
_subtitle.Paragraphs.Clear();
|
_subtitle.Paragraphs.Clear();
|
||||||
|
|
||||||
Utilities.LoadMatroskaTextSubtitle(matroskaSubtitleInfo, matroska, sub, _subtitle);
|
Utilities.LoadMatroskaTextSubtitle(matroskaSubtitleInfo, matroska, sub, _subtitle);
|
||||||
for (int index = 0; index < sub.Count; index++)
|
Utilities.ParseMatroskaTextSt(matroskaSubtitleInfo, sub, _subtitle);
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_networkSession == null)
|
if (_networkSession == null)
|
||||||
{
|
{
|
||||||
SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra);
|
SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra);
|
||||||
|
@ -13,7 +13,7 @@ using Nikse.SubtitleEdit.Logic.Ocr;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -671,6 +671,11 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
var ss = matroska.GetSubtitle(track.TrackNumber, null);
|
var ss = matroska.GetSubtitle(track.TrackNumber, null);
|
||||||
format = Utilities.LoadMatroskaTextSubtitle(track, matroska, ss, sub);
|
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";
|
var newFileName = fileName.Substring(0, fileName.LastIndexOf('.')) + "." + lang + ".mkv";
|
||||||
if (!mkvFileNames.Add(newFileName))
|
if (!mkvFileNames.Add(newFileName))
|
||||||
{
|
{
|
||||||
@ -723,7 +728,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
else if (!done && FileUtil.IsVobSub(fileName))
|
else if (!done && FileUtil.IsVobSub(fileName))
|
||||||
{
|
{
|
||||||
_stdOutWriter.WriteLine("Found VobSub subtitle format");
|
_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;
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1749,11 +1754,11 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
using (var binarySubtitleFile = new FileStream(outputFileName, FileMode.Create))
|
using (var binarySubtitleFile = new FileStream(outputFileName, FileMode.Create))
|
||||||
{
|
{
|
||||||
var isImageBased = IsImageBased(format);
|
var isImageBased = IsImageBased(format);
|
||||||
|
|
||||||
List<IBinaryParagraph> bin = null;
|
List<IBinaryParagraph> bin = null;
|
||||||
if (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);
|
BdSupSaver.SaveBdSup(fileName, sub, bin, form, width, height, isImageBased, binarySubtitleFile, format, cancellationToken);
|
||||||
|
Loading…
Reference in New Issue
Block a user