From 395175a3741fc048479d5c01873e58ebb536f934 Mon Sep 17 00:00:00 2001 From: niksedk Date: Wed, 14 Nov 2012 06:56:28 +0000 Subject: [PATCH] Updated header for TMPGEnc subtitle formats - thx Neil :) git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1482 99eadd0c-20b8-1223-b5c4-2a2b2df33de2 --- src/Logic/SubtitleFormats/TmpegEncAW5.cs | 130 +---------- src/Logic/SubtitleFormats/TmpegEncXml.cs | 270 ++++++++++++----------- 2 files changed, 153 insertions(+), 247 deletions(-) diff --git a/src/Logic/SubtitleFormats/TmpegEncAW5.cs b/src/Logic/SubtitleFormats/TmpegEncAW5.cs index 5b6d23866..fcfc47e99 100644 --- a/src/Logic/SubtitleFormats/TmpegEncAW5.cs +++ b/src/Logic/SubtitleFormats/TmpegEncAW5.cs @@ -15,132 +15,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats public override string ToText(Subtitle subtitle, string title) { - string xmlStructure = @" - - - - - - - 4 - - - - 0.069 - 17588159451135 - 0 - 0 - 0 - 0 - 1 - 2 - 0 - 1 - 0.00345 - 0 - 1 - 0 - - - - - - 4 - - - - 0.1 - 17588159451135 - 0 - 0 - 0 - 0 - 1 - 0 - 0 - 1 - 0.005 - 0 - 1 - 0 - - - - - - 4 - - - - 0.1 - 17588159451135 - 0 - 0 - 0 - 0 - 0 - 1 - 1 - 1 - 0.005 - 0 - 1 - 0 - - - - - - 4 - - - - 0.1 - 17588159451135 - 0 - 0 - 0 - 0 - 2 - 1 - 1 - 1 - 0.005 - 0 - 1 - 1 - - - - - - 4 - - - - 0.069 - 17588159451135 - 0 - 1 - 0 - 0 - 1 - 2 - 0 - 1 - 0.00345 - 0 - 1 - 0 - - - - -".Replace("'", "\""); - + string xmlStructure = Layout.Replace("'", "\""); var xml = new XmlDocument(); xml.LoadXml(xmlStructure); XmlNode div = xml.DocumentElement.SelectSingleNode("Subtitle"); + div.InnerXml = string.Empty; int no = 0; foreach (Paragraph p in subtitle.Paragraphs) { @@ -174,7 +53,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats no++; } - return ToUtf8XmlString(xml); + string s = ToUtf8XmlString(xml); + int startPos = s.IndexOf("") + 10; + s = s.Substring(startPos, s.IndexOf("") - startPos).Trim(); + return Layout.Replace("@", s); } public override bool IsMine(List lines, string fileName) diff --git a/src/Logic/SubtitleFormats/TmpegEncXml.cs b/src/Logic/SubtitleFormats/TmpegEncXml.cs index 360704f32..ac6a6812b 100644 --- a/src/Logic/SubtitleFormats/TmpegEncXml.cs +++ b/src/Logic/SubtitleFormats/TmpegEncXml.cs @@ -49,134 +49,155 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats return false; } + internal const string Layout = @" + + + + + + + 4 + + + + 0.1 + 17588159451135 + 0 + 0 + 0 + 0 + 1 + 2 + 0 + 1 + 0.005 + 0 + 1 + 0 + 0.005 + 0 + 1 + 0 + 1000 + 0 + 1000 + 0 + 1 + 0 + + + + + + 4 + + + + 0.1 + 17588159451135 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 1 + 0.005 + 0 + 1 + 0 + 0.005 + 0 + 1 + 0 + 1000 + 0 + 1000 + 0 + 1 + 0 + + + + + + 4 + + + + 0.1 + 17588159451135 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 0.005 + 0 + 1 + 0 + 0.005 + 0 + 1 + 0 + 1000 + 0 + 1000 + 0 + 1 + 1 + + + + + + 4 + + + + 0.1 + 17588159451135 + 0 + 0 + 0 + 0 + 2 + 1 + 1 + 1 + 0.005 + 0 + 1 + 0 + 0.005 + 0 + 1 + 0 + 1000 + 0 + 1000 + 0 + 1 + 1 + + + + @ + +"; + public override string ToText(Subtitle subtitle, string title) { - string xmlStructure = @" - - - - - - - 4 - - - - 0.069 - 17588159451135 - 0 - 0 - 0 - 0 - 1 - 2 - 0 - 1 - 0.00345 - 0 - 1 - 0 - - - - - - 4 - - - - 0.1 - 17588159451135 - 0 - 0 - 0 - 0 - 1 - 0 - 0 - 1 - 0.005 - 0 - 1 - 0 - - - - - - 4 - - - - 0.1 - 17588159451135 - 0 - 0 - 0 - 0 - 0 - 1 - 1 - 1 - 0.005 - 0 - 1 - 0 - - - - - - 4 - - - - 0.1 - 17588159451135 - 0 - 0 - 0 - 0 - 2 - 1 - 1 - 1 - 0.005 - 0 - 1 - 1 - - - - - - 4 - - - - 0.069 - 17588159451135 - 0 - 1 - 0 - 0 - 1 - 2 - 0 - 1 - 0.00345 - 0 - 1 - 0 - - - - -".Replace("'", "\""); + string xmlStructure = Layout.Replace("'", "\""); var xml = new XmlDocument(); xml.LoadXml(xmlStructure); XmlNode div = xml.DocumentElement.SelectSingleNode("Subtitle"); + div.InnerXml = string.Empty; int no = 0; foreach (Paragraph p in subtitle.Paragraphs) { @@ -210,7 +231,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats no++; } - return ToUtf8XmlString(xml); + string s = ToUtf8XmlString(xml); + int startPos = s.IndexOf("") + 10; + s = s.Substring(startPos, s.IndexOf("") - startPos).Trim(); + return Layout.Replace("@", s); } public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName)