mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 14:32:35 +01:00
Refactor to always use milliseconds internally
This commit is contained in:
parent
09e6234978
commit
98104f30fd
@ -14,10 +14,6 @@ namespace Nikse.SubtitleEdit.Core
|
||||
|
||||
public TimeCode Duration => new TimeCode(EndTime.TotalMilliseconds - StartTime.TotalMilliseconds);
|
||||
|
||||
public int StartFrame { get; set; }
|
||||
|
||||
public int EndFrame { get; set; }
|
||||
|
||||
public bool Forced { get; set; }
|
||||
|
||||
public string Extra { get; set; }
|
||||
@ -70,8 +66,6 @@ namespace Nikse.SubtitleEdit.Core
|
||||
Text = paragraph.Text;
|
||||
StartTime = new TimeCode(paragraph.StartTime.TotalMilliseconds);
|
||||
EndTime = new TimeCode(paragraph.EndTime.TotalMilliseconds);
|
||||
StartFrame = paragraph.StartFrame;
|
||||
EndFrame = paragraph.EndFrame;
|
||||
Forced = paragraph.Forced;
|
||||
Extra = paragraph.Extra;
|
||||
IsComment = paragraph.IsComment;
|
||||
@ -89,13 +83,6 @@ namespace Nikse.SubtitleEdit.Core
|
||||
Bookmark = paragraph.Bookmark;
|
||||
}
|
||||
|
||||
public Paragraph(int startFrame, int endFrame, string text) :
|
||||
this(new TimeCode(), new TimeCode(), text)
|
||||
{
|
||||
StartFrame = startFrame;
|
||||
EndFrame = endFrame;
|
||||
}
|
||||
|
||||
public Paragraph(string text, double startTotalMilliseconds, double endTotalMilliseconds)
|
||||
: this(new TimeCode(startTotalMilliseconds), new TimeCode(endTotalMilliseconds), text)
|
||||
{
|
||||
@ -112,18 +99,6 @@ namespace Nikse.SubtitleEdit.Core
|
||||
EndTime.TotalMilliseconds = EndTime.TotalMilliseconds * factor + adjustmentInSeconds * TimeCode.BaseUnit;
|
||||
}
|
||||
|
||||
public void CalculateFrameNumbersFromTimeCodes(double frameRate)
|
||||
{
|
||||
StartFrame = (int)Math.Round(StartTime.TotalMilliseconds / TimeCode.BaseUnit * frameRate);
|
||||
EndFrame = (int)Math.Round(EndTime.TotalMilliseconds / TimeCode.BaseUnit * frameRate);
|
||||
}
|
||||
|
||||
public void CalculateTimeCodesFromFrameNumbers(double frameRate)
|
||||
{
|
||||
StartTime.TotalMilliseconds = StartFrame * (TimeCode.BaseUnit / frameRate);
|
||||
EndTime.TotalMilliseconds = EndFrame * (TimeCode.BaseUnit / frameRate);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{StartTime} --> {EndTime} {Text}";
|
||||
|
@ -62,7 +62,6 @@ namespace Nikse.SubtitleEdit.Core
|
||||
{
|
||||
_paragraphs.Add(new Paragraph(p, generateNewId));
|
||||
}
|
||||
WasLoadedWithFrameNumbers = subtitle.WasLoadedWithFrameNumbers;
|
||||
Header = subtitle.Header;
|
||||
Footer = subtitle.Footer;
|
||||
FileName = subtitle.FileName;
|
||||
@ -198,11 +197,6 @@ namespace Nikse.SubtitleEdit.Core
|
||||
subtitleFormat.LoadSubtitle(this, lines, fileName);
|
||||
}
|
||||
OriginalFormat = subtitleFormat;
|
||||
WasLoadedWithFrameNumbers = OriginalFormat.IsFrameBased;
|
||||
if (WasLoadedWithFrameNumbers)
|
||||
{
|
||||
CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
|
||||
}
|
||||
return subtitleFormat;
|
||||
}
|
||||
|
||||
@ -257,82 +251,15 @@ namespace Nikse.SubtitleEdit.Core
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate the time codes from frame number/frame rate
|
||||
/// </summary>
|
||||
/// <param name="frameRate">Number of frames per second</param>
|
||||
/// <returns>True if times could be calculated</returns>
|
||||
public bool CalculateTimeCodesFromFrameNumbers(double frameRate)
|
||||
{
|
||||
if (OriginalFormat == null || OriginalFormat.IsTimeBased)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (Paragraph p in Paragraphs)
|
||||
{
|
||||
p.CalculateTimeCodesFromFrameNumbers(frameRate);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate the frame numbers from time codes/frame rate
|
||||
/// </summary>
|
||||
/// <param name="frameRate"></param>
|
||||
/// <returns></returns>
|
||||
public bool CalculateFrameNumbersFromTimeCodes(double frameRate)
|
||||
{
|
||||
if (OriginalFormat == null || OriginalFormat.IsFrameBased)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (Paragraph p in Paragraphs)
|
||||
{
|
||||
p.CalculateFrameNumbersFromTimeCodes(frameRate);
|
||||
}
|
||||
|
||||
FixEqualOrJustOverlappingFrameNumbers();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void CalculateFrameNumbersFromTimeCodesNoCheck(double frameRate)
|
||||
{
|
||||
foreach (Paragraph p in Paragraphs)
|
||||
{
|
||||
p.CalculateFrameNumbersFromTimeCodes(frameRate);
|
||||
}
|
||||
|
||||
FixEqualOrJustOverlappingFrameNumbers();
|
||||
}
|
||||
|
||||
private void FixEqualOrJustOverlappingFrameNumbers()
|
||||
{
|
||||
for (int i = 0; i < Paragraphs.Count - 1; i++)
|
||||
{
|
||||
Paragraph p = Paragraphs[i];
|
||||
Paragraph next = GetParagraphOrDefault(i + 1);
|
||||
if (next != null && (p.EndFrame == next.StartFrame || p.EndFrame == next.StartFrame + 1))
|
||||
{
|
||||
p.EndFrame = next.StartFrame - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeFrameRate(double oldFrameRate, double newFrameRate)
|
||||
{
|
||||
foreach (Paragraph p in Paragraphs)
|
||||
{
|
||||
p.StartTime.TotalMilliseconds = (p.StartTime.TotalMilliseconds * oldFrameRate / newFrameRate);
|
||||
p.EndTime.TotalMilliseconds = (p.EndTime.TotalMilliseconds * oldFrameRate / newFrameRate);
|
||||
p.CalculateFrameNumbersFromTimeCodes(newFrameRate);
|
||||
}
|
||||
}
|
||||
|
||||
public bool WasLoadedWithFrameNumbers { get; set; }
|
||||
|
||||
public void AdjustDisplayTimeUsingPercent(double percent, List<int> selectedIndexes)
|
||||
{
|
||||
for (int i = 0; i < _paragraphs.Count; i++)
|
||||
|
@ -71,12 +71,11 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
var tc = DecodeTimeCode(timePart);
|
||||
if (expecting == ExpectingLine.TimeStart)
|
||||
{
|
||||
paragraph = new Paragraph { StartFrame = int.Parse(timePart), StartTime = tc };
|
||||
paragraph = new Paragraph { StartTime = tc };
|
||||
expecting = ExpectingLine.Text;
|
||||
}
|
||||
else if (expecting == ExpectingLine.TimeEndOrText)
|
||||
{
|
||||
paragraph.EndFrame = int.Parse(timePart);
|
||||
paragraph.EndTime = tc;
|
||||
subtitle.Paragraphs.Add(paragraph);
|
||||
paragraph = new Paragraph();
|
||||
@ -117,8 +116,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
else if (expecting == ExpectingLine.TimeStart && !string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
int ms = (int)paragraph.EndTime.TotalMilliseconds;
|
||||
int frames = paragraph.EndFrame;
|
||||
paragraph = new Paragraph { StartTime = { TotalMilliseconds = ms }, StartFrame = frames, Text = line.Trim() };
|
||||
int frames = MillisecondsToFrames(paragraph.EndTime.TotalMilliseconds);
|
||||
paragraph = new Paragraph { StartTime = { TotalMilliseconds = ms }, Text = line.Trim() };
|
||||
expecting = ExpectingLine.TimeEndOrText;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
case Expecting.StartFrame:
|
||||
if (ContainsOnlyNumber(line))
|
||||
{
|
||||
p.StartFrame = int.Parse(line.TrimStart(trimChar));
|
||||
p.StartTime.TotalMilliseconds = FramesToMilliseconds(int.Parse(line.TrimStart(trimChar)));
|
||||
expecting = Expecting.Text;
|
||||
}
|
||||
else
|
||||
@ -68,7 +68,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
case Expecting.EndFrame:
|
||||
if (ContainsOnlyNumber(line))
|
||||
{
|
||||
p.EndFrame = int.Parse(line.TrimStart(trimChar));
|
||||
p.EndTime.TotalMilliseconds = FramesToMilliseconds(int.Parse(line.TrimStart(trimChar)));
|
||||
subtitle.Paragraphs.Add(p);
|
||||
// Prepare for next reading.
|
||||
p = new Paragraph();
|
||||
|
@ -81,9 +81,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
sb.Append('{');
|
||||
sb.Append(p.StartFrame);
|
||||
sb.Append(MillisecondsToFrames(p.StartTime.TotalMilliseconds));
|
||||
sb.Append("}{");
|
||||
sb.Append(p.EndFrame);
|
||||
sb.Append(MillisecondsToFrames(p.EndTime.TotalMilliseconds));
|
||||
sb.Append('}');
|
||||
|
||||
//{y:b} is italics for single line
|
||||
@ -567,7 +567,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
count++;
|
||||
}
|
||||
text = lineSb + post;
|
||||
subtitle.Paragraphs.Add(new Paragraph(startFrame, endFrame, text));
|
||||
subtitle.Paragraphs.Add(new Paragraph(text, FramesToMilliseconds(startFrame), FramesToMilliseconds(endFrame)));
|
||||
}
|
||||
}
|
||||
catch
|
||||
@ -593,13 +593,13 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
Paragraph previous = subtitle.GetParagraphOrDefault(j - 1);
|
||||
if (p.StartFrame == 0 && previous != null)
|
||||
if (p.StartTime.TotalMilliseconds == 0 && previous != null)
|
||||
{
|
||||
p.StartFrame = previous.EndFrame + 1;
|
||||
p.StartTime.TotalMilliseconds = previous.EndTime.TotalMilliseconds + 1;
|
||||
}
|
||||
if (p.EndFrame == 0)
|
||||
if (p.EndTime.TotalMilliseconds == 0)
|
||||
{
|
||||
p.EndFrame = p.StartFrame;
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
|
@ -53,12 +53,13 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
try
|
||||
{
|
||||
var startMs = (double)FramesToMilliseconds(int.Parse(match.Groups[1].Value));
|
||||
var endMs = (double)FramesToMilliseconds(int.Parse(match.Groups[2].Value));
|
||||
var paragraph = new Paragraph
|
||||
{
|
||||
Number = subtitle.Paragraphs.Count + 1,
|
||||
// Read frames.
|
||||
StartFrame = int.Parse(match.Groups[1].Value),
|
||||
EndFrame = int.Parse(match.Groups[2].Value)
|
||||
StartTime = new TimeCode(startMs),
|
||||
EndTime = new TimeCode(endMs)
|
||||
};
|
||||
|
||||
// Decode text.
|
||||
@ -97,8 +98,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
string text = HtmlUtil.RemoveHtmlTags(p.Text, true);
|
||||
// Pipe character for forced line breaks.
|
||||
text = text.Replace(Environment.NewLine, "|");
|
||||
sb.AppendFormat(writeFormat, MillisecondsToFrames(p.StartTime.TotalMilliseconds),
|
||||
MillisecondsToFrames(p.EndTime.TotalMilliseconds), text, Environment.NewLine);
|
||||
sb.AppendFormat(writeFormat, MillisecondsToFrames(p.StartTime.TotalMilliseconds), MillisecondsToFrames(p.EndTime.TotalMilliseconds), text, Environment.NewLine);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -42,15 +42,10 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
ý
|
||||
ý Kraj info blocka.");
|
||||
sb.AppendLine();
|
||||
if (!subtitle.WasLoadedWithFrameNumbers)
|
||||
{
|
||||
subtitle.CalculateFrameNumbersFromTimeCodes(Configuration.Settings.General.CurrentFrameRate);
|
||||
}
|
||||
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
var text = HtmlUtil.RemoveOpenCloseTags(p.Text, HtmlUtil.TagFont);
|
||||
sb.AppendLine(string.Format(paragraphWriteFormat, p.StartFrame, p.EndFrame, text));
|
||||
sb.AppendLine(string.Format(paragraphWriteFormat, MillisecondsToFrames(p.StartTime.TotalMilliseconds), MillisecondsToFrames(p.EndTime.TotalMilliseconds), text));
|
||||
}
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
@ -77,9 +72,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
try
|
||||
{
|
||||
paragraph.StartFrame = int.Parse(parts[0]);
|
||||
paragraph.EndFrame = int.Parse(parts[1]);
|
||||
paragraph.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
|
||||
paragraph.StartTime.TotalMilliseconds = FramesToMilliseconds(int.Parse(parts[0]));
|
||||
paragraph.EndTime.TotalMilliseconds = FramesToMilliseconds(int.Parse(parts[1]));
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -108,6 +102,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -251,13 +251,13 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
Paragraph previous = subtitle.GetParagraphOrDefault(i - 1);
|
||||
if (p.StartFrame == 0 && previous != null)
|
||||
if (p.StartTime.TotalMilliseconds == 0 && previous != null)
|
||||
{
|
||||
p.StartFrame = previous.EndFrame + 1;
|
||||
p.StartTime.TotalMilliseconds = previous.EndTime.TotalMilliseconds + 1;
|
||||
}
|
||||
if (p.EndFrame == 0)
|
||||
if (p.EndTime.TotalMilliseconds == 0)
|
||||
{
|
||||
p.EndFrame = p.StartFrame;
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@ -275,7 +275,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
tagCount++;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
|
@ -25,12 +25,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
var sb = new StringBuilder();
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
if (!subtitle.WasLoadedWithFrameNumbers)
|
||||
{
|
||||
p.CalculateFrameNumbersFromTimeCodes(Configuration.Settings.General.CurrentFrameRate);
|
||||
}
|
||||
|
||||
sb.AppendLine(string.Format(paragraphWriteFormat, p.StartFrame, p.EndFrame, p.Text.Replace(Environment.NewLine, "\\~")));
|
||||
sb.AppendLine(string.Format(paragraphWriteFormat, MillisecondsToFrames(p.StartTime.TotalMilliseconds), MillisecondsToFrames(p.EndTime.TotalMilliseconds), p.Text.Replace(Environment.NewLine, "\\~")));
|
||||
}
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
|
@ -81,9 +81,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
sb.Append('[');
|
||||
sb.Append(p.StartFrame);
|
||||
sb.Append(MillisecondsToFrames(p.StartTime.TotalMilliseconds));
|
||||
sb.Append("][");
|
||||
sb.Append(p.EndFrame);
|
||||
sb.Append(MillisecondsToFrames(p.EndTime.TotalMilliseconds));
|
||||
sb.Append(']');
|
||||
|
||||
//{y:b} is italics for single line
|
||||
@ -564,7 +564,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
count++;
|
||||
}
|
||||
text = lineSb + post;
|
||||
subtitle.Paragraphs.Add(new Paragraph(startFrame, endFrame, text));
|
||||
subtitle.Paragraphs.Add(new Paragraph(text, FramesToMilliseconds(startFrame), FramesToMilliseconds(endFrame)));
|
||||
}
|
||||
}
|
||||
catch
|
||||
@ -590,13 +590,13 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
Paragraph previous = subtitle.GetParagraphOrDefault(j - 1);
|
||||
if (p.StartFrame == 0 && previous != null)
|
||||
if (p.StartTime.TotalMilliseconds == 0 && previous != null)
|
||||
{
|
||||
p.StartFrame = previous.EndFrame + 1;
|
||||
p.StartTime.TotalMilliseconds = previous.EndTime.TotalMilliseconds + 1;
|
||||
}
|
||||
if (p.EndFrame == 0)
|
||||
if (p.EndTime.TotalMilliseconds == 0)
|
||||
{
|
||||
p.EndFrame = p.StartFrame;
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
|
@ -179,9 +179,8 @@ namespace Nikse.SubtitleEdit.Core
|
||||
{
|
||||
if (UseFrames)
|
||||
{
|
||||
p.StartFrame = int.Parse(start);
|
||||
p.EndFrame = int.Parse(end);
|
||||
p.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
|
||||
p.StartTime.TotalMilliseconds = SubtitleFormat.FramesToMilliseconds(int.Parse(start));
|
||||
p.EndTime.TotalMilliseconds = SubtitleFormat.FramesToMilliseconds(int.Parse(end));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -264,9 +263,8 @@ namespace Nikse.SubtitleEdit.Core
|
||||
{
|
||||
if (UseFrames)
|
||||
{
|
||||
p.StartFrame = int.Parse(start[0]);
|
||||
p.EndFrame = int.Parse(end[0]);
|
||||
p.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
|
||||
p.StartTime.TotalMilliseconds = SubtitleFormat.FramesToMilliseconds(int.Parse(start[0]));
|
||||
p.EndTime.TotalMilliseconds = SubtitleFormat.FramesToMilliseconds(int.Parse(end[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -305,9 +303,8 @@ namespace Nikse.SubtitleEdit.Core
|
||||
{
|
||||
if (UseFrames)
|
||||
{
|
||||
p.StartFrame = int.Parse(start[0]);
|
||||
p.EndFrame = int.Parse(end[0]);
|
||||
p.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
|
||||
p.StartTime.TotalMilliseconds = SubtitleFormat.FramesToMilliseconds(int.Parse(start[0]));
|
||||
p.EndTime.TotalMilliseconds = SubtitleFormat.FramesToMilliseconds(int.Parse(end[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -338,7 +335,6 @@ namespace Nikse.SubtitleEdit.Core
|
||||
p.Text = sb.ToString().Trim();
|
||||
subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
subtitle.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
|
||||
subtitle.Renumber();
|
||||
return subtitle;
|
||||
}
|
||||
|
@ -5579,10 +5579,6 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
}
|
||||
}
|
||||
subtitleListView1.EndUpdate();
|
||||
if (_subtitle.WasLoadedWithFrameNumbers)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(Configuration.Settings.General.CurrentFrameRate);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowTimeInListView(int index)
|
||||
@ -5639,12 +5635,6 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
ShowTimeInListView(i);
|
||||
}
|
||||
subtitleListView1.EndUpdate();
|
||||
if (_subtitle.WasLoadedWithFrameNumbers)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(Configuration.Settings.General.CurrentFrameRate);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -349,12 +349,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (!checkBoxRemoveLinesWithoutLetters.Checked)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(new Paragraph(0, 0, line.Trim()));
|
||||
_subtitle.Paragraphs.Add(new Paragraph(line.Trim(), 0, 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_subtitle.Paragraphs.Add(new Paragraph(0, 0, line.Trim()));
|
||||
_subtitle.Paragraphs.Add(new Paragraph(line.Trim(), 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1941,11 +1941,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SaveSubtitleListviewIndices();
|
||||
if (onlySelectedLines)
|
||||
{
|
||||
var selectedLines = new Subtitle { WasLoadedWithFrameNumbers = _subtitle.WasLoadedWithFrameNumbers };
|
||||
var selectedLines = new Subtitle();
|
||||
Subtitle selectedLinesAlternate = null;
|
||||
if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
|
||||
{
|
||||
selectedLinesAlternate = new Subtitle { WasLoadedWithFrameNumbers = _subtitle.WasLoadedWithFrameNumbers };
|
||||
selectedLinesAlternate = new Subtitle();
|
||||
}
|
||||
|
||||
foreach (int index in SubtitleListview1.SelectedIndices)
|
||||
@ -2011,20 +2011,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
toolStripComboBoxFrameRate.Text = string.Format("{0:0.###}", visualSync.FrameRate);
|
||||
}
|
||||
|
||||
if (IsFramesRelevant && CurrentFrameRate > 0)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
if (_subtitleAlternate != null)
|
||||
{
|
||||
_subtitleAlternate.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
}
|
||||
|
||||
if (tabControlSubtitle.SelectedIndex == TabControlSourceView)
|
||||
{
|
||||
ShowSource();
|
||||
}
|
||||
}
|
||||
|
||||
ShowSource();
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
RestoreSubtitleListviewIndices();
|
||||
@ -2885,15 +2871,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
_fileDateTime = File.GetLastWriteTime(fileName);
|
||||
|
||||
if (format != null && format.IsFrameBased)
|
||||
{
|
||||
_subtitle.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
}
|
||||
|
||||
if (format != null)
|
||||
{
|
||||
new BookmarkPersistence(_subtitle, fileName).Load();
|
||||
@ -3207,8 +3184,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
FileNew();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat);
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -3241,8 +3216,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
FileNew();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat);
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -3275,8 +3248,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
FileNew();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat);
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -3309,8 +3280,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
FileNew();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat);
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -3340,8 +3309,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
FileNew();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat);
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -4087,16 +4054,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Network);
|
||||
}
|
||||
|
||||
// Recalculate time.
|
||||
if (!_oldSubtitleFormat.IsFrameBased && format.IsFrameBased)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate); // Milliseconds to frames
|
||||
}
|
||||
else if (_oldSubtitleFormat.IsFrameBased && !format.IsFrameBased)
|
||||
{
|
||||
_subtitle.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate); // Frame to Milliseconds.
|
||||
}
|
||||
}
|
||||
|
||||
ShowSource();
|
||||
@ -4244,15 +4201,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SubtitleFormat format = GetCurrentSubtitleFormat();
|
||||
if (format != null)
|
||||
{
|
||||
if (format.IsFrameBased)
|
||||
{
|
||||
_subtitle.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
}
|
||||
|
||||
textBoxSource.TextChanged -= TextBoxSourceTextChanged;
|
||||
textBoxSource.Text = GetSaveSubtitle(_subtitle).ToText(format);
|
||||
textBoxSource.TextChanged += TextBoxSourceTextChanged;
|
||||
@ -4830,16 +4778,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
ShowSource();
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
|
||||
SubtitleFormat format = Utilities.GetSubtitleFormatByFriendlyName(comboBoxSubtitleFormats.SelectedItem.ToString());
|
||||
if (_subtitle.WasLoadedWithFrameNumbers && format.IsTimeBased)
|
||||
{
|
||||
MessageBox.Show(string.Format(_language.NewFrameRateUsedToCalculateTimeCodes, info.FramesPerSecond));
|
||||
}
|
||||
else if (!_subtitle.WasLoadedWithFrameNumbers && format.IsFrameBased)
|
||||
{
|
||||
MessageBox.Show(string.Format(_language.NewFrameRateUsedToCalculateFrameNumbers, info.FramesPerSecond));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5822,10 +5761,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_sourceViewChange = false;
|
||||
MakeHistoryForUndo(_language.BeforeChangesMadeInSourceView);
|
||||
_subtitle.ReloadLoadSubtitle(list, null, format);
|
||||
if (format.IsFrameBased)
|
||||
{
|
||||
_subtitle.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
foreach (string formatName in comboBoxSubtitleFormats.Items)
|
||||
@ -6018,15 +5953,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
SaveSubtitleListviewIndices();
|
||||
if (IsFramesRelevant && CurrentFrameRate > 0)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
if (tabControlSubtitle.SelectedIndex == TabControlSourceView)
|
||||
{
|
||||
ShowSource();
|
||||
}
|
||||
}
|
||||
|
||||
ShowSource();
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
RestoreSubtitleListviewIndices();
|
||||
@ -6034,11 +5960,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsFramesRelevant
|
||||
{
|
||||
get { return _subtitle.WasLoadedWithFrameNumbers || GetCurrentSubtitleFormat().IsFrameBased; }
|
||||
}
|
||||
|
||||
private void FixToolStripMenuItemClick(object sender, EventArgs e)
|
||||
{
|
||||
if (_networkSession == null)
|
||||
@ -6057,7 +5978,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (onlySelectedLines)
|
||||
{
|
||||
var selectedLines = new Subtitle { WasLoadedWithFrameNumbers = _subtitle.WasLoadedWithFrameNumbers };
|
||||
var selectedLines = new Subtitle();
|
||||
foreach (int index in SubtitleListview1.SelectedIndices)
|
||||
{
|
||||
selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]);
|
||||
@ -6330,15 +6251,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
format = cavena890;
|
||||
}
|
||||
}
|
||||
|
||||
if (GetCurrentSubtitleFormat().IsFrameBased)
|
||||
{
|
||||
subtitleToAppend.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
subtitleToAppend.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -6361,11 +6273,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
MakeHistoryForUndo(_language.BeforeAppend);
|
||||
foreach (var p in visualSync.Paragraphs)
|
||||
{
|
||||
if (format.IsFrameBased)
|
||||
{
|
||||
p.CalculateFrameNumbersFromTimeCodes(fr);
|
||||
}
|
||||
|
||||
_subtitle.Paragraphs.Add(new Paragraph(p));
|
||||
}
|
||||
|
||||
@ -6451,7 +6358,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (onlySelectedLines)
|
||||
{
|
||||
var selectedLines = new Subtitle { WasLoadedWithFrameNumbers = _subtitle.WasLoadedWithFrameNumbers };
|
||||
var selectedLines = new Subtitle();
|
||||
foreach (int index in SubtitleListview1.SelectedIndices)
|
||||
{
|
||||
selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]);
|
||||
@ -8260,12 +8167,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
if (GetCurrentSubtitleFormat().IsFrameBased)
|
||||
{
|
||||
newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
|
||||
if (_networkSession != null)
|
||||
{
|
||||
_networkSession.TimerStop();
|
||||
@ -8389,12 +8290,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
if (GetCurrentSubtitleFormat().IsFrameBased)
|
||||
{
|
||||
newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
|
||||
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
|
||||
{
|
||||
var currentOriginal = Utilities.GetOriginalParagraph(firstSelectedIndex - 1, _subtitle.Paragraphs[firstSelectedIndex - 1], _subtitleAlternate.Paragraphs);
|
||||
@ -9955,18 +9850,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetCurrentSubtitleFormat().IsFrameBased)
|
||||
{
|
||||
if (currentParagraph != null)
|
||||
{
|
||||
currentParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
currentParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
|
||||
newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
|
||||
_subtitle.Paragraphs.Insert(firstSelectedIndex + 1, newParagraph);
|
||||
_subtitle.Renumber();
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
@ -10634,12 +10517,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
p.EndTime.TotalMilliseconds += (startTime.TotalMilliseconds - p.StartTime.TotalMilliseconds);
|
||||
p.StartTime = startTime;
|
||||
SubtitleListview1.SetStartTimeAndDuration(_subtitleListViewIndex, p, _subtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1), _subtitle.GetParagraphOrDefault(_subtitleListViewIndex - 1));
|
||||
if (GetCurrentSubtitleFormat().IsFrameBased)
|
||||
{
|
||||
p.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
p.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
|
||||
StartUpdateListSyntaxColoring();
|
||||
}
|
||||
}
|
||||
@ -10829,12 +10706,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
StartUpdateListSyntaxColoring();
|
||||
|
||||
if (GetCurrentSubtitleFormat().IsFrameBased)
|
||||
{
|
||||
currentParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
currentParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
}
|
||||
|
||||
labelStatus.Text = string.Empty;
|
||||
@ -11662,12 +11533,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_subtitle.Paragraphs.RemoveAt(index);
|
||||
foreach (var tp in typewriter.TypewriterParagraphs)
|
||||
{
|
||||
if (isframeBased)
|
||||
{
|
||||
tp.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
tp.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
|
||||
_subtitle.Paragraphs.Insert(index, tp);
|
||||
index++;
|
||||
}
|
||||
@ -11711,12 +11576,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_subtitle.Paragraphs.RemoveAt(index);
|
||||
foreach (var kp in karaoke.MakeAnimation(p))
|
||||
{
|
||||
if (isframeBased)
|
||||
{
|
||||
p.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
p.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
|
||||
_subtitle.Paragraphs.Insert(index, kp);
|
||||
index++;
|
||||
}
|
||||
@ -11982,7 +11841,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SetEncoding(Encoding.UTF8);
|
||||
ShowStatus(_language.SubtitleImportedFromMatroskaFile);
|
||||
_subtitle.Renumber();
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
if (matroska.Path.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase) || matroska.Path.EndsWith(".mks", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_fileName = matroska.Path.Remove(matroska.Path.Length - 4) + format.Extension;
|
||||
@ -12063,7 +11921,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SetEncoding(Encoding.UTF8);
|
||||
ShowStatus(_language.SubtitleImportedFromMatroskaFile);
|
||||
_subtitle.Renumber();
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
if (matroska.Path.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase) || matroska.Path.EndsWith(".mks", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_fileName = matroska.Path.Remove(matroska.Path.Length - 4) + GetCurrentSubtitleFormat().Extension;
|
||||
@ -12199,7 +12056,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
ResetSubtitle();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -12297,7 +12153,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
ResetSubtitle();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -12410,8 +12265,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
_subtitle.Paragraphs.Clear();
|
||||
SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat);
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -12473,8 +12326,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
_subtitle.Paragraphs.Clear();
|
||||
SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat);
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -12578,8 +12429,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
_subtitle.Paragraphs.Clear();
|
||||
SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat);
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -12729,7 +12578,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile);
|
||||
_subtitleListViewIndex = -1;
|
||||
FileNew();
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -12795,7 +12643,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile);
|
||||
_subtitleListViewIndex = -1;
|
||||
FileNew();
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -12826,7 +12673,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SetEncoding(Encoding.UTF8);
|
||||
ShowStatus(_language.SubtitleImportedFromMatroskaFile);
|
||||
_subtitle.Renumber();
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
if (fileName.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase) || fileName.EndsWith(".m4v", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_fileName = fileName.Substring(0, fileName.Length - 4) + GetCurrentSubtitleFormat().Extension;
|
||||
@ -13063,7 +12909,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
var selectedLines = new Subtitle();
|
||||
var selectedIndices = SubtitleListview1.SelectedIndices.Cast<int>().ToList();
|
||||
selectedLines.WasLoadedWithFrameNumbers = _subtitle.WasLoadedWithFrameNumbers;
|
||||
if (onlySelectedLines)
|
||||
{
|
||||
foreach (int index in SubtitleListview1.SelectedIndices)
|
||||
@ -13100,7 +12945,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
selectedLines = allUpperSubtitle;
|
||||
onlySelectedLines = true;
|
||||
selectedLines.WasLoadedWithFrameNumbers = _subtitle.WasLoadedWithFrameNumbers;
|
||||
}
|
||||
|
||||
changeCasing.FixCasing(selectedLines, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle));
|
||||
@ -13284,8 +13128,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
FileNew();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat);
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
foreach (var p in vobSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -13328,8 +13170,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
FileNew();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat);
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
foreach (var p in vobSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -14141,7 +13981,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (ContinueNewOrExit())
|
||||
{
|
||||
var subtitle = new Subtitle();
|
||||
subtitle.WasLoadedWithFrameNumbers = _subtitle.WasLoadedWithFrameNumbers;
|
||||
var fr = CurrentFrameRate;
|
||||
var format = GetCurrentSubtitleFormat();
|
||||
var videoFileName = _videoFileName;
|
||||
@ -14170,12 +14009,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
OpenVideo(videoFileName);
|
||||
}
|
||||
|
||||
if (IsFramesRelevant && CurrentFrameRate > 0)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
}
|
||||
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
}
|
||||
@ -15449,15 +15282,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
if (IsFramesRelevant && CurrentFrameRate > 0)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
if (tabControlSubtitle.SelectedIndex == TabControlSourceView)
|
||||
{
|
||||
ShowSource();
|
||||
}
|
||||
}
|
||||
|
||||
checkBoxSyncListViewWithVideoWhilePlaying.Checked = oldSync;
|
||||
|
||||
if (goToNext)
|
||||
@ -16487,8 +16311,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
FileNew();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat);
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -16756,7 +16578,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
ShowStatus(string.Format(_language.XMinimumDisplayTimeBetweenParagraphsChanged, setMinDisplayDiff.FixCount));
|
||||
SaveSubtitleListviewIndices();
|
||||
ShowSource();
|
||||
@ -16800,7 +16621,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
_subtitle = new Subtitle(importText.FixedSubtitle.Paragraphs, _subtitle.HistoryItems);
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
ShowStatus(_language.TextImported);
|
||||
ShowSource();
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
@ -16831,8 +16651,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
ShowStatus(_language.PointSynchronizationDone);
|
||||
ShowSource();
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
@ -16989,8 +16807,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
ShowStatus(_language.PointSynchronizationDone);
|
||||
ShowSource();
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
@ -17067,15 +16883,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
MakeHistoryForUndo(_language.BeforeTimeCodeImport);
|
||||
|
||||
if (GetCurrentSubtitleFormat().IsFrameBased)
|
||||
{
|
||||
timeCodeSubtitle.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeCodeSubtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < timeCodeSubtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
@ -17096,15 +16903,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
existing.StartTime.TotalMilliseconds = newTimeCode.StartTime.TotalMilliseconds;
|
||||
existing.EndTime.TotalMilliseconds = newTimeCode.EndTime.TotalMilliseconds;
|
||||
existing.StartFrame = newTimeCode.StartFrame;
|
||||
existing.EndFrame = newTimeCode.EndFrame;
|
||||
|
||||
if (original != null)
|
||||
{
|
||||
original.StartTime.TotalMilliseconds = newTimeCode.StartTime.TotalMilliseconds;
|
||||
original.EndTime.TotalMilliseconds = newTimeCode.EndTime.TotalMilliseconds;
|
||||
original.StartFrame = newTimeCode.StartFrame;
|
||||
original.EndFrame = newTimeCode.EndFrame;
|
||||
}
|
||||
|
||||
count++;
|
||||
@ -17225,15 +17028,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return false;
|
||||
}
|
||||
|
||||
if (format.IsFrameBased)
|
||||
{
|
||||
_subtitleAlternate.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
_subtitleAlternate.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
}
|
||||
|
||||
SetupAlternateEdit();
|
||||
FixRightToLeftDependingOnLanguage();
|
||||
return true;
|
||||
@ -18069,14 +17863,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
UpdateOriginalTimeCodes(oldParagraph);
|
||||
if (IsFramesRelevant && CurrentFrameRate > 0)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
if (tabControlSubtitle.SelectedIndex == TabControlSourceView)
|
||||
{
|
||||
ShowSource();
|
||||
}
|
||||
}
|
||||
ShowSource();
|
||||
}
|
||||
}
|
||||
|
||||
@ -18160,12 +17947,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
// create and insert
|
||||
var newParagraph = new Paragraph(string.Empty, videoPositionInMilliseconds, videoPositionInMilliseconds + Configuration.Settings.General.NewEmptyDefaultMs);
|
||||
SetStyleForNewParagraph(newParagraph, index);
|
||||
if (GetCurrentSubtitleFormat().IsFrameBased)
|
||||
{
|
||||
newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
|
||||
if (_networkSession != null)
|
||||
{
|
||||
_networkSession.TimerStop();
|
||||
@ -18490,11 +18271,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
SubtitleListview1.EndUpdate();
|
||||
if (_subtitle.WasLoadedWithFrameNumbers)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(frameRate);
|
||||
}
|
||||
|
||||
RefreshSelectedParagraph();
|
||||
UpdateSourceView();
|
||||
UpdateListSyntaxColoring();
|
||||
@ -19039,15 +18815,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
if (IsFramesRelevant && CurrentFrameRate > 0)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
if (tabControlSubtitle.SelectedIndex == TabControlSourceView)
|
||||
{
|
||||
ShowSource();
|
||||
}
|
||||
}
|
||||
|
||||
ShowSource();
|
||||
checkBoxSyncListViewWithVideoWhilePlaying.Checked = oldSync;
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged;
|
||||
}
|
||||
@ -19094,15 +18862,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (index + 1 < _subtitle.Paragraphs.Count)
|
||||
{
|
||||
if (IsFramesRelevant && CurrentFrameRate > 0)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
if (tabControlSubtitle.SelectedIndex == TabControlSourceView)
|
||||
{
|
||||
ShowSource();
|
||||
}
|
||||
}
|
||||
|
||||
SubtitleListview1.SelectIndexAndEnsureVisible(index + 1, true);
|
||||
}
|
||||
|
||||
@ -19689,15 +19448,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SubtitleFormat format = GetCurrentSubtitleFormat();
|
||||
if (format != null)
|
||||
{
|
||||
if (format.IsFrameBased)
|
||||
{
|
||||
_subtitle.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
}
|
||||
|
||||
rawText = _subtitle.ToText(format);
|
||||
}
|
||||
|
||||
@ -19835,7 +19585,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
SaveSubtitleListviewIndices();
|
||||
var selectedLines = new Subtitle { WasLoadedWithFrameNumbers = _subtitle.WasLoadedWithFrameNumbers };
|
||||
var selectedLines = new Subtitle();
|
||||
foreach (int index in SubtitleListview1.SelectedIndices)
|
||||
{
|
||||
var p = _subtitle.Paragraphs[index];
|
||||
@ -19859,15 +19609,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SubtitleFormat format = GetCurrentSubtitleFormat();
|
||||
if (format != null)
|
||||
{
|
||||
if (format.IsFrameBased)
|
||||
{
|
||||
selectedLines.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedLines.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
}
|
||||
|
||||
rawText = selectedLines.ToText(format);
|
||||
}
|
||||
|
||||
@ -20271,12 +20012,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
// create and insert
|
||||
var format = GetCurrentSubtitleFormat();
|
||||
if (format.IsFrameBased)
|
||||
{
|
||||
newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
|
||||
if (_networkSession != null)
|
||||
{
|
||||
_networkSession.TimerStop();
|
||||
@ -20640,8 +20375,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
FileNew();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat);
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
foreach (var p in vobSubOcr.SubtitleFromOcr.Paragraphs)
|
||||
{
|
||||
_subtitle.Paragraphs.Add(p);
|
||||
@ -21896,15 +21629,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (format != null)
|
||||
{
|
||||
SaveSubtitleListviewIndices();
|
||||
if (format.IsFrameBased)
|
||||
{
|
||||
subtitle.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
}
|
||||
|
||||
if (Configuration.Settings.General.RemoveBlankLinesWhenOpening)
|
||||
{
|
||||
subtitle.RemoveEmptyLines();
|
||||
@ -23762,7 +23486,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (onlySelectedLines)
|
||||
{
|
||||
var selectedLines = new Subtitle { WasLoadedWithFrameNumbers = _subtitle.WasLoadedWithFrameNumbers };
|
||||
var selectedLines = new Subtitle();
|
||||
foreach (int index in SubtitleListview1.SelectedIndices)
|
||||
{
|
||||
selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]);
|
||||
@ -23803,12 +23527,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
RestoreSubtitleListviewIndices();
|
||||
}
|
||||
|
||||
if (IsFramesRelevant && CurrentFrameRate > 0)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
}
|
||||
|
||||
ShowSource();
|
||||
}
|
||||
}
|
||||
@ -23834,14 +23552,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
SubtitleListview1.SelectIndexAndEnsureVisible(0, true);
|
||||
|
||||
if (IsFramesRelevant && CurrentFrameRate > 0)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
}
|
||||
|
||||
ShowSource();
|
||||
|
||||
OpenVideo(extractDateTimeInfo.VideoFileName);
|
||||
}
|
||||
}
|
||||
@ -23900,14 +23611,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SetCurrentFormat(joinSubtitles.JoinedFormat);
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
SubtitleListview1.SelectIndexAndEnsureVisible(0, true);
|
||||
|
||||
if (IsFramesRelevant && CurrentFrameRate > 0)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
}
|
||||
|
||||
ShowSource();
|
||||
|
||||
ShowStatus(_language.SubtitlesJoined);
|
||||
}
|
||||
}
|
||||
@ -24600,11 +24304,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
audioVisualizer.GenerateTimeCodes(_subtitle, startFromSeconds, form.BlockSize, form.VolumeMinimum, form.VolumeMaximum, form.DefaultMilliseconds);
|
||||
if (IsFramesRelevant && CurrentFrameRate > 0)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
}
|
||||
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
RefreshSelectedParagraph();
|
||||
}
|
||||
@ -24681,7 +24380,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
foreach (var line in text.SplitToLines())
|
||||
{
|
||||
tmp.Paragraphs.Add(new Paragraph(0, 0, line));
|
||||
tmp.Paragraphs.Add(new Paragraph(line, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -24709,8 +24408,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
_subtitle.Paragraphs[k + 1].StartTime.TotalMilliseconds = _subtitle.Paragraphs[k].StartTime.TotalMilliseconds;
|
||||
_subtitle.Paragraphs[k + 1].EndTime.TotalMilliseconds = _subtitle.Paragraphs[k].EndTime.TotalMilliseconds;
|
||||
_subtitle.Paragraphs[k + 1].StartFrame = _subtitle.Paragraphs[k].StartFrame;
|
||||
_subtitle.Paragraphs[k + 1].EndFrame = _subtitle.Paragraphs[k].EndFrame;
|
||||
}
|
||||
}
|
||||
else if (form.PasteTextOnly)
|
||||
@ -24954,15 +24651,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (format != null)
|
||||
{
|
||||
if (format.IsFrameBased)
|
||||
{
|
||||
tmp.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
}
|
||||
|
||||
if (Configuration.Settings.General.RemoveBlankLinesWhenOpening)
|
||||
{
|
||||
tmp.RemoveEmptyLines();
|
||||
@ -24990,12 +24678,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
_subtitle.Paragraphs[index + i].Text = tmp.Paragraphs[i].Text;
|
||||
}
|
||||
|
||||
if (IsFramesRelevant && CurrentFrameRate > 0)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
}
|
||||
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
SubtitleListview1.SelectIndexAndEnsureVisible(index, true);
|
||||
RefreshSelectedParagraph();
|
||||
@ -25056,11 +24738,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
if (IsFramesRelevant && CurrentFrameRate > 0)
|
||||
{
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
}
|
||||
|
||||
ShowSource();
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
RestoreSubtitleListviewIndices();
|
||||
@ -25879,12 +25556,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
newParagraph.EndTime.TotalMilliseconds = cur.EndTime.TotalMilliseconds;
|
||||
newParagraph.Text = cur.Text;
|
||||
|
||||
if (GetCurrentSubtitleFormat().IsFrameBased)
|
||||
{
|
||||
newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
|
||||
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
|
||||
{
|
||||
var currentOriginal = Utilities.GetOriginalParagraph(firstSelectedIndex - 1, _subtitle.Paragraphs[firstSelectedIndex - 1], _subtitleAlternate.Paragraphs);
|
||||
@ -26056,14 +25727,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (format != null && subtitle.Paragraphs.Count > 0)
|
||||
{
|
||||
SaveSubtitleListviewIndices();
|
||||
if (format.IsFrameBased)
|
||||
{
|
||||
subtitle.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
|
||||
}
|
||||
|
||||
if (Configuration.Settings.General.RemoveBlankLinesWhenOpening)
|
||||
{
|
||||
|
@ -127,11 +127,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (saveFileDialog1.FilterIndex == index + 1)
|
||||
{
|
||||
if (format.IsFrameBased)
|
||||
{
|
||||
part.CalculateFrameNumbersFromTimeCodesNoCheck(Configuration.Settings.General.CurrentFrameRate);
|
||||
}
|
||||
|
||||
File.WriteAllText(fileName, part.ToText(format), _encoding);
|
||||
}
|
||||
index++;
|
||||
|
@ -146,27 +146,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
VideoInfo videoInfo = ShowVideoInfo(fileName);
|
||||
|
||||
// be sure to match frames with movie
|
||||
if (_inputSubtitle.WasLoadedWithFrameNumbers) // frame based subtitles like MicroDVD
|
||||
{
|
||||
if (Math.Abs(_videoInfo.FramesPerSecond - _oldFrameRate) > 0.02)
|
||||
{
|
||||
_inputSubtitle.CalculateTimeCodesFromFrameNumbers(_videoInfo.FramesPerSecond);
|
||||
LoadAndShowOriginalSubtitle();
|
||||
FrameRateChanged = true;
|
||||
}
|
||||
}
|
||||
if (_inputAlternateSubtitle != null && _inputAlternateSubtitle.WasLoadedWithFrameNumbers) // frame based subtitles like MicroDVD
|
||||
{
|
||||
if (Math.Abs(_videoInfo.FramesPerSecond - _oldFrameRate) > 0.02)
|
||||
{
|
||||
_inputAlternateSubtitle.CalculateTimeCodesFromFrameNumbers(_videoInfo.FramesPerSecond);
|
||||
LoadAndShowOriginalSubtitle();
|
||||
FrameRateChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
UiUtil.InitializeVideoPlayerAndContainer(fileName, videoInfo, MediaPlayerStart, VideoStartLoaded, VideoStartEnded);
|
||||
}
|
||||
}
|
||||
@ -484,7 +463,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
// fix overlapping time codes
|
||||
var tmpSubtitle = new Subtitle { WasLoadedWithFrameNumbers = _inputSubtitle.WasLoadedWithFrameNumbers };
|
||||
var tmpSubtitle = new Subtitle();
|
||||
foreach (Paragraph p in _paragraphs)
|
||||
{
|
||||
tmpSubtitle.Paragraphs.Add(new Paragraph(p));
|
||||
@ -496,7 +475,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
// fix overlapping time codes for alternate subtitle (translation)
|
||||
if (_inputAlternateSubtitle != null)
|
||||
{
|
||||
tmpSubtitle = new Subtitle { WasLoadedWithFrameNumbers = _inputAlternateSubtitle.WasLoadedWithFrameNumbers };
|
||||
tmpSubtitle = new Subtitle();
|
||||
foreach (Paragraph p in _paragraphsAlternate)
|
||||
{
|
||||
tmpSubtitle.Paragraphs.Add(new Paragraph(p));
|
||||
|
@ -1161,14 +1161,6 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
||||
sf.BatchMode = true;
|
||||
outputFileName = FormatOutputFileNameForBatchConvert(fileName, sf.Extension, outputFolder, overwrite);
|
||||
_stdOutWriter?.Write($"{count}: {Path.GetFileName(fileName)} -> {outputFileName}...");
|
||||
if (sf.IsFrameBased && !sub.WasLoadedWithFrameNumbers)
|
||||
{
|
||||
sub.CalculateFrameNumbersFromTimeCodesNoCheck(Configuration.Settings.General.CurrentFrameRate);
|
||||
}
|
||||
else if (sf.IsTimeBased && sub.WasLoadedWithFrameNumbers)
|
||||
{
|
||||
sub.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
|
||||
}
|
||||
|
||||
if (sf.GetType() == typeof(WebVTT) || sf.GetType() == typeof(WebVTTFileWithLineNumber))
|
||||
{
|
||||
|
@ -1124,8 +1124,8 @@ Dialogue: Marked=0,0:00:01.00,0:00:03.00,Default,NTP,0000,0000,0000,!Effect," +
|
||||
Assert.AreEqual("Yeah. The Drama Club is worried\r\nthat you haven't been coming.", subtitle.Paragraphs[1].Text);
|
||||
|
||||
// Test frames.
|
||||
Assert.AreEqual(SubtitleFormat.FramesToMilliseconds(2447), SubtitleFormat.FramesToMilliseconds(subtitle.Paragraphs[0].StartFrame));
|
||||
Assert.AreEqual(SubtitleFormat.FramesToMilliseconds(2513), SubtitleFormat.FramesToMilliseconds(subtitle.Paragraphs[0].EndFrame));
|
||||
Assert.AreEqual(SubtitleFormat.FramesToMilliseconds(2447), subtitle.Paragraphs[0].StartTime.TotalMilliseconds);
|
||||
Assert.AreEqual(SubtitleFormat.FramesToMilliseconds(2513), subtitle.Paragraphs[0].EndTime.TotalMilliseconds);
|
||||
|
||||
// Test total lines.
|
||||
Assert.AreEqual(2, subtitle.Paragraphs[1].NumberOfLines);
|
||||
@ -1160,7 +1160,7 @@ and astronauts.“...""
|
||||
// Test line count.
|
||||
Assert.AreEqual(2, subtitle.Paragraphs[2].NumberOfLines);
|
||||
// Test frame.
|
||||
Assert.AreEqual(3082, subtitle.Paragraphs[1].StartFrame);
|
||||
Assert.AreEqual(3082, SubtitleFormat.MillisecondsToFrames(subtitle.Paragraphs[1].StartTime.TotalMilliseconds));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -1480,11 +1480,11 @@ VÄLKOMMEN TILL TEXAS
|
||||
{
|
||||
var target = new WebVTT();
|
||||
var subtitle = new Subtitle();
|
||||
subtitle.Paragraphs.Add(new Paragraph(0, 0, "<i>R&D</i>"));
|
||||
subtitle.Paragraphs.Add(new Paragraph(0, 0, "i<5"));
|
||||
subtitle.Paragraphs.Add(new Paragraph(0, 0, "i>6"));
|
||||
subtitle.Paragraphs.Add(new Paragraph(0, 0, "<v Viggo>Hallo"));
|
||||
subtitle.Paragraphs.Add(new Paragraph(0, 0, "‏<c.arabic>مسلسلات NETFLIX ألاصلية</c.arabic>"));
|
||||
subtitle.Paragraphs.Add(new Paragraph("<i>R&D</i>", 0, 0));
|
||||
subtitle.Paragraphs.Add(new Paragraph("i<5", 0, 0));
|
||||
subtitle.Paragraphs.Add(new Paragraph("i>6", 0, 0));
|
||||
subtitle.Paragraphs.Add(new Paragraph("<v Viggo>Hallo", 0, 0));
|
||||
subtitle.Paragraphs.Add(new Paragraph("‏<c.arabic>مسلسلات NETFLIX ألاصلية</c.arabic>", 0, 0));
|
||||
var raw = subtitle.ToText(target);
|
||||
Assert.IsTrue(raw.Contains("<i>R&D</i>"));
|
||||
Assert.IsTrue(raw.Contains("i<5"));
|
||||
|
Loading…
Reference in New Issue
Block a user