mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Cheetah caption - don't write end times if next sub is closer then 1,5 sec (can be turned off by setting)
This commit is contained in:
parent
70c9519d21
commit
88b2fe64a1
@ -264,7 +264,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public int CurrentCavena890LanguageIdLine1 { get; set; }
|
||||
public int CurrentCavena890LanguageIdLine2 { get; set; }
|
||||
|
||||
public bool CheetahCaptionLessThan5SecondsNoEndTime { get; set; }
|
||||
public bool CheetahCaptionAlwayWriteEndTime { get; set; }
|
||||
|
||||
public bool SamiDisplayTwoClassesAsTwoSubtitles { get; set; }
|
||||
public int SamiHtmlEncodeMode { get; set; }
|
||||
@ -1791,9 +1791,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
subNode = node.SelectSingleNode("FcpFontName");
|
||||
if (subNode != null)
|
||||
settings.SubtitleSettings.FcpFontName = subNode.InnerText;
|
||||
subNode = node.SelectSingleNode("CheetahCaptionLessThan5SecondsNoEndTime");
|
||||
subNode = node.SelectSingleNode("CheetahCaptionAlwayWriteEndTime");
|
||||
if (subNode != null)
|
||||
settings.SubtitleSettings.CheetahCaptionLessThan5SecondsNoEndTime = Convert.ToBoolean(subNode.InnerText);
|
||||
settings.SubtitleSettings.CheetahCaptionAlwayWriteEndTime = Convert.ToBoolean(subNode.InnerText);
|
||||
subNode = node.SelectSingleNode("NuendoCharacterListFile");
|
||||
if (subNode != null)
|
||||
settings.SubtitleSettings.NuendoCharacterListFile = subNode.InnerText;
|
||||
@ -2824,7 +2824,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
textWriter.WriteElementString("TimedText10TimeCodeFormat", settings.SubtitleSettings.TimedText10TimeCodeFormat);
|
||||
textWriter.WriteElementString("FcpFontSize", settings.SubtitleSettings.FcpFontSize.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("FcpFontName", settings.SubtitleSettings.FcpFontName);
|
||||
textWriter.WriteElementString("CheetahCaptionLessThan5SecondsNoEndTime", settings.SubtitleSettings.CheetahCaptionLessThan5SecondsNoEndTime.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("CheetahCaptionAlwayWriteEndTime", settings.SubtitleSettings.CheetahCaptionAlwayWriteEndTime.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("NuendoCharacterListFile", settings.SubtitleSettings.NuendoCharacterListFile);
|
||||
textWriter.WriteEndElement();
|
||||
|
||||
|
@ -89,12 +89,15 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
fs.WriteByte(0);
|
||||
|
||||
// paragraphs
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
for (int index = 0; index < subtitle.Paragraphs.Count; index++)
|
||||
{
|
||||
Paragraph p = subtitle.Paragraphs[index];
|
||||
Paragraph next = subtitle.GetParagraphOrDefault(index + 1);
|
||||
string text = p.Text;
|
||||
|
||||
//styles + ?
|
||||
buffer = new byte[] {
|
||||
buffer = new byte[]
|
||||
{
|
||||
0x12,
|
||||
1,
|
||||
0,
|
||||
@ -103,7 +106,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
0,
|
||||
3, // justification, 1=left, 2=right, 3=center
|
||||
0xF, //horizontal position, 1=top, F=bottom
|
||||
0x10, //horizontal position, 3=left, 0x10=center, 0x19=right
|
||||
0x10 //horizontal position, 3=left, 0x10=center, 0x19=right
|
||||
};
|
||||
|
||||
//Normal : 12 01 00 00 00 00 03 0F 10
|
||||
@ -160,9 +163,9 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
int idx = LatinLetters.IndexOf(text.Substring(j, 1));
|
||||
if (idx >= 0)
|
||||
textBytes.Add((byte)LatinCodes[idx]);
|
||||
textBytes.Add((byte) LatinCodes[idx]);
|
||||
else
|
||||
textBytes.Add(Encoding.GetEncoding(1252).GetBytes(new[] { text[j] })[0]);
|
||||
textBytes.Add(Encoding.GetEncoding(1252).GetBytes(new[] {text[j]})[0]);
|
||||
|
||||
j++;
|
||||
}
|
||||
@ -170,9 +173,15 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
|
||||
int length = textBytes.Count + 20;
|
||||
long end = fs.Position + length;
|
||||
fs.WriteByte((byte)(length));
|
||||
fs.WriteByte((byte) (length));
|
||||
|
||||
if (Configuration.Settings.SubtitleSettings.CheetahCaptionLessThan5SecondsNoEndTime && p.Duration.TotalMilliseconds < 5000)
|
||||
if (Configuration.Settings.SubtitleSettings.CheetahCaptionAlwayWriteEndTime || (next != null && next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds >= 1500))
|
||||
{
|
||||
fs.WriteByte(0x62); // ?
|
||||
WriteTime(fs, p.StartTime);
|
||||
WriteTime(fs, p.EndTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
fs.WriteByte(0x42); // ?
|
||||
WriteTime(fs, p.StartTime);
|
||||
@ -181,12 +190,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
fs.WriteByte(0);
|
||||
fs.WriteByte(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fs.WriteByte(0x62); // ?
|
||||
WriteTime(fs, p.StartTime);
|
||||
WriteTime(fs, p.EndTime);
|
||||
}
|
||||
|
||||
fs.Write(buffer, 0, buffer.Length); // styles
|
||||
|
||||
@ -264,7 +267,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
}
|
||||
if (textLength > 0 && buffer.Length >= i + textLength)
|
||||
{
|
||||
byte firstByte = buffer[i + 1];
|
||||
p.StartTime = DecodeTimestamp(buffer, i + 2);
|
||||
|
||||
if (last != null && last.EndTime.TotalMilliseconds > p.StartTime.TotalMilliseconds)
|
||||
|
Loading…
Reference in New Issue
Block a user