mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
Minor optimization for Paragraph.Duration - thx ivandrofly :)
Fix #7054
This commit is contained in:
parent
04c7ca55ab
commit
c87ed8eade
@ -65,7 +65,7 @@ namespace Test.Logic
|
||||
public void TestDuration()
|
||||
{
|
||||
var p = new Paragraph { Text = string.Empty, StartTime = new TimeCode(0, 1, 0, 0), EndTime = new TimeCode(0, 1, 1, 1) };
|
||||
Assert.AreEqual(p.Duration.TotalMilliseconds, 1001);
|
||||
Assert.AreEqual(p.DurationTotalMilliseconds, 1001);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -65,11 +65,11 @@ namespace Test.Logic
|
||||
Assert.AreEqual("and laugh it off to realise that\r\nlife isn’t so bad after all.", procSubtitle.Paragraphs[6].Text);
|
||||
|
||||
// timing test
|
||||
if (procSubtitle.Paragraphs[5].Duration.TotalMilliseconds > procSubtitle.Paragraphs[6].Duration.TotalMilliseconds)
|
||||
if (procSubtitle.Paragraphs[5].DurationTotalMilliseconds > procSubtitle.Paragraphs[6].DurationTotalMilliseconds)
|
||||
{
|
||||
Assert.IsTrue(procSubtitle.Paragraphs[5].Text.Length > procSubtitle.Paragraphs[6].Text.Length);
|
||||
}
|
||||
if (procSubtitle.Paragraphs[5].Duration.TotalMilliseconds < procSubtitle.Paragraphs[6].Duration.TotalMilliseconds)
|
||||
if (procSubtitle.Paragraphs[5].DurationTotalMilliseconds < procSubtitle.Paragraphs[6].DurationTotalMilliseconds)
|
||||
{
|
||||
Assert.IsTrue(procSubtitle.Paragraphs[5].Text.Length < procSubtitle.Paragraphs[6].Text.Length);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
var pctHere = FindPercentage(startPos - 0.05, startPos + 0.05, wavePeaks);
|
||||
if (Math.Abs(pctHere - (-1)) < 0.01)
|
||||
{
|
||||
if (p.Duration.TotalMilliseconds < minDurationMs)
|
||||
if (p.DurationTotalMilliseconds < minDurationMs)
|
||||
{
|
||||
s.Paragraphs[index] = oldP;
|
||||
}
|
||||
@ -78,7 +78,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
var pct = FindPercentage(startPosBack - 0.05, startPosBack + 0.05, wavePeaks);
|
||||
if (Math.Abs(pct - (-1)) < 0.01)
|
||||
{
|
||||
if (p.Duration.TotalMilliseconds < minDurationMs)
|
||||
if (p.DurationTotalMilliseconds < minDurationMs)
|
||||
{
|
||||
s.Paragraphs[index] = oldP;
|
||||
}
|
||||
@ -86,7 +86,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
return s;
|
||||
}
|
||||
|
||||
if (pct < percentageMax + 1 && p.Duration.TotalSeconds < 5)
|
||||
if (pct < percentageMax + 1 && p.DurationTotalSeconds < 5)
|
||||
{
|
||||
startPosBack -= 0.025;
|
||||
var pct2 = FindPercentage(startPosBack - 0.05, startPosBack + 0.05, wavePeaks);
|
||||
@ -127,7 +127,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
var pctF = FindPercentage(startPosForward - 0.05, startPosForward + 0.05, wavePeaks);
|
||||
if (Math.Abs(pctF - (-1)) < 0.01)
|
||||
{
|
||||
if (p.Duration.TotalMilliseconds < minDurationMs)
|
||||
if (p.DurationTotalMilliseconds < minDurationMs)
|
||||
{
|
||||
s.Paragraphs[index] = oldP;
|
||||
}
|
||||
@ -160,7 +160,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
pctHere = FindPercentage(startPos - 0.05, startPos + 0.05, wavePeaks);
|
||||
if (Math.Abs(pctHere - (-1)) < 0.01)
|
||||
{
|
||||
if (p.Duration.TotalMilliseconds < minDurationMs)
|
||||
if (p.DurationTotalMilliseconds < minDurationMs)
|
||||
{
|
||||
s.Paragraphs[index] = oldP;
|
||||
}
|
||||
@ -176,7 +176,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
pctHere = FindPercentage(startPosForward - 0.05, startPosForward + 0.05, wavePeaks);
|
||||
if (Math.Abs(pctHere - (- 1)) < 0.01)
|
||||
{
|
||||
if (p.Duration.TotalMilliseconds < 1000)
|
||||
if (p.DurationTotalMilliseconds < 1000)
|
||||
{
|
||||
s.Paragraphs[index] = oldP;
|
||||
}
|
||||
@ -209,7 +209,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
}
|
||||
}
|
||||
|
||||
if (p.Duration.TotalMilliseconds < minDurationMs)
|
||||
if (p.DurationTotalMilliseconds < minDurationMs)
|
||||
{
|
||||
s.Paragraphs[index] = oldP;
|
||||
}
|
||||
@ -225,7 +225,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
for (var i = 0; i < subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
var p = subtitle.Paragraphs[i];
|
||||
if (p.Duration.TotalMilliseconds > 8000)
|
||||
if (p.DurationTotalMilliseconds > 8000)
|
||||
{
|
||||
p.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds - 5000;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
var p = subtitle.Paragraphs[i];
|
||||
var displayTime = p.Duration.TotalMilliseconds;
|
||||
var displayTime = p.DurationTotalMilliseconds;
|
||||
if (displayTime < _minDurationMs)
|
||||
{
|
||||
var next = subtitle.GetParagraphOrDefault(i + 1);
|
||||
@ -42,7 +42,7 @@
|
||||
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
var p = subtitle.Paragraphs[i];
|
||||
var displayTime = p.Duration.TotalMilliseconds;
|
||||
var displayTime = p.DurationTotalMilliseconds;
|
||||
if (displayTime > _maxDurationMs)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + _maxDurationMs;
|
||||
|
@ -14,6 +14,8 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
public TimeCode EndTime { get; set; }
|
||||
|
||||
public TimeCode Duration => new TimeCode(EndTime.TotalMilliseconds - StartTime.TotalMilliseconds);
|
||||
public double DurationTotalMilliseconds => EndTime.TotalMilliseconds - StartTime.TotalMilliseconds;
|
||||
public double DurationTotalSeconds => (EndTime.TotalMilliseconds - StartTime.TotalMilliseconds) / TimeCode.BaseUnit;
|
||||
|
||||
public bool Forced { get; set; }
|
||||
|
||||
@ -119,7 +121,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 60.0 / Duration.TotalSeconds * Text.CountWords();
|
||||
return 60.0 / DurationTotalSeconds * Text.CountWords();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
if (next != null && p.StartTime.TotalMilliseconds + duration + Configuration.Settings.General.MinimumMillisecondsBetweenLines > next.StartTime.TotalMilliseconds)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
if (p.Duration.TotalMilliseconds <= 0)
|
||||
if (p.DurationTotalMilliseconds <= 0)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 1;
|
||||
}
|
||||
@ -536,7 +536,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
if (next != null && p.StartTime.TotalMilliseconds + fixedDurationMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines > next.StartTime.TotalMilliseconds)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
if (p.Duration.TotalMilliseconds <= 0)
|
||||
if (p.DurationTotalMilliseconds <= 0)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 1;
|
||||
}
|
||||
@ -730,7 +730,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
Paragraphs = Paragraphs.OrderBy(p => p.EndTime.TotalMilliseconds).ThenBy(p => p.Number).ToList();
|
||||
break;
|
||||
case SubtitleSortCriteria.Duration:
|
||||
Paragraphs = Paragraphs.OrderBy(p => p.Duration.TotalMilliseconds).ThenBy(p => p.Number).ToList();
|
||||
Paragraphs = Paragraphs.OrderBy(p => p.DurationTotalMilliseconds).ThenBy(p => p.Number).ToList();
|
||||
break;
|
||||
case SubtitleSortCriteria.Gap:
|
||||
var lookupDictionary = new Dictionary<string, double>();
|
||||
|
@ -44,13 +44,13 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
{
|
||||
var sameLineSub = ImportTimeCodesInFramesAndTextOnSameLine(lines);
|
||||
if (sameLineSub.Paragraphs.Count < 10 &&
|
||||
(sameLineSub.Paragraphs.Count(p => p.Duration.TotalMilliseconds < 0) > 2 ||
|
||||
(sameLineSub.Paragraphs.Count(p => p.DurationTotalMilliseconds < 0) > 2 ||
|
||||
sameLineSub.Paragraphs.Count(p => p.Text.Length > 100) > 1))
|
||||
{
|
||||
// probably not a subtitle
|
||||
}
|
||||
else if (sameLineSub.Paragraphs.Count < 20 &&
|
||||
(sameLineSub.Paragraphs.Count(p => p.Duration.TotalMilliseconds < 0) > 8 ||
|
||||
(sameLineSub.Paragraphs.Count(p => p.DurationTotalMilliseconds < 0) > 8 ||
|
||||
sameLineSub.Paragraphs.Count(p => p.Text.Length > 100) > 5))
|
||||
{
|
||||
// probably not a subtitle
|
||||
@ -764,7 +764,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
double averateDuration = 0;
|
||||
foreach (Paragraph a in subtitle.Paragraphs)
|
||||
{
|
||||
double d = a.Duration.TotalSeconds;
|
||||
double d = a.DurationTotalSeconds;
|
||||
if (d > 10)
|
||||
{
|
||||
d = 8;
|
||||
|
@ -108,7 +108,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
int msFound = 0;
|
||||
foreach (var p in subtitle.Paragraphs)
|
||||
{
|
||||
totalDuration += p.Duration.TotalMilliseconds;
|
||||
totalDuration += p.DurationTotalMilliseconds;
|
||||
if (p.Style.Contains("\"startMs\"") ||
|
||||
p.Style.Contains("\"start_ms\"") ||
|
||||
p.Style.Contains("\"startMillis\"") ||
|
||||
|
@ -933,36 +933,33 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
|
||||
public static double GetCharactersPerSecond(Paragraph paragraph)
|
||||
{
|
||||
var duration = paragraph.Duration;
|
||||
if (duration.TotalMilliseconds < 1)
|
||||
if (paragraph.DurationTotalMilliseconds < 1)
|
||||
{
|
||||
return 999;
|
||||
}
|
||||
|
||||
return (double)paragraph.Text.CountCharacters(true) / duration.TotalSeconds;
|
||||
return (double)paragraph.Text.CountCharacters(true) / paragraph.DurationTotalSeconds;
|
||||
}
|
||||
|
||||
public static double GetCharactersPerSecond(Paragraph paragraph, double numberOfCharacters)
|
||||
{
|
||||
var duration = paragraph.Duration;
|
||||
if (duration.TotalMilliseconds < 1)
|
||||
if (paragraph.DurationTotalMilliseconds < 1)
|
||||
{
|
||||
return 999;
|
||||
}
|
||||
|
||||
return numberOfCharacters / duration.TotalSeconds;
|
||||
return numberOfCharacters / paragraph.DurationTotalSeconds;
|
||||
}
|
||||
|
||||
|
||||
public static double GetCharactersPerSecond(Paragraph paragraph, ICalcLength calc)
|
||||
{
|
||||
var duration = paragraph.Duration;
|
||||
if (duration.TotalMilliseconds < 1)
|
||||
if (paragraph.DurationTotalMilliseconds < 1)
|
||||
{
|
||||
return 999;
|
||||
}
|
||||
|
||||
return (double)calc.CountCharacters(paragraph.Text, true) / duration.TotalSeconds;
|
||||
return (double)calc.CountCharacters(paragraph.Text, true) / paragraph.DurationTotalSeconds;
|
||||
}
|
||||
|
||||
public static bool IsRunningOnMono()
|
||||
@ -1259,7 +1256,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
return null;
|
||||
}
|
||||
|
||||
var middle = paragraph.StartTime.TotalMilliseconds + paragraph.Duration.TotalMilliseconds / 2.0;
|
||||
var middle = paragraph.StartTime.TotalMilliseconds + paragraph.DurationTotalMilliseconds / 2.0;
|
||||
if (index < originalParagraphs.Count)
|
||||
{
|
||||
var o = originalParagraphs[index];
|
||||
@ -2661,7 +2658,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
subtitle.Paragraphs[i].Text = subtitle.Paragraphs[i].Text.TrimEnd();
|
||||
if (subtitle.Paragraphs[i].Duration.TotalMilliseconds < 1)
|
||||
if (subtitle.Paragraphs[i].DurationTotalMilliseconds < 1)
|
||||
{
|
||||
// fix subtitles without duration
|
||||
FixShortDisplayTime(subtitle, i);
|
||||
@ -2676,7 +2673,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
{
|
||||
Paragraph p = s.Paragraphs[i];
|
||||
var minDisplayTime = Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds;
|
||||
double displayTime = p.Duration.TotalMilliseconds;
|
||||
double displayTime = p.DurationTotalMilliseconds;
|
||||
if (displayTime < minDisplayTime)
|
||||
{
|
||||
var next = s.GetParagraphOrDefault(i + 1);
|
||||
|
@ -22,7 +22,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
maxDisplayTime = Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds;
|
||||
}
|
||||
|
||||
double displayTime = p.Duration.TotalMilliseconds;
|
||||
double displayTime = p.DurationTotalMilliseconds;
|
||||
|
||||
bool allowFix = callbacks.AllowFix(p, Language.FixLongDisplayTime);
|
||||
if (allowFix && displayTime > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
|
@ -26,7 +26,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
var p = subtitle.Paragraphs[i];
|
||||
var oldP = new Paragraph(p);
|
||||
if (p.Duration.TotalMilliseconds < 0) // negative display time...
|
||||
if (p.DurationTotalMilliseconds < 0) // negative display time...
|
||||
{
|
||||
bool isFixed = false;
|
||||
string status = string.Format(Language.StartTimeLaterThanEndTime, i + 1, p.StartTime, p.EndTime, p.Text, Environment.NewLine);
|
||||
@ -100,18 +100,18 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
int diffHalf = (int)(diff / 2);
|
||||
if (!Configuration.Settings.Tools.FixCommonErrorsFixOverlapAllowEqualEndStart && Math.Abs(p.StartTime.TotalMilliseconds - prev.EndTime.TotalMilliseconds) < 0.001 &&
|
||||
prev.Duration.TotalMilliseconds > 100)
|
||||
prev.DurationTotalMilliseconds > 100)
|
||||
{
|
||||
if (callbacks.AllowFix(target, fixAction))
|
||||
{
|
||||
if (!canBeEqual)
|
||||
{
|
||||
bool okEqual = true;
|
||||
if (prev.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
if (prev.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
{
|
||||
prev.EndTime.TotalMilliseconds--;
|
||||
}
|
||||
else if (p.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
else if (p.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
{
|
||||
p.StartTime.TotalMilliseconds++;
|
||||
}
|
||||
@ -142,8 +142,8 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
callbacks.AddFixToListView(target, fixAction, oldPrevious, prev.ToString());
|
||||
}
|
||||
}
|
||||
else if (diff > 0 && currentOptimalDisplayTime <= p.Duration.TotalMilliseconds - diffHalf &&
|
||||
prevOptimalDisplayTime <= prev.Duration.TotalMilliseconds - diffHalf)
|
||||
else if (diff > 0 && currentOptimalDisplayTime <= p.DurationTotalMilliseconds - diffHalf &&
|
||||
prevOptimalDisplayTime <= prev.DurationTotalMilliseconds - diffHalf)
|
||||
{
|
||||
if (callbacks.AllowFix(p, fixAction))
|
||||
{
|
||||
@ -167,8 +167,8 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
callbacks.AddFixToListView(p, fixAction, oldCurrent, p.ToString());
|
||||
}
|
||||
}
|
||||
else if (diff > 0 && currentWantedDisplayTime <= p.Duration.TotalMilliseconds - diffHalf &&
|
||||
prevWantedDisplayTime <= prev.Duration.TotalMilliseconds - diffHalf)
|
||||
else if (diff > 0 && currentWantedDisplayTime <= p.DurationTotalMilliseconds - diffHalf &&
|
||||
prevWantedDisplayTime <= prev.DurationTotalMilliseconds - diffHalf)
|
||||
{
|
||||
if (callbacks.AllowFix(p, fixAction))
|
||||
{
|
||||
@ -206,7 +206,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
callbacks.AddFixToListView(p, fixAction, oldCurrent, p.ToString());
|
||||
}
|
||||
}
|
||||
else if (Math.Abs(p.StartTime.TotalMilliseconds - prev.EndTime.TotalMilliseconds) < 10 && p.Duration.TotalMilliseconds > 1)
|
||||
else if (Math.Abs(p.StartTime.TotalMilliseconds - prev.EndTime.TotalMilliseconds) < 10 && p.DurationTotalMilliseconds > 1)
|
||||
{
|
||||
if (callbacks.AllowFix(p, fixAction))
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
Paragraph p = subtitle.Paragraphs[i];
|
||||
var skip = p.StartTime.IsMaxTime || p.EndTime.IsMaxTime;
|
||||
double displayTime = p.Duration.TotalMilliseconds;
|
||||
double displayTime = p.DurationTotalMilliseconds;
|
||||
if (!skip && displayTime < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
{
|
||||
Paragraph next = subtitle.GetParagraphOrDefault(i + 1);
|
||||
@ -78,7 +78,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
Paragraph next = subtitle.GetParagraphOrDefault(i + 1);
|
||||
Paragraph nextNext = subtitle.GetParagraphOrDefault(i + 2);
|
||||
Paragraph prev = subtitle.GetParagraphOrDefault(i - 1);
|
||||
double diffMs = temp.Duration.TotalMilliseconds - p.Duration.TotalMilliseconds;
|
||||
double diffMs = temp.DurationTotalMilliseconds - p.DurationTotalMilliseconds;
|
||||
|
||||
// Normal - just make current subtitle duration longer
|
||||
if (next == null || temp.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines < next.StartTime.TotalMilliseconds)
|
||||
@ -93,7 +93,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
}
|
||||
// Start current subtitle earlier (max 50 ms)
|
||||
else if (Configuration.Settings.Tools.FixShortDisplayTimesAllowMoveStartTime && p.StartTime.TotalMilliseconds > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds &&
|
||||
diffMs < 50 && (prev == null || prev.EndTime.TotalMilliseconds < p.EndTime.TotalMilliseconds - temp.Duration.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines))
|
||||
diffMs < 50 && (prev == null || prev.EndTime.TotalMilliseconds < p.EndTime.TotalMilliseconds - temp.DurationTotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines))
|
||||
{
|
||||
noOfShortDisplayTimes = MoveStartTime(fixAction, noOfShortDisplayTimes, p, temp, next);
|
||||
}
|
||||
@ -106,8 +106,8 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
if (callbacks.AllowFix(p, fixAction))
|
||||
{
|
||||
string oldCurrent = p.ToString();
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + temp.Duration.TotalMilliseconds;
|
||||
var nextDurationMs = next.Duration.TotalMilliseconds;
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + temp.DurationTotalMilliseconds;
|
||||
var nextDurationMs = next.DurationTotalMilliseconds;
|
||||
next.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
next.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds + nextDurationMs;
|
||||
noOfShortDisplayTimes++;
|
||||
@ -116,12 +116,12 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
}
|
||||
// Make next subtitle duration shorter + make current subtitle duration longer
|
||||
else if (diffMs < 1000 &&
|
||||
Configuration.Settings.Tools.FixShortDisplayTimesAllowMoveStartTime && Utilities.GetCharactersPerSecond(new Paragraph(next.Text, p.StartTime.TotalMilliseconds + temp.Duration.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines, next.EndTime.TotalMilliseconds)) < Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds)
|
||||
Configuration.Settings.Tools.FixShortDisplayTimesAllowMoveStartTime && Utilities.GetCharactersPerSecond(new Paragraph(next.Text, p.StartTime.TotalMilliseconds + temp.DurationTotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines, next.EndTime.TotalMilliseconds)) < Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds)
|
||||
{
|
||||
if (callbacks.AllowFix(p, fixAction))
|
||||
{
|
||||
string oldCurrent = p.ToString();
|
||||
next.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + temp.Duration.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
next.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + temp.DurationTotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
noOfShortDisplayTimes++;
|
||||
callbacks.AddFixToListView(p, fixAction, oldCurrent, p.ToString());
|
||||
@ -145,7 +145,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
}
|
||||
// Start current subtitle earlier (max 200 ms)
|
||||
else if (Configuration.Settings.Tools.FixShortDisplayTimesAllowMoveStartTime && p.StartTime.TotalMilliseconds > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds &&
|
||||
diffMs < 200 && (prev == null || prev.EndTime.TotalMilliseconds < p.EndTime.TotalMilliseconds - temp.Duration.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines))
|
||||
diffMs < 200 && (prev == null || prev.EndTime.TotalMilliseconds < p.EndTime.TotalMilliseconds - temp.DurationTotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines))
|
||||
{
|
||||
noOfShortDisplayTimes = MoveStartTime(fixAction, noOfShortDisplayTimes, p, temp, next);
|
||||
}
|
||||
@ -182,7 +182,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
}
|
||||
|
||||
p.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds - temp.Duration.TotalMilliseconds;
|
||||
p.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds - temp.DurationTotalMilliseconds;
|
||||
noOfShortDisplayTimes++;
|
||||
_callbacks.AddFixToListView(p, fixAction, oldCurrent, p.ToString());
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
|
||||
}
|
||||
|
||||
// calculate milliseconds per char
|
||||
var millisecondsPerChar = oldParagraph.Duration.TotalMilliseconds / (HtmlUtil.RemoveHtmlTags(text, true).Length - Environment.NewLine.Length);
|
||||
var millisecondsPerChar = oldParagraph.DurationTotalMilliseconds / (HtmlUtil.RemoveHtmlTags(text, true).Length - Environment.NewLine.Length);
|
||||
|
||||
oldParagraph.Text = lines[firstLine];
|
||||
|
||||
|
@ -11,7 +11,7 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
|
||||
{
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
if (p.Duration.TotalMilliseconds > 7000)
|
||||
if (p.DurationTotalMilliseconds > 7000)
|
||||
{
|
||||
var fixedParagraph = new Paragraph(p, false);
|
||||
fixedParagraph.EndTime.TotalMilliseconds = fixedParagraph.StartTime.TotalMilliseconds + 7000;
|
||||
|
@ -16,16 +16,16 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
|
||||
|
||||
if (controller.Language == "ja")
|
||||
{
|
||||
if (p.Duration.TotalMilliseconds < 500)
|
||||
if (p.DurationTotalMilliseconds < 500)
|
||||
{
|
||||
string comment = "Minimum duration: 0.5 second";
|
||||
controller.AddRecord(p, p.StartTime.ToHHMMSSFF(), comment, p.Duration.TotalSeconds.ToString(CultureInfo.InvariantCulture));
|
||||
controller.AddRecord(p, p.StartTime.ToHHMMSSFF(), comment, p.DurationTotalSeconds.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
var next = subtitle.GetParagraphOrDefault(index + 1);
|
||||
if (p.Duration.TotalMilliseconds < 833 && !p.StartTime.IsMaxTime)
|
||||
if (p.DurationTotalMilliseconds < 833 && !p.StartTime.IsMaxTime)
|
||||
{
|
||||
Paragraph fixedParagraph = null;
|
||||
if (next == null || next.StartTime.TotalMilliseconds > p.StartTime.TotalMilliseconds + 834)
|
||||
|
@ -33,7 +33,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
XmlNode paragraph = xml.CreateElement("marker");
|
||||
paragraph.InnerXml = string.Format(CultureInfo.InvariantCulture, innerXml, p.StartTime.TotalSeconds, p.Duration.TotalSeconds);
|
||||
paragraph.InnerXml = string.Format(CultureInfo.InvariantCulture, innerXml, p.StartTime.TotalSeconds, p.DurationTotalSeconds);
|
||||
paragraph.SelectSingleNode("comment").Attributes["value"].InnerText = HtmlUtil.RemoveHtmlTags(p.Text, true).Replace(Environment.NewLine, "||");
|
||||
root.AppendChild(paragraph);
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
}
|
||||
}
|
||||
if (last != null && last.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (last != null && last.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(last.Text);
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
p.StartTime = DecodeTimestamp(buffer, i + 2);
|
||||
p.EndTime = DecodeTimestamp(buffer, i + 6);
|
||||
if (p.EndTime.Hours == 2 && p.EndTime.Minutes == 1 && p.EndTime.Seconds == 0 && p.EndTime.Milliseconds == 0 &&
|
||||
(p.Duration.TotalMilliseconds < 0 || p.Duration.TotalMilliseconds > 5000))
|
||||
(p.DurationTotalMilliseconds < 0 || p.DurationTotalMilliseconds > 5000))
|
||||
{
|
||||
usedBytes = 20 - 4;
|
||||
}
|
||||
@ -345,7 +345,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
i += length;
|
||||
}
|
||||
if (last != null && (last.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds || last.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds))
|
||||
if (last != null && (last.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds || last.DurationTotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds))
|
||||
{
|
||||
last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(last.Text);
|
||||
}
|
||||
@ -355,7 +355,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
var current = subtitle.Paragraphs[index];
|
||||
var next = subtitle.Paragraphs[index + 1];
|
||||
if (current.EndTime.Hours == 2 && current.EndTime.Minutes == 1 && current.EndTime.Seconds == 0 && current.EndTime.Milliseconds == 0 &&
|
||||
(current.Duration.TotalMilliseconds < 0 || current.Duration.TotalMilliseconds > 5000))
|
||||
(current.DurationTotalMilliseconds < 0 || current.DurationTotalMilliseconds > 5000))
|
||||
{
|
||||
current.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
}
|
||||
|
@ -76,17 +76,17 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
var paragraph = subtitle.Paragraphs[index];
|
||||
var next = subtitle.GetParagraphOrDefault(index + 1);
|
||||
if (paragraph.Duration.TotalSeconds > 100)
|
||||
if (paragraph.DurationTotalSeconds > 100)
|
||||
{
|
||||
_errorCount++;
|
||||
}
|
||||
if (Math.Abs(paragraph.EndTime.TotalMilliseconds) < 0.1 || paragraph.Duration.TotalMilliseconds < 0.1)
|
||||
if (Math.Abs(paragraph.EndTime.TotalMilliseconds) < 0.1 || paragraph.DurationTotalMilliseconds < 0.1)
|
||||
{
|
||||
if (next != null)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
}
|
||||
if (next == null || paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (next == null || paragraph.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
|
||||
private object GetDuration(Paragraph p)
|
||||
private static object GetDuration(Paragraph p)
|
||||
{
|
||||
string s;
|
||||
var ts = p.Duration.TimeSpan;
|
||||
@ -57,7 +57,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
s = $"{ts.Seconds:00}:{MillisecondsToFramesMaxFrameRate(ts.Milliseconds):00}";
|
||||
}
|
||||
if (p.Duration.TotalMilliseconds >= 0)
|
||||
if (p.DurationTotalMilliseconds >= 0)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
name = xml.CreateElement("Name");
|
||||
name.InnerText = "duration";
|
||||
value = xml.CreateElement("Value");
|
||||
value.InnerText = p.Duration.TotalMilliseconds.ToString();
|
||||
value.InnerText = p.DurationTotalMilliseconds.ToString();
|
||||
parameter.AppendChild(name);
|
||||
parameter.AppendChild(value);
|
||||
parameters.AppendChild(parameter);
|
||||
|
@ -58,7 +58,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
XmlNode chapterMarker = xml.CreateElement("chapter-marker");
|
||||
|
||||
var attr = xml.CreateAttribute("duration");
|
||||
attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s";
|
||||
attr.Value = Convert.ToInt64(p.DurationTotalSeconds * 2400000) + "/2400000s";
|
||||
chapterMarker.Attributes.Append(attr);
|
||||
|
||||
attr = xml.CreateAttribute("start");
|
||||
|
@ -68,7 +68,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
attr = xml.CreateAttribute("duration");
|
||||
//attr.Value = "9529520/2400000s";
|
||||
attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s";
|
||||
attr.Value = Convert.ToInt64(p.DurationTotalSeconds * 2400000) + "/2400000s";
|
||||
clip.Attributes.Append(attr);
|
||||
|
||||
attr = xml.CreateAttribute("start");
|
||||
@ -81,7 +81,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
clip.Attributes.Append(attr);
|
||||
|
||||
attr = xml.CreateAttribute("audioDuration");
|
||||
attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s";
|
||||
attr.Value = Convert.ToInt64(p.DurationTotalSeconds * 2400000) + "/2400000s";
|
||||
clip.Attributes.Append(attr);
|
||||
|
||||
attr = xml.CreateAttribute("tcFormat");
|
||||
@ -91,7 +91,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
XmlNode titleNode = clip.SelectSingleNode("title");
|
||||
titleNode.Attributes["offset"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s";
|
||||
titleNode.Attributes["name"].Value = HtmlUtil.RemoveHtmlTags(p.Text);
|
||||
titleNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds * 60000) + "/60000s";
|
||||
titleNode.Attributes["duration"].Value = Convert.ToInt64(p.DurationTotalSeconds * 60000) + "/60000s";
|
||||
titleNode.Attributes["start"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s";
|
||||
|
||||
XmlNode text = clip.SelectSingleNode("title/text");
|
||||
|
@ -66,7 +66,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
clip.Attributes.Append(attr);
|
||||
|
||||
attr = xml.CreateAttribute("duration");
|
||||
attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s";
|
||||
attr.Value = Convert.ToInt64(p.DurationTotalSeconds * 2400000) + "/2400000s";
|
||||
clip.Attributes.Append(attr);
|
||||
|
||||
attr = xml.CreateAttribute("start");
|
||||
@ -78,7 +78,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
clip.Attributes.Append(attr);
|
||||
|
||||
attr = xml.CreateAttribute("audioDuration");
|
||||
attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s";
|
||||
attr.Value = Convert.ToInt64(p.DurationTotalSeconds * 2400000) + "/2400000s";
|
||||
clip.Attributes.Append(attr);
|
||||
|
||||
attr = xml.CreateAttribute("tcFormat");
|
||||
@ -88,7 +88,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
XmlNode titleNode = clip.SelectSingleNode("video");
|
||||
titleNode.Attributes["offset"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s";
|
||||
titleNode.Attributes["name"].Value = HtmlUtil.RemoveHtmlTags(p.Text);
|
||||
titleNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds * 60000) + "/60000s";
|
||||
titleNode.Attributes["duration"].Value = Convert.ToInt64(p.DurationTotalSeconds * 60000) + "/60000s";
|
||||
titleNode.Attributes["start"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s";
|
||||
|
||||
XmlNode param = clip.SelectSingleNode("video/param");
|
||||
|
@ -76,7 +76,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
XmlNode generatorNode = video.SelectSingleNode("video");
|
||||
generatorNode.Attributes["offset"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 2400000) + "/2400000s";
|
||||
generatorNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s";
|
||||
generatorNode.Attributes["duration"].Value = Convert.ToInt64(p.DurationTotalSeconds * 2400000) + "/2400000s";
|
||||
generatorNode.Attributes["start"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 2400000) + "/2400000s";
|
||||
|
||||
XmlNode param = video.SelectSingleNode("video/param");
|
||||
|
@ -88,9 +88,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
generatorNode.Attributes["offset"].Value = FinalCutProXml15.GetFrameTime(p.StartTime);
|
||||
}
|
||||
|
||||
if (IsNearleWholeNumber(p.Duration.TotalSeconds))
|
||||
if (IsNearleWholeNumber(p.DurationTotalSeconds))
|
||||
{
|
||||
generatorNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds) + "s";
|
||||
generatorNode.Attributes["duration"].Value = Convert.ToInt64(p.DurationTotalSeconds) + "s";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
titleNode = titleNode.SelectSingleNode("title");
|
||||
titleNode.Attributes["offset"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s";
|
||||
titleNode.Attributes["name"].Value = HtmlUtil.RemoveHtmlTags(p.Text);
|
||||
titleNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds * 60000) + "/60000s";
|
||||
titleNode.Attributes["duration"].Value = Convert.ToInt64(p.DurationTotalSeconds * 60000) + "/60000s";
|
||||
titleNode.Attributes["start"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s";
|
||||
titleNode.SelectSingleNode("text").InnerText = HtmlUtil.RemoveHtmlTags(p.Text);
|
||||
videoNode.AppendChild(titleNode);
|
||||
|
@ -21,7 +21,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
sb.AppendLine(count > 0 ? ", {" : " {");
|
||||
sb.AppendLine(" \"tStartMs\": " + p.StartTime.TotalMilliseconds.ToString(CultureInfo.InvariantCulture) + ",");
|
||||
sb.AppendLine(" \"dDurationMs\": " + p.Duration.TotalMilliseconds.ToString(CultureInfo.InvariantCulture) + ",");
|
||||
sb.AppendLine(" \"dDurationMs\": " + p.DurationTotalMilliseconds.ToString(CultureInfo.InvariantCulture) + ",");
|
||||
sb.AppendLine(" \"segs\": [ {");
|
||||
sb.AppendLine(" \"utf8\": \"" + Json.EncodeJsonText(p.Text).Replace("<br />", "\\n") + "\"");
|
||||
sb.AppendLine(" } ]");
|
||||
|
@ -150,7 +150,7 @@ version=1.1
|
||||
}
|
||||
|
||||
var last = subtitle.Paragraphs.Last();
|
||||
last.Duration.TotalMilliseconds = Utilities.GetOptimalDisplayMilliseconds(last.Text);
|
||||
last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(last.Text);
|
||||
subtitle.RemoveEmptyLines();
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
sb.Append("{\"duration\":");
|
||||
sb.Append(p.Duration.TotalMilliseconds.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
sb.Append(p.DurationTotalMilliseconds.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
sb.Append(",\"content\":\"");
|
||||
sb.Append(Json.EncodeJsonText(p.Text) + "\"");
|
||||
sb.Append(",\"startOfParagraph\":true");
|
||||
|
@ -21,7 +21,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
var last = subtitle.Paragraphs.LastOrDefault();
|
||||
if (last != null)
|
||||
{
|
||||
duration = (last.StartTime.TotalSeconds + last.Duration.TotalSeconds).ToString(CultureInfo.InvariantCulture);
|
||||
duration = (last.StartTime.TotalSeconds + last.DurationTotalSeconds).ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
var createdAt = "";
|
||||
@ -47,7 +47,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
sb.AppendLine(" {");
|
||||
sb.AppendLine(" \"duration\": \"" + p.Duration.TotalSeconds.ToString(CultureInfo.InvariantCulture) + "\",");
|
||||
sb.AppendLine(" \"duration\": \"" + p.DurationTotalSeconds.ToString(CultureInfo.InvariantCulture) + "\",");
|
||||
sb.AppendLine(" \"confidence\": null,");
|
||||
sb.AppendLine(" \"name\": \"" + Json.EncodeJsonText(p.Text) + "\",");
|
||||
sb.AppendLine(" \"time\": \"" + p.StartTime.TotalSeconds.ToString(CultureInfo.InvariantCulture) + "\"");
|
||||
|
@ -26,7 +26,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
sb.AppendLine();
|
||||
sb.AppendLine(" {");
|
||||
sb.AppendLine($" \"s\": {p.StartTime.TotalSeconds.ToString(CultureInfo.InvariantCulture)},");
|
||||
sb.AppendLine($" \"d\": {p.Duration.TotalSeconds.ToString(CultureInfo.InvariantCulture)},");
|
||||
sb.AppendLine($" \"d\": {p.DurationTotalSeconds.ToString(CultureInfo.InvariantCulture)},");
|
||||
sb.AppendLine($" \"n\": \"{Json.EncodeJsonText(p.Text, "\\n")}\"");
|
||||
sb.Append(" }");
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
sb.AppendLine();
|
||||
sb.AppendLine(" {");
|
||||
sb.AppendLine($" \"tStartMs\": {p.StartTime.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)},");
|
||||
sb.AppendLine($" \"dDurationMs\": {p.Duration.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)},");
|
||||
sb.AppendLine($" \"dDurationMs\": {p.DurationTotalMilliseconds.ToString(CultureInfo.InvariantCulture)},");
|
||||
sb.AppendLine($" \"segs\": [{{ \"utf8\": \"{Json.EncodeJsonText(p.Text, "\\n")}\" }} ]");
|
||||
sb.Append(" }");
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
sb.Append("{\"duration\":");
|
||||
sb.Append(p.Duration.TotalMilliseconds.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
sb.Append(p.DurationTotalMilliseconds.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
sb.Append(",\"content\":\"");
|
||||
sb.Append(Json.EncodeJsonText(p.Text) + "\"");
|
||||
sb.Append(",\"startOfParagraph\":false");
|
||||
|
@ -20,7 +20,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var avgDurSecs = subtitle.Paragraphs.Average(p => p.Duration.TotalSeconds);
|
||||
var avgDurSecs = subtitle.Paragraphs.Average(p => p.DurationTotalSeconds);
|
||||
return avgDurSecs < 60;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var avgDurSecs = subtitle.Paragraphs.Average(p => p.Duration.TotalSeconds);
|
||||
var avgDurSecs = subtitle.Paragraphs.Average(p => p.DurationTotalSeconds);
|
||||
return avgDurSecs < 60 && avgDurSecs > 0.1;
|
||||
}
|
||||
|
||||
|
@ -290,7 +290,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
}
|
||||
if (p.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (p.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
double duration = Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds;
|
||||
p.EndTime = new TimeCode(p.StartTime.TotalMilliseconds + duration);
|
||||
|
@ -269,7 +269,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
if (next != null && !p.StartTime.IsMaxTime && !next.StartTime.IsMaxTime)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
if (p.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (p.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text + "!");
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Configuration.Settings.General.NewEmptyDefaultMs;
|
||||
}
|
||||
|
||||
if (paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (paragraph.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text);
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
Paragraph p = subtitle.GetParagraphOrDefault(i);
|
||||
Paragraph next = subtitle.GetParagraphOrDefault(i + 1);
|
||||
if (p.Duration.TotalMilliseconds <= 0 && next != null)
|
||||
if (p.DurationTotalMilliseconds <= 0 && next != null)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
name = xml.CreateElement("Name");
|
||||
name.InnerText = "duration";
|
||||
value = xml.CreateElement("Value");
|
||||
value.InnerText = p.Duration.TotalMilliseconds.ToString();
|
||||
value.InnerText = p.DurationTotalMilliseconds.ToString();
|
||||
parameter.AppendChild(name);
|
||||
parameter.AppendChild(value);
|
||||
parameters.AppendChild(parameter);
|
||||
|
@ -100,7 +100,7 @@ TimeCode Format: " + Configuration.Settings.General.CurrentFrameRate + @" frames
|
||||
subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
|
||||
if (subtitle.Paragraphs.Count > 0 && subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].Duration.TotalMilliseconds < 0.01)
|
||||
if (subtitle.Paragraphs.Count > 0 && subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].DurationTotalMilliseconds < 0.01)
|
||||
{
|
||||
p = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1];
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text);
|
||||
|
@ -217,7 +217,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text);
|
||||
}
|
||||
if (paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (paragraph.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
XmlNode paragraph = xml.CreateElement("subtitle");
|
||||
|
||||
XmlAttribute duration = xml.CreateAttribute("duration");
|
||||
duration.InnerText = ((int)Math.Round(p.Duration.TotalMilliseconds)).ToString(CultureInfo.InvariantCulture);
|
||||
duration.InnerText = ((int)Math.Round(p.DurationTotalMilliseconds)).ToString(CultureInfo.InvariantCulture);
|
||||
paragraph.Attributes.Append(duration);
|
||||
|
||||
XmlAttribute effect = xml.CreateAttribute("effect");
|
||||
|
@ -102,17 +102,17 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
var next = subtitle.GetParagraphOrDefault(index + 1);
|
||||
if (paragraph.Duration.TotalSeconds > 100)
|
||||
if (paragraph.DurationTotalSeconds > 100)
|
||||
{
|
||||
_errorCount++;
|
||||
}
|
||||
if (Math.Abs(paragraph.EndTime.TotalMilliseconds) < 0.1 || paragraph.Duration.TotalMilliseconds < 0.1)
|
||||
if (Math.Abs(paragraph.EndTime.TotalMilliseconds) < 0.1 || paragraph.DurationTotalMilliseconds < 0.1)
|
||||
{
|
||||
if (next != null)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
}
|
||||
if (next == null || paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (next == null || paragraph.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ ATTENTION : Pas plus de 40 caractères PAR LIGNE
|
||||
{
|
||||
index++;
|
||||
var text = HtmlUtil.RemoveHtmlTags(p.Text, true);
|
||||
sb.AppendLine(string.Format(writeFormat, index, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), GetMaxCharsForDuration(p.Duration.TotalSeconds) + "c", Environment.NewLine, text));
|
||||
sb.AppendLine(string.Format(writeFormat, index, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), GetMaxCharsForDuration(p.DurationTotalSeconds) + "c", Environment.NewLine, text));
|
||||
sb.AppendLine();
|
||||
if (!text.Contains(Environment.NewLine))
|
||||
{
|
||||
|
@ -283,7 +283,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + 2500;
|
||||
}
|
||||
|
||||
if (last.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (last.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(last.Text);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
private static string GetTimeCodeString(Paragraph paragraph)
|
||||
{
|
||||
return $"#{paragraph.StartTime.TotalMilliseconds:00000000}{paragraph.Duration.TotalMilliseconds:000000}";
|
||||
return $"#{paragraph.StartTime.TotalMilliseconds:00000000}{paragraph.DurationTotalMilliseconds:000000}";
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
|
@ -76,7 +76,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
else
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
if (p.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (p.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds;
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
for (var index = 0; index < subtitle.Paragraphs.Count; index++)
|
||||
{
|
||||
var p = subtitle.Paragraphs[index];
|
||||
sb.AppendLine($"{EncodeTime(p.Duration.TotalSeconds)}");
|
||||
sb.AppendLine($"{EncodeTime(p.DurationTotalSeconds)}");
|
||||
sb.AppendLine(p.Text);
|
||||
|
||||
seconds += p.Duration.TotalSeconds;
|
||||
seconds += p.DurationTotalSeconds;
|
||||
var next = subtitle.GetParagraphOrDefault(index + 1);
|
||||
if (next != null && (next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds) > 100)
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Configuration.Settings.General.NewEmptyDefaultMs;
|
||||
}
|
||||
|
||||
if (paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (paragraph.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ NOTE=
|
||||
Paragraph last = null;
|
||||
foreach (var p in subtitle.Paragraphs)
|
||||
{
|
||||
sb.AppendLine($"{MakeTimeCode(p.StartTime, last)} {MakeTimeCode(p.Duration.TotalSeconds)}\r\n{p.Text}\r\n");
|
||||
sb.AppendLine($"{MakeTimeCode(p.StartTime, last)} {MakeTimeCode(p.DurationTotalSeconds)}\r\n{p.Text}\r\n");
|
||||
last = p;
|
||||
}
|
||||
return sb.ToString().Trim().Replace(Environment.NewLine, "\n");
|
||||
|
@ -93,7 +93,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
current.EndTime.TotalMilliseconds = current.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(current.Text);
|
||||
}
|
||||
|
||||
if (current.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (current.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
current.EndTime.TotalMilliseconds = current.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
current.EndTime.TotalMilliseconds = current.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(current.Text);
|
||||
}
|
||||
|
||||
if (current.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (current.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
current.EndTime.TotalMilliseconds = current.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
|
||||
}
|
||||
if (paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (paragraph.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
|
||||
if (paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (paragraph.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
paragraph.Attributes.Append(start);
|
||||
|
||||
XmlAttribute duration = xml.CreateAttribute("dur");
|
||||
duration.InnerText = $"{p.Duration.TotalMilliseconds / 1000}".Replace(',', '.');
|
||||
duration.InnerText = $"{p.DurationTotalMilliseconds / 1000}".Replace(',', '.');
|
||||
paragraph.Attributes.Append(duration);
|
||||
|
||||
paragraph.InnerText = p.Text;
|
||||
|
@ -176,7 +176,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
foreach (var p2 in subtitle.Paragraphs)
|
||||
{
|
||||
if (p2.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (p2.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
p2.EndTime.TotalMilliseconds = p2.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
paragraph.Attributes.Append(tAttribute);
|
||||
|
||||
XmlAttribute dAttribute = xml.CreateAttribute("d");
|
||||
dAttribute.InnerText = Convert.ToInt64(p.Duration.TotalMilliseconds).ToString();
|
||||
dAttribute.InnerText = Convert.ToInt64(p.DurationTotalMilliseconds).ToString();
|
||||
paragraph.Attributes.Append(dAttribute);
|
||||
|
||||
paragraphInsertNode.AppendChild(paragraph);
|
||||
|
@ -32,7 +32,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
for (int index = 0; index < subtitle.Paragraphs.Count;)
|
||||
{
|
||||
var p = subtitle.Paragraphs[index++];
|
||||
var lis = (int)Math.Round(MillisecondsToFrames(p.Duration.TotalMilliseconds) / 2.0);
|
||||
var lis = (int)Math.Round(MillisecondsToFrames(p.DurationTotalMilliseconds) / 2.0);
|
||||
sb.AppendLine(string.Format(format, index, p.StartTime.ToHHMMSSFF(), p.EndTime.ToHHMMSSFF(), p.Duration.ToSSFF(), lis, p.Text.Length, p.Text));
|
||||
}
|
||||
return sb.ToString().ToRtf();
|
||||
|
@ -125,7 +125,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
if (next.StartTime.TotalMilliseconds < p.EndTime.TotalMilliseconds)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
if (p.Duration.TotalMilliseconds < 0)
|
||||
if (p.DurationTotalMilliseconds < 0)
|
||||
{
|
||||
_errorCount++;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
}
|
||||
|
||||
if (p.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (p.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
sb.AppendLine(" <div id=\"transcriptPanel\">");
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
sb.AppendLine($" <a class=\"caption\" starttime=\"{((long)(Math.Round(p.StartTime.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture)}\" duration=\"{((long)(Math.Round(p.Duration.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture)}\">{p.Text.Replace(Environment.NewLine, "<br />")}</a>");
|
||||
sb.AppendLine($" <a class=\"caption\" starttime=\"{((long)(Math.Round(p.StartTime.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture)}\" duration=\"{((long)(Math.Round(p.DurationTotalMilliseconds))).ToString(CultureInfo.InvariantCulture)}\">{p.Text.Replace(Environment.NewLine, "<br />")}</a>");
|
||||
}
|
||||
sb.AppendLine(" </div>");
|
||||
sb.AppendLine(" </div>");
|
||||
|
@ -85,7 +85,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
|
||||
}
|
||||
if (paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (paragraph.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
|
||||
}
|
||||
if (paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (paragraph.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
li.AppendChild(comment);
|
||||
|
||||
var duration = xml.CreateElement("xmpDM", "duration", NamespaceDescription);
|
||||
duration.InnerText = MillisecondsToFrames(paragraph.Duration.TotalMilliseconds).ToString(CultureInfo.InvariantCulture);
|
||||
duration.InnerText = MillisecondsToFrames(paragraph.DurationTotalMilliseconds).ToString(CultureInfo.InvariantCulture);
|
||||
li.AppendChild(duration);
|
||||
|
||||
var startTime = xml.CreateElement("xmpDM", "startTime", NamespaceDescription);
|
||||
|
@ -124,7 +124,7 @@ namespace Nikse.SubtitleEdit.Core.VobSub
|
||||
|
||||
// Control Sequence Table
|
||||
// Write delay - subtitle duration
|
||||
WriteEndianWord(Convert.ToInt32(p.Duration.TotalMilliseconds * 90.0) >> 10, ms);
|
||||
WriteEndianWord(Convert.ToInt32(p.DurationTotalMilliseconds * 90.0) >> 10, ms);
|
||||
|
||||
// next display control sequence table address (use current is last)
|
||||
WriteEndianWord(startDisplayControlSequenceTableAddress + 24, ms); // start of display control sequence table address
|
||||
|
@ -451,7 +451,7 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
foreach (var p in displayableParagraphs)
|
||||
{
|
||||
if (displayableParagraphs.Count > 30 &&
|
||||
(p.Duration.TotalMilliseconds < 0.01 || p.StartTime.TotalMilliseconds - lastStartTime < 90))
|
||||
(p.DurationTotalMilliseconds < 0.01 || p.StartTime.TotalMilliseconds - lastStartTime < 90))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -1827,7 +1827,7 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
}
|
||||
else if (_mouseDownParagraphType == MouseDownParagraphType.Whole)
|
||||
{
|
||||
var durationMilliseconds = _mouseDownParagraph.Duration.TotalMilliseconds;
|
||||
var durationMilliseconds = _mouseDownParagraph.DurationTotalMilliseconds;
|
||||
var oldStart = _mouseDownParagraph.StartTime.TotalMilliseconds;
|
||||
_mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds - _moveWholeStartDifferenceMilliseconds;
|
||||
_mouseDownParagraph.EndTime.TotalMilliseconds = _mouseDownParagraph.StartTime.TotalMilliseconds + durationMilliseconds;
|
||||
@ -2129,7 +2129,7 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
{
|
||||
_oldParagraph = new Paragraph(SelectedParagraph);
|
||||
_mouseDownParagraph = SelectedParagraph;
|
||||
var durationMilliseconds = _mouseDownParagraph.Duration.TotalMilliseconds;
|
||||
var durationMilliseconds = _mouseDownParagraph.DurationTotalMilliseconds;
|
||||
_mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds;
|
||||
_mouseDownParagraph.EndTime.TotalMilliseconds = _mouseDownParagraph.StartTime.TotalMilliseconds + durationMilliseconds;
|
||||
OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph));
|
||||
|
@ -1472,13 +1472,13 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
item.SubItems[ColumnIndexDuration].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor;
|
||||
}
|
||||
}
|
||||
if (paragraph.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds && ColumnIndexDuration >= 0)
|
||||
if (paragraph.DurationTotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds && ColumnIndexDuration >= 0)
|
||||
{
|
||||
item.SubItems[ColumnIndexDuration].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor;
|
||||
}
|
||||
}
|
||||
if (_settings.Tools.ListViewSyntaxColorDurationBig &&
|
||||
paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds &&
|
||||
paragraph.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds &&
|
||||
ColumnIndexDuration >= 0)
|
||||
{
|
||||
item.SubItems[ColumnIndexDuration].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor;
|
||||
|
@ -145,7 +145,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
for (int i = 0; i < _working.Paragraphs.Count; i++)
|
||||
{
|
||||
var p = _working.Paragraphs[i];
|
||||
var displayTime = p.Duration.TotalMilliseconds;
|
||||
var displayTime = p.DurationTotalMilliseconds;
|
||||
if (displayTime < minDisplayTime)
|
||||
{
|
||||
var next = _working.GetParagraphOrDefault(i + 1);
|
||||
@ -198,7 +198,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
for (int i = 0; i < _working.Paragraphs.Count; i++)
|
||||
{
|
||||
var p = _working.Paragraphs[i];
|
||||
var displayTime = p.Duration.TotalMilliseconds;
|
||||
var displayTime = p.DurationTotalMilliseconds;
|
||||
if (displayTime > maxDisplayTime)
|
||||
{
|
||||
AddFix(p, p.StartTime.TotalMilliseconds + maxDisplayTime, DefaultBackColor);
|
||||
|
@ -59,7 +59,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
var start = $"{item.StartTime.TotalSeconds:0.000}".Replace(",", ".");
|
||||
var duration = $"{item.Duration.TotalSeconds:0.000}".Replace(",", ".");
|
||||
var duration = $"{item.DurationTotalSeconds:0.000}".Replace(",", ".");
|
||||
var fFmpegWaveTranscodeSettings = "-ss " + start + " -t " + duration + " -i \"{0}\" -vn -ar 16000 -ac 1 -ab 32k -af volume=1.75 -f wav {2} \"{1}\"";
|
||||
if (useCenterChannelOnly)
|
||||
{
|
||||
|
@ -1255,7 +1255,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (fromFormat != null && fromFormat.GetType() == typeof(MicroDvd))
|
||||
{
|
||||
if (sub != null && sub.Paragraphs.Count > 0 && sub.Paragraphs[0].Duration.TotalMilliseconds < 1001)
|
||||
if (sub != null && sub.Paragraphs.Count > 0 && sub.Paragraphs[0].DurationTotalMilliseconds < 1001)
|
||||
{
|
||||
if (sub.Paragraphs[0].Text.StartsWith("29.", StringComparison.Ordinal) || sub.Paragraphs[0].Text.StartsWith("23.", StringComparison.Ordinal) ||
|
||||
sub.Paragraphs[0].Text.StartsWith("29,", StringComparison.Ordinal) || sub.Paragraphs[0].Text.StartsWith("23,", StringComparison.Ordinal) ||
|
||||
@ -1885,10 +1885,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (pes == null && subtitle.Paragraphs.Count > 0)
|
||||
{
|
||||
var last = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1];
|
||||
if (last.Duration.TotalMilliseconds < 100)
|
||||
if (last.DurationTotalMilliseconds < 100)
|
||||
{
|
||||
last.EndTime.TotalMilliseconds = msub.Start;
|
||||
if (last.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (last.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + 3000;
|
||||
}
|
||||
@ -1916,7 +1916,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
for (var index = 0; index < subtitle.Paragraphs.Count; index++)
|
||||
{
|
||||
var p = subtitle.Paragraphs[index];
|
||||
if (p.Duration.TotalMilliseconds < 200)
|
||||
if (p.DurationTotalMilliseconds < 200)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 3000;
|
||||
}
|
||||
@ -2612,7 +2612,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
var current = p.Subtitle.GetParagraphOrDefault(i);
|
||||
var next = p.Subtitle.GetParagraphOrDefault(i + 1);
|
||||
var gapsBetween = next.StartTime.TotalMilliseconds - current.EndTime.TotalMilliseconds;
|
||||
if (gapsBetween < minimumMillisecondsBetweenLines && current.Duration.TotalMilliseconds > minimumMillisecondsBetweenLines)
|
||||
if (gapsBetween < minimumMillisecondsBetweenLines && current.DurationTotalMilliseconds > minimumMillisecondsBetweenLines)
|
||||
{
|
||||
current.EndTime.TotalMilliseconds -= (minimumMillisecondsBetweenLines - gapsBetween);
|
||||
}
|
||||
|
@ -716,11 +716,11 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
|
||||
|
||||
if (_columnIndexDuration >= 0)
|
||||
{
|
||||
if (paragraph.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds && _columnIndexDuration >= 0)
|
||||
if (paragraph.DurationTotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds && _columnIndexDuration >= 0)
|
||||
{
|
||||
colorDuration = true;
|
||||
}
|
||||
else if (paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
else if (paragraph.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
colorDuration = true;
|
||||
}
|
||||
@ -1139,10 +1139,10 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
|
||||
if (pes == null && subtitle.Paragraphs.Count > 0)
|
||||
{
|
||||
var last = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1];
|
||||
if (last.Duration.TotalMilliseconds < 100)
|
||||
if (last.DurationTotalMilliseconds < 100)
|
||||
{
|
||||
last.EndTime.TotalMilliseconds = msub.Start;
|
||||
if (last.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (last.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + 3000;
|
||||
}
|
||||
@ -1170,7 +1170,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
|
||||
for (var index = 0; index < subtitle.Paragraphs.Count; index++)
|
||||
{
|
||||
var p = subtitle.Paragraphs[index];
|
||||
if (p.Duration.TotalMilliseconds < 200)
|
||||
if (p.DurationTotalMilliseconds < 200)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 3000;
|
||||
}
|
||||
@ -1701,7 +1701,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
ntsc = "TRUE";
|
||||
}
|
||||
|
||||
var duration = SubtitleFormat.MillisecondsToFrames(p.Duration.TotalMilliseconds, _frameRate);
|
||||
var duration = SubtitleFormat.MillisecondsToFrames(p.DurationTotalMilliseconds, _frameRate);
|
||||
var start = SubtitleFormat.MillisecondsToFrames(p.StartTime.TotalMilliseconds, _frameRate);
|
||||
var end = SubtitleFormat.MillisecondsToFrames(p.EndTime.TotalMilliseconds, _frameRate);
|
||||
|
||||
@ -3985,11 +3985,11 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
|
||||
if (string.IsNullOrEmpty(errorText))
|
||||
{
|
||||
if (paragraph.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds && _columnIndexDuration >= 0)
|
||||
if (paragraph.DurationTotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds && _columnIndexDuration >= 0)
|
||||
{
|
||||
errorText = "Duration too small";
|
||||
}
|
||||
else if (paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds && _columnIndexDuration >= 0)
|
||||
else if (paragraph.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds && _columnIndexDuration >= 0)
|
||||
{
|
||||
errorText = "Duration too large";
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
AddToPreview(richTextBoxPreview, paragraph.Text);
|
||||
RefreshPreview();
|
||||
labelTotalMilliseconds.Text = $"{paragraph.Duration.TotalMilliseconds / TimeCode.BaseUnit:#,##0.000}";
|
||||
numericUpDownDelay.Maximum = (decimal)((paragraph.Duration.TotalMilliseconds - 500) / TimeCode.BaseUnit);
|
||||
labelTotalMilliseconds.Text = $"{paragraph.DurationTotalMilliseconds / TimeCode.BaseUnit:#,##0.000}";
|
||||
numericUpDownDelay.Maximum = (decimal)((paragraph.DurationTotalMilliseconds - 500) / TimeCode.BaseUnit);
|
||||
numericUpDownDelay.Minimum = 0;
|
||||
|
||||
numericUpDownDelay.Left = labelEndDelay.Left + labelEndDelay.Width + 5;
|
||||
@ -108,13 +108,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
_animation = new List<Paragraph>();
|
||||
|
||||
if (HtmlUtil.RemoveHtmlTags(_paragraph.Text, true).Length == 0 || _paragraph.Duration.TotalMilliseconds < 0.001)
|
||||
if (HtmlUtil.RemoveHtmlTags(_paragraph.Text, true).Length == 0 || _paragraph.DurationTotalMilliseconds < 0.001)
|
||||
{
|
||||
_animation.Add(new Paragraph(_paragraph));
|
||||
return;
|
||||
}
|
||||
|
||||
var duration = _paragraph.Duration.TotalMilliseconds - ((double)numericUpDownDelay.Value * TimeCode.BaseUnit);
|
||||
var duration = _paragraph.DurationTotalMilliseconds - ((double)numericUpDownDelay.Value * TimeCode.BaseUnit);
|
||||
var partsBase = EffectAnimationPart.MakeBase(_paragraph.Text);
|
||||
var stepsLength = duration / partsBase.Count+1;
|
||||
for (var index = 0; index <= partsBase.Count; index++)
|
||||
|
@ -59,8 +59,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
AddToPreview(richTextBoxPreview, paragraph.Text);
|
||||
RefreshPreview();
|
||||
|
||||
labelTotalMilliseconds.Text = $"{paragraph.Duration.TotalMilliseconds / TimeCode.BaseUnit:#,##0.000}";
|
||||
numericUpDownDelay.Maximum = (decimal)((paragraph.Duration.TotalMilliseconds - 500) / TimeCode.BaseUnit);
|
||||
labelTotalMilliseconds.Text = $"{paragraph.DurationTotalMilliseconds / TimeCode.BaseUnit:#,##0.000}";
|
||||
numericUpDownDelay.Maximum = (decimal)((paragraph.DurationTotalMilliseconds - 500) / TimeCode.BaseUnit);
|
||||
numericUpDownDelay.Minimum = 0;
|
||||
|
||||
numericUpDownDelay.Left = labelEndDelay.Left + labelEndDelay.Width + 5;
|
||||
@ -273,7 +273,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
public void MakeAnimation()
|
||||
{
|
||||
TypewriterParagraphs = new List<Paragraph>();
|
||||
var duration = _paragraph.Duration.TotalMilliseconds - (double)numericUpDownDelay.Value * TimeCode.BaseUnit;
|
||||
var duration = _paragraph.DurationTotalMilliseconds - (double)numericUpDownDelay.Value * TimeCode.BaseUnit;
|
||||
var stepsLength = CalculateStepLength(_paragraph.Text, duration);
|
||||
double startMilliseconds;
|
||||
double endMilliseconds;
|
||||
|
@ -78,14 +78,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
errors.Add($"CPS: {charactersPerSecond:#,###.00} > {Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds}");
|
||||
}
|
||||
|
||||
if (paragraph.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
if (paragraph.DurationTotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
{
|
||||
errors.Add($"Min duration: {paragraph.Duration.TotalMilliseconds:#,###.00} < {Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds}");
|
||||
errors.Add($"Min duration: {paragraph.DurationTotalMilliseconds:#,###.00} < {Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds}");
|
||||
}
|
||||
|
||||
if (paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (paragraph.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
errors.Add($"Max duration: {paragraph.Duration.TotalMilliseconds:#,###.00} > {Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds}");
|
||||
errors.Add($"Max duration: {paragraph.DurationTotalMilliseconds:#,###.00} > {Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds}");
|
||||
}
|
||||
|
||||
if (i > 0 && i < paragraphs.Count)
|
||||
|
@ -2118,7 +2118,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
ntsc = "TRUE";
|
||||
}
|
||||
|
||||
var duration = SubtitleFormat.MillisecondsToFrames(param.P.Duration.TotalMilliseconds, param.FramesPerSeconds);
|
||||
var duration = SubtitleFormat.MillisecondsToFrames(param.P.DurationTotalMilliseconds, param.FramesPerSeconds);
|
||||
var start = SubtitleFormat.MillisecondsToFrames(param.P.StartTime.TotalMilliseconds, param.FramesPerSeconds);
|
||||
var end = SubtitleFormat.MillisecondsToFrames(param.P.EndTime.TotalMilliseconds, param.FramesPerSeconds);
|
||||
|
||||
|
@ -1382,7 +1382,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBox_TextChanged;
|
||||
|
||||
numericUpDownDuration.ValueChanged -= NumericUpDownDurationValueChanged;
|
||||
numericUpDownDuration.Value = (decimal)(p.Duration.TotalMilliseconds / TimeCode.BaseUnit);
|
||||
numericUpDownDuration.Value = (decimal)(p.DurationTotalMilliseconds / TimeCode.BaseUnit);
|
||||
numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged;
|
||||
}
|
||||
|
||||
@ -1939,7 +1939,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
startFactor = 0.80;
|
||||
}
|
||||
|
||||
double middle = currentParagraph.StartTime.TotalMilliseconds + (currentParagraph.Duration.TotalMilliseconds * startFactor);
|
||||
double middle = currentParagraph.StartTime.TotalMilliseconds + (currentParagraph.DurationTotalMilliseconds * startFactor);
|
||||
if (splitSeconds.HasValue && splitSeconds.Value > (currentParagraph.StartTime.TotalSeconds + 0.2) && splitSeconds.Value < (currentParagraph.EndTime.TotalSeconds - 0.2))
|
||||
{
|
||||
middle = splitSeconds.Value * TimeCode.BaseUnit;
|
||||
|
@ -555,7 +555,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
double millisecondsIndex = millisecondsInterval;
|
||||
foreach (Paragraph p in FixedSubtitle.Paragraphs)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = millisecondsIndex + p.Duration.TotalMilliseconds;
|
||||
p.EndTime.TotalMilliseconds = millisecondsIndex + p.DurationTotalMilliseconds;
|
||||
p.StartTime.TotalMilliseconds = millisecondsIndex;
|
||||
millisecondsIndex += (p.EndTime.TotalMilliseconds - p.StartTime.TotalMilliseconds) + millisecondsInterval;
|
||||
}
|
||||
|
@ -1289,17 +1289,17 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{ // so we don't get weird rounds we'll use whole frames when moving start time
|
||||
double fr = TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate;
|
||||
if (e.BeforeParagraph != null && e.BeforeParagraph.StartTime.TotalMilliseconds != e.Paragraph.StartTime.TotalMilliseconds &&
|
||||
e.BeforeParagraph.Duration.TotalMilliseconds == e.Paragraph.Duration.TotalMilliseconds)
|
||||
e.BeforeParagraph.DurationTotalMilliseconds == e.Paragraph.DurationTotalMilliseconds)
|
||||
{
|
||||
// move paragraph
|
||||
paragraph.StartTime.TotalMilliseconds = ((int)Math.Round(paragraph.StartTime.TotalMilliseconds / fr)) * fr;
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + e.BeforeParagraph.Duration.TotalMilliseconds;
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + e.BeforeParagraph.DurationTotalMilliseconds;
|
||||
}
|
||||
else if (e.BeforeParagraph != null && e.BeforeParagraph.EndTime.TotalMilliseconds == e.Paragraph.EndTime.TotalMilliseconds)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = ((int)Math.Round(paragraph.EndTime.TotalMilliseconds / fr)) * fr;
|
||||
int end = SubtitleFormat.MillisecondsToFrames(paragraph.EndTime.TotalMilliseconds);
|
||||
int dur = SubtitleFormat.MillisecondsToFrames(paragraph.Duration.TotalMilliseconds);
|
||||
int dur = SubtitleFormat.MillisecondsToFrames(paragraph.DurationTotalMilliseconds);
|
||||
paragraph.StartTime.TotalMilliseconds = SubtitleFormat.FramesToMilliseconds(end - dur);
|
||||
}
|
||||
}
|
||||
@ -1309,7 +1309,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged;
|
||||
SubtitleListview1.SetStartTimeAndDurationBackground(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1));
|
||||
|
||||
var durationInSeconds = (decimal)paragraph.Duration.TotalSeconds;
|
||||
var durationInSeconds = (decimal)paragraph.DurationTotalSeconds;
|
||||
if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum)
|
||||
{
|
||||
SetDurationInSeconds((double)durationInSeconds);
|
||||
@ -1353,7 +1353,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged;
|
||||
timeUpDownStartTime.TimeCode = paragraph.StartTime;
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged;
|
||||
var durationInSeconds = (decimal)(paragraph.Duration.TotalSeconds);
|
||||
var durationInSeconds = (decimal)(paragraph.DurationTotalSeconds);
|
||||
if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum)
|
||||
{
|
||||
SetDurationInSeconds((double)durationInSeconds);
|
||||
@ -1430,7 +1430,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private void MoveSelectedLines(AudioVisualizer.ParagraphEventArgs e, Paragraph paragraph, int index, int[] selectedIndices)
|
||||
{
|
||||
// calculate move min/max values related to current idx
|
||||
var newMultiMoveHash = paragraph.Duration.TotalMilliseconds.GetHashCode() + index.GetHashCode() + selectedIndices.Length.GetHashCode();
|
||||
var newMultiMoveHash = paragraph.DurationTotalMilliseconds.GetHashCode() + index.GetHashCode() + selectedIndices.Length.GetHashCode();
|
||||
if (newMultiMoveHash != _lastMultiMoveHash)
|
||||
{
|
||||
var currentStart = _subtitle.Paragraphs[index].StartTime.TotalMilliseconds;
|
||||
@ -1463,7 +1463,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (p != paragraph)
|
||||
{
|
||||
var oldParagraph = new Paragraph(p, false);
|
||||
var dur = p.Duration.TotalMilliseconds;
|
||||
var dur = p.DurationTotalMilliseconds;
|
||||
p.StartTime.TotalMilliseconds += e.AdjustMs;
|
||||
p.EndTime.TotalMilliseconds += e.AdjustMs;
|
||||
SubtitleListview1.SetStartTimeAndDurationBackground(idx, p, _subtitle.GetParagraphOrDefault(idx + 1), _subtitle.GetParagraphOrDefault(idx - 1));
|
||||
@ -1508,7 +1508,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (curIdx == index - 1)
|
||||
{
|
||||
var durationInSeconds = (decimal)(prev.Duration.TotalSeconds);
|
||||
var durationInSeconds = (decimal)(prev.DurationTotalSeconds);
|
||||
if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum)
|
||||
{
|
||||
SetDurationInSeconds((double)durationInSeconds);
|
||||
@ -1539,7 +1539,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (curIdx == index + 1)
|
||||
{
|
||||
timeUpDownStartTime.TimeCode = next.StartTime;
|
||||
var durationInSeconds = (decimal)(next.Duration.TotalSeconds);
|
||||
var durationInSeconds = (decimal)(next.DurationTotalSeconds);
|
||||
if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum)
|
||||
{
|
||||
SetDurationInSeconds((double)durationInSeconds);
|
||||
@ -6099,7 +6099,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
for (var index = 0; index < _subtitle.Paragraphs.Count; index++)
|
||||
{
|
||||
var p = _subtitle.Paragraphs[index];
|
||||
if (p.Duration.TotalMilliseconds < 0 && !p.StartTime.IsMaxTime && !p.EndTime.IsMaxTime)
|
||||
if (p.DurationTotalMilliseconds < 0 && !p.StartTime.IsMaxTime && !p.EndTime.IsMaxTime)
|
||||
{
|
||||
if (sb.Length < 20)
|
||||
{
|
||||
@ -7478,7 +7478,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_makeHistoryPaused = true;
|
||||
var idx = SubtitleListview1.SelectedItems[0].Index;
|
||||
_subtitle.RecalculateDisplayTime(Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds, idx, Configuration.Settings.General.SubtitleOptimalCharactersPerSeconds, onlyOptimal: onlyOptimal);
|
||||
SetDurationInSeconds(_subtitle.Paragraphs[idx].Duration.TotalSeconds);
|
||||
SetDurationInSeconds(_subtitle.Paragraphs[idx].DurationTotalSeconds);
|
||||
_makeHistoryPaused = false;
|
||||
}
|
||||
}
|
||||
@ -7491,7 +7491,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_makeHistoryPaused = true;
|
||||
var idx = SubtitleListview1.SelectedItems[0].Index;
|
||||
_subtitle.RecalculateDisplayTime(Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds, idx, Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds);
|
||||
SetDurationInSeconds(_subtitle.Paragraphs[idx].Duration.TotalSeconds);
|
||||
SetDurationInSeconds(_subtitle.Paragraphs[idx].DurationTotalSeconds);
|
||||
_makeHistoryPaused = false;
|
||||
}
|
||||
}
|
||||
@ -10050,7 +10050,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1;
|
||||
}
|
||||
|
||||
if (newParagraph.Duration.TotalMilliseconds < 100)
|
||||
if (newParagraph.DurationTotalMilliseconds < 100)
|
||||
{
|
||||
newParagraph.EndTime.TotalMilliseconds += 100;
|
||||
}
|
||||
@ -10101,7 +10101,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
newParagraph.StartTime.TotalMilliseconds = 1000;
|
||||
newParagraph.EndTime.TotalMilliseconds = 3000;
|
||||
if (newParagraph.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
if (newParagraph.DurationTotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
{
|
||||
newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds +
|
||||
Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds;
|
||||
@ -10225,7 +10225,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
newParagraph.StartTime.TotalMilliseconds = 1000;
|
||||
newParagraph.EndTime.TotalMilliseconds = 3000;
|
||||
if (newParagraph.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
if (newParagraph.DurationTotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
{
|
||||
newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds +
|
||||
Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds;
|
||||
@ -10362,7 +10362,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (startTime != null && last != null && _subtitle != null &&
|
||||
Math.Abs(last.StartTime.TotalMilliseconds - startTime.TotalMilliseconds) > 0.5)
|
||||
{
|
||||
var dur = last.Duration.TotalMilliseconds;
|
||||
var dur = last.DurationTotalMilliseconds;
|
||||
last.StartTime.TotalMilliseconds = startTime.TotalMilliseconds;
|
||||
last.EndTime.TotalMilliseconds = startTime.TotalMilliseconds + dur;
|
||||
SubtitleListview1.SetStartTimeAndDuration(_subtitleListViewIndex, last, _subtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1), _subtitle.GetParagraphOrDefault(_subtitleListViewIndex - 1));
|
||||
@ -10370,7 +10370,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
var duration = GetDurationInMilliseconds();
|
||||
if (last != null && duration > 0 && duration < 100000 && Math.Abs(duration - last.Duration.TotalMilliseconds) > 0.5 && _subtitle != null)
|
||||
if (last != null && duration > 0 && duration < 100000 && Math.Abs(duration - last.DurationTotalMilliseconds) > 0.5 && _subtitle != null)
|
||||
{
|
||||
last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + duration;
|
||||
SubtitleListview1.SetDuration(_subtitleListViewIndex, last, _subtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1));
|
||||
@ -10452,7 +10452,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void UpdateListViewTextCharactersPerSeconds(Label charsPerSecond, Paragraph paragraph)
|
||||
{
|
||||
if (paragraph.Duration.TotalSeconds > 0)
|
||||
if (paragraph.DurationTotalSeconds > 0)
|
||||
{
|
||||
double charactersPerSecond = Utilities.GetCharactersPerSecond(paragraph);
|
||||
if (charactersPerSecond > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds &&
|
||||
@ -11837,7 +11837,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (_networkSession != null)
|
||||
{
|
||||
_networkSession.TimerStop();
|
||||
SetDurationInSeconds(currentParagraph.Duration.TotalSeconds);
|
||||
SetDurationInSeconds(currentParagraph.DurationTotalSeconds);
|
||||
_networkSession.UpdateLine(_subtitle.GetIndex(currentParagraph), currentParagraph);
|
||||
NetworkGetSendUpdates(new List<int>(), firstSelectedIndex + 1, newParagraph);
|
||||
}
|
||||
@ -11980,7 +11980,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void SetSplitTime(double? splitSeconds, Paragraph currentParagraph, Paragraph newParagraph, string oldText)
|
||||
{
|
||||
double middle = currentParagraph.StartTime.TotalMilliseconds + (currentParagraph.Duration.TotalMilliseconds / 2);
|
||||
double middle = currentParagraph.StartTime.TotalMilliseconds + (currentParagraph.DurationTotalMilliseconds / 2);
|
||||
if (!string.IsNullOrWhiteSpace(HtmlUtil.RemoveHtmlTags(oldText)))
|
||||
{
|
||||
var lineOneTextNoHtml = HtmlUtil.RemoveHtmlTags(currentParagraph.Text, true).Replace(Environment.NewLine, string.Empty);
|
||||
@ -12000,7 +12000,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
startFactor = 0.75;
|
||||
}
|
||||
|
||||
middle = currentParagraph.StartTime.TotalMilliseconds + (currentParagraph.Duration.TotalMilliseconds * startFactor);
|
||||
middle = currentParagraph.StartTime.TotalMilliseconds + (currentParagraph.DurationTotalMilliseconds * startFactor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12009,7 +12009,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
newParagraph.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds;
|
||||
newParagraph.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds;
|
||||
}
|
||||
else if (currentParagraph.Duration.TotalMilliseconds <= 1)
|
||||
else if (currentParagraph.DurationTotalMilliseconds <= 1)
|
||||
{
|
||||
newParagraph.StartTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds;
|
||||
newParagraph.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds;
|
||||
@ -12109,7 +12109,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
durationMilliseconds += p.Duration.TotalMilliseconds;
|
||||
durationMilliseconds += p.DurationTotalMilliseconds;
|
||||
}
|
||||
|
||||
if (sb1.Length > 150 || sb2.Length > 150)
|
||||
@ -12645,7 +12645,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (_networkSession != null)
|
||||
{
|
||||
_networkSession.TimerStop();
|
||||
SetDurationInSeconds(currentParagraph.Duration.TotalSeconds);
|
||||
SetDurationInSeconds(currentParagraph.DurationTotalSeconds);
|
||||
_networkSession.UpdateLine(_subtitle.GetIndex(currentParagraph), currentParagraph);
|
||||
var deleteIndices = new List<int>();
|
||||
deleteIndices.Add(_subtitle.GetIndex(nextParagraph));
|
||||
@ -12980,13 +12980,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged;
|
||||
|
||||
numericUpDownDuration.ValueChanged -= NumericUpDownDurationValueChanged;
|
||||
if (p.Duration.TotalSeconds > (double)numericUpDownDuration.Maximum)
|
||||
if (p.DurationTotalSeconds > (double)numericUpDownDuration.Maximum)
|
||||
{
|
||||
SetDurationInSeconds((double)numericUpDownDuration.Maximum);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDurationInSeconds(p.Duration.TotalSeconds);
|
||||
SetDurationInSeconds(p.DurationTotalSeconds);
|
||||
}
|
||||
|
||||
numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged;
|
||||
@ -13011,13 +13011,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged;
|
||||
|
||||
numericUpDownDuration.ValueChanged -= NumericUpDownDurationValueChanged;
|
||||
if (p.Duration.TotalSeconds > (double)numericUpDownDuration.Maximum)
|
||||
if (p.DurationTotalSeconds > (double)numericUpDownDuration.Maximum)
|
||||
{
|
||||
SetDurationInSeconds((double)numericUpDownDuration.Maximum);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDurationInSeconds(p.Duration.TotalSeconds);
|
||||
SetDurationInSeconds(p.DurationTotalSeconds);
|
||||
}
|
||||
|
||||
numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged;
|
||||
@ -14820,10 +14820,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (pes == null && subtitle.Paragraphs.Count > 0)
|
||||
{
|
||||
var last = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1];
|
||||
if (last.Duration.TotalMilliseconds < 100)
|
||||
if (last.DurationTotalMilliseconds < 100)
|
||||
{
|
||||
last.EndTime.TotalMilliseconds = msub.Start;
|
||||
if (last.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (last.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + 3000;
|
||||
}
|
||||
@ -14850,7 +14850,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
for (int index = 0; index < subtitle.Paragraphs.Count; index++)
|
||||
{
|
||||
var p = subtitle.Paragraphs[index];
|
||||
if (p.Duration.TotalMilliseconds < 200)
|
||||
if (p.DurationTotalMilliseconds < 200)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 3000;
|
||||
}
|
||||
@ -18185,7 +18185,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
var p = _subtitle.Paragraphs[index];
|
||||
p.EndTime = TimeCode.FromSeconds(videoPosition);
|
||||
if (p.Duration.TotalMilliseconds - MinGapBetweenLines > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
if (p.DurationTotalMilliseconds - MinGapBetweenLines > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
{
|
||||
var newEndTime = new TimeCode(p.EndTime.TotalMilliseconds - MinGapBetweenLines);
|
||||
double charactersPerSecond = Utilities.GetCharactersPerSecond(new Paragraph(p) { EndTime = newEndTime });
|
||||
@ -18196,7 +18196,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1));
|
||||
SetDurationInSeconds(_subtitle.Paragraphs[index].Duration.TotalSeconds);
|
||||
SetDurationInSeconds(_subtitle.Paragraphs[index].DurationTotalSeconds);
|
||||
ButtonInsertNewTextClick(null, null);
|
||||
UpdateSourceView();
|
||||
}
|
||||
@ -19186,14 +19186,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
var temp = new Paragraph(p);
|
||||
temp.StartTime.TotalMilliseconds = newStartTimeMs;
|
||||
if (temp.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds ||
|
||||
if (temp.DurationTotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds ||
|
||||
Utilities.GetCharactersPerSecond(temp) > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds)
|
||||
{
|
||||
var next = _subtitle.GetParagraphOrDefault(index + 1);
|
||||
if (next == null ||
|
||||
next.StartTime.TotalMilliseconds > newStartTimeMs + p.Duration.TotalMilliseconds + MinGapBetweenLines)
|
||||
next.StartTime.TotalMilliseconds > newStartTimeMs + p.DurationTotalMilliseconds + MinGapBetweenLines)
|
||||
{
|
||||
newEndTimeMs = newStartTimeMs + p.Duration.TotalMilliseconds;
|
||||
newEndTimeMs = newStartTimeMs + p.DurationTotalMilliseconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19627,7 +19627,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
isClose = true;
|
||||
prevGap = p.StartTime.TotalMilliseconds - prev.EndTime.TotalMilliseconds;
|
||||
if (ms < 0 && prev.Duration.TotalMilliseconds + ms < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
if (ms < 0 && prev.DurationTotalMilliseconds + ms < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -19645,7 +19645,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.Duration.TotalMilliseconds + Math.Abs(ms) > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (p.DurationTotalMilliseconds + Math.Abs(ms) > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -19673,7 +19673,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged;
|
||||
timeUpDownStartTime.TimeCode = p.StartTime;
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged;
|
||||
SetDurationInSeconds(p.Duration.TotalSeconds);
|
||||
SetDurationInSeconds(p.DurationTotalSeconds);
|
||||
|
||||
if (keepGapPrevIfClose && isClose && prev != null)
|
||||
{
|
||||
@ -19739,7 +19739,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
isClose = true;
|
||||
nextGap = next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds;
|
||||
if (ms > 0 && next.Duration.TotalMilliseconds + ms < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
if (ms > 0 && next.DurationTotalMilliseconds + ms < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -19748,7 +19748,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (ms > 0)
|
||||
{
|
||||
if (p.Duration.TotalMilliseconds + ms > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (p.DurationTotalMilliseconds + ms > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -19780,7 +19780,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged;
|
||||
timeUpDownStartTime.TimeCode = p.StartTime;
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged;
|
||||
SetDurationInSeconds(p.Duration.TotalSeconds);
|
||||
SetDurationInSeconds(p.DurationTotalSeconds);
|
||||
|
||||
if (keepGapNextIfClose && isClose && next != null)
|
||||
{
|
||||
@ -23627,7 +23627,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
timeUpDownStartTime.TimeCode = TimeCode.FromSeconds(videoPosition);
|
||||
|
||||
var duration = p.Duration.TotalMilliseconds;
|
||||
var duration = p.DurationTotalMilliseconds;
|
||||
|
||||
p.StartTime.TotalMilliseconds = videoPosition * TimeCode.BaseUnit;
|
||||
if (adjustEndTime)
|
||||
@ -23646,7 +23646,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (!adjustEndTime)
|
||||
{
|
||||
SetDurationInSeconds(p.Duration.TotalSeconds);
|
||||
SetDurationInSeconds(p.DurationTotalSeconds);
|
||||
}
|
||||
|
||||
UpdateOriginalTimeCodes(oldParagraph);
|
||||
@ -23721,7 +23721,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1));
|
||||
SetDurationInSeconds(_subtitle.Paragraphs[index].Duration.TotalSeconds);
|
||||
SetDurationInSeconds(_subtitle.Paragraphs[index].DurationTotalSeconds);
|
||||
UpdateSourceView();
|
||||
}
|
||||
}
|
||||
@ -24664,7 +24664,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_subtitle.Paragraphs[index].EndTime.TotalSeconds = videoPosition;
|
||||
SubtitleListview1.SetDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1));
|
||||
checkBoxSyncListViewWithVideoWhilePlaying.Checked = oldSync;
|
||||
numericUpDownDuration.Value = (decimal)_subtitle.Paragraphs[index].Duration.TotalSeconds;
|
||||
numericUpDownDuration.Value = (decimal)_subtitle.Paragraphs[index].DurationTotalSeconds;
|
||||
numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged;
|
||||
RefreshSelectedParagraph();
|
||||
|
||||
@ -24748,7 +24748,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
SubtitleListview1.SetDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1));
|
||||
SetDurationInSeconds(_subtitle.Paragraphs[index].Duration.TotalSeconds);
|
||||
SetDurationInSeconds(_subtitle.Paragraphs[index].DurationTotalSeconds);
|
||||
|
||||
if (index + 1 < _subtitle.Paragraphs.Count)
|
||||
{
|
||||
@ -29041,7 +29041,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
timeUpDownStartTime.TimeCode = p.StartTime;
|
||||
var durationInSeconds = (decimal)p.Duration.TotalSeconds;
|
||||
var durationInSeconds = (decimal)p.DurationTotalSeconds;
|
||||
if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum)
|
||||
{
|
||||
SetDurationInSeconds((double)durationInSeconds);
|
||||
@ -29091,7 +29091,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
//}
|
||||
|
||||
// current movie Position
|
||||
double durationTotalMilliseconds = p.Duration.TotalMilliseconds;
|
||||
double durationTotalMilliseconds = p.DurationTotalMilliseconds;
|
||||
double totalMillisecondsEnd = mediaPlayer.CurrentPosition * TimeCode.BaseUnit;
|
||||
|
||||
var tc = new TimeCode(totalMillisecondsEnd - durationTotalMilliseconds);
|
||||
@ -29110,7 +29110,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
timeUpDownStartTime.TimeCode = p.StartTime;
|
||||
var durationInSeconds = (decimal)(p.Duration.TotalSeconds);
|
||||
var durationInSeconds = (decimal)(p.DurationTotalSeconds);
|
||||
if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum)
|
||||
{
|
||||
SetDurationInSeconds((double)durationInSeconds);
|
||||
@ -29233,14 +29233,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged;
|
||||
}
|
||||
|
||||
if (p.Duration.TotalSeconds < 0)
|
||||
if (p.DurationTotalSeconds < 0)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text);
|
||||
}
|
||||
|
||||
SubtitleListview1.SetStartTimeAndDuration(index, p, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1));
|
||||
|
||||
SetDurationInSeconds(_subtitle.Paragraphs[index].Duration.TotalSeconds + 0.001);
|
||||
SetDurationInSeconds(_subtitle.Paragraphs[index].DurationTotalSeconds + 0.001);
|
||||
if (next != null)
|
||||
{
|
||||
int addMilliseconds = MinGapBetweenLines;
|
||||
@ -29249,7 +29249,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
addMilliseconds = 1;
|
||||
}
|
||||
|
||||
var oldDuration = next.Duration.TotalMilliseconds;
|
||||
var oldDuration = next.DurationTotalMilliseconds;
|
||||
if (next.StartTime.IsMaxTime || next.EndTime.IsMaxTime)
|
||||
{
|
||||
oldDuration = Utilities.GetOptimalDisplayMilliseconds(p.Text);
|
||||
@ -30332,7 +30332,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
// current sub
|
||||
}
|
||||
else if (p.Duration.TotalSeconds < 10 && p.StartTime.TotalMilliseconds > ms)
|
||||
else if (p.DurationTotalSeconds < 10 && p.StartTime.TotalMilliseconds > ms)
|
||||
{
|
||||
mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds;
|
||||
SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(p), true);
|
||||
@ -30355,7 +30355,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
// current sub
|
||||
}
|
||||
else if (p.Duration.TotalSeconds < 10 && p.StartTime.TotalMilliseconds < ms)
|
||||
else if (p.DurationTotalSeconds < 10 && p.StartTime.TotalMilliseconds < ms)
|
||||
{
|
||||
mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds;
|
||||
SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(p), true);
|
||||
|
@ -384,14 +384,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else if (comboBoxRule.SelectedIndex == FunctionDurationLessThan) // Duration less than
|
||||
{
|
||||
if (p.Duration.TotalMilliseconds < (double)numericUpDownDuration.Value)
|
||||
if (p.DurationTotalMilliseconds < (double)numericUpDownDuration.Value)
|
||||
{
|
||||
listViewItems.Add(MakeListViewItem(p, i));
|
||||
}
|
||||
}
|
||||
else if (comboBoxRule.SelectedIndex == FunctionDurationGreaterThan) // Duration greater than
|
||||
{
|
||||
if (p.Duration.TotalMilliseconds > (double)numericUpDownDuration.Value)
|
||||
if (p.DurationTotalMilliseconds > (double)numericUpDownDuration.Value)
|
||||
{
|
||||
listViewItems.Add(MakeListViewItem(p, i));
|
||||
}
|
||||
|
@ -1476,7 +1476,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
Paragraph p = new Paragraph(string.Empty, x.StartTime.TotalMilliseconds, x.EndTime.TotalMilliseconds);
|
||||
if (checkBoxUseTimeCodesFromIdx.Checked && x.IdxLine != null)
|
||||
{
|
||||
double durationMilliseconds = p.Duration.TotalMilliseconds;
|
||||
double durationMilliseconds = p.DurationTotalMilliseconds;
|
||||
p.StartTime = new TimeCode(x.IdxLine.StartTime.TotalMilliseconds);
|
||||
p.EndTime = new TimeCode(x.IdxLine.StartTime.TotalMilliseconds + durationMilliseconds);
|
||||
}
|
||||
@ -7512,7 +7512,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
foreach (var old in oldSubtitle.Paragraphs)
|
||||
{
|
||||
if (Math.Abs(current.StartTime.TotalMilliseconds - old.StartTime.TotalMilliseconds) < 0.01 &&
|
||||
Math.Abs(current.Duration.TotalMilliseconds - old.Duration.TotalMilliseconds) < 0.01)
|
||||
Math.Abs(current.DurationTotalMilliseconds - old.DurationTotalMilliseconds) < 0.01)
|
||||
{
|
||||
current.Text = old.Text;
|
||||
break;
|
||||
|
@ -424,7 +424,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (imageSub == null)
|
||||
{
|
||||
var mean = _currentParagraph.StartTime.TotalMilliseconds + _currentParagraph.Duration.TotalMilliseconds / 2;
|
||||
var mean = _currentParagraph.StartTime.TotalMilliseconds + _currentParagraph.DurationTotalMilliseconds / 2;
|
||||
imageSub = _binSubtitles.FirstOrDefault(p => mean >= p.StartTimeCode.TotalMilliseconds && mean <= _currentParagraph.EndTime.TotalMilliseconds);
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
var newParagraph2 = new Paragraph(p);
|
||||
newParagraph1.Text = Utilities.AutoBreakLine(arr[0], language);
|
||||
|
||||
var middle = p.StartTime.TotalMilliseconds + p.Duration.TotalMilliseconds / 2;
|
||||
var middle = p.StartTime.TotalMilliseconds + p.DurationTotalMilliseconds / 2;
|
||||
if (!string.IsNullOrWhiteSpace(oldText))
|
||||
{
|
||||
var startFactor = (double)HtmlUtil.RemoveHtmlTags(newParagraph1.Text).Length / oldText.Length;
|
||||
@ -217,7 +217,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
startFactor = 0.75;
|
||||
}
|
||||
|
||||
middle = p.StartTime.TotalMilliseconds + p.Duration.TotalMilliseconds * startFactor;
|
||||
middle = p.StartTime.TotalMilliseconds + p.DurationTotalMilliseconds * startFactor;
|
||||
}
|
||||
|
||||
newParagraph1.EndTime.TotalMilliseconds = middle - spacing1;
|
||||
@ -302,7 +302,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
var durationMs = p.Duration.TotalMilliseconds / arr.Count;
|
||||
var durationMs = p.DurationTotalMilliseconds / arr.Count;
|
||||
for (var index = 0; index < arr.Count; index++)
|
||||
{
|
||||
var line = arr[index];
|
||||
@ -318,7 +318,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
var minGap = Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
if (minGap > 0 &&
|
||||
newParagraph.Duration.TotalMilliseconds - minGap > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
newParagraph.DurationTotalMilliseconds - minGap > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
{
|
||||
newParagraph.EndTime.TotalMilliseconds -= minGap;
|
||||
}
|
||||
@ -421,7 +421,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
var newParagraph2 = new Paragraph(p);
|
||||
newParagraph1.Text = Utilities.AutoBreakLine(arr[0], language);
|
||||
|
||||
var middle = p.StartTime.TotalMilliseconds + p.Duration.TotalMilliseconds / 2;
|
||||
var middle = p.StartTime.TotalMilliseconds + p.DurationTotalMilliseconds / 2;
|
||||
if (!string.IsNullOrWhiteSpace(oldText))
|
||||
{
|
||||
var startFactor = (double)HtmlUtil.RemoveHtmlTags(newParagraph1.Text).Length / oldText.Length;
|
||||
@ -435,7 +435,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
startFactor = 0.75;
|
||||
}
|
||||
|
||||
middle = p.StartTime.TotalMilliseconds + p.Duration.TotalMilliseconds * startFactor;
|
||||
middle = p.StartTime.TotalMilliseconds + p.DurationTotalMilliseconds * startFactor;
|
||||
}
|
||||
|
||||
newParagraph1.EndTime.TotalMilliseconds = middle - spacing1;
|
||||
|
@ -138,7 +138,7 @@ https://github.com/SubtitleEdit/subtitleedit
|
||||
maximumLineLength = Math.Max(len, maximumLineLength);
|
||||
totalLineLength += len;
|
||||
|
||||
var duration = p.Duration.TotalMilliseconds;
|
||||
var duration = p.DurationTotalMilliseconds;
|
||||
minimumDuration = Math.Min(duration, minimumDuration);
|
||||
maximumDuration = Math.Max(duration, maximumDuration);
|
||||
totalDuration += duration;
|
||||
@ -218,11 +218,11 @@ https://github.com/SubtitleEdit/subtitleedit
|
||||
aboveMaximumWpmCount++;
|
||||
}
|
||||
|
||||
if (p.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
if (p.DurationTotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
{
|
||||
belowMinimumDurationCount++;
|
||||
}
|
||||
if (p.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
if (p.DurationTotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
aboveMaximumDurationCount++;
|
||||
}
|
||||
@ -324,7 +324,7 @@ https://github.com/SubtitleEdit/subtitleedit
|
||||
for (var i = 0; i < _subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
var p = _subtitle.Paragraphs[i];
|
||||
if (Math.Abs(p.Duration.TotalMilliseconds - duration) < 0.01)
|
||||
if (Math.Abs(p.DurationTotalMilliseconds - duration) < 0.01)
|
||||
{
|
||||
if (indices.Count >= NumberOfLinesToShow)
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (_synchronizationPoints.ContainsKey(i))
|
||||
{
|
||||
var p = new Paragraph { StartTime = { TotalMilliseconds = _synchronizationPoints[i].TotalMilliseconds } };
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + _subtitle.Paragraphs[i].Duration.TotalMilliseconds;
|
||||
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + _subtitle.Paragraphs[i].DurationTotalMilliseconds;
|
||||
SubtitleListview1.SetStartTimeAndDuration(i, p, _subtitle.GetParagraphOrDefault(i + 1), _subtitle.GetParagraphOrDefault(i - 1));
|
||||
|
||||
var item = new ListBoxSyncPoint { Index = i, Text = _subtitle.Paragraphs[i].Number + " - " + p.StartTime };
|
||||
|
@ -84,7 +84,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
if (p.StartTime.TotalMilliseconds <= positionInMilliseconds + 0.01 && p.EndTime.TotalMilliseconds >= positionInMilliseconds - 0.01)
|
||||
{
|
||||
string text = p.Text.Replace("|", Environment.NewLine);
|
||||
bool isInfo = p == subtitle.Paragraphs[0] && (Math.Abs(p.StartTime.TotalMilliseconds) < 0.01 && Math.Abs(p.Duration.TotalMilliseconds) < 0.01 || Math.Abs(p.StartTime.TotalMilliseconds - Pac.PacNullTime.TotalMilliseconds) < 0.01);
|
||||
bool isInfo = p == subtitle.Paragraphs[0] && (Math.Abs(p.StartTime.TotalMilliseconds) < 0.01 && Math.Abs(p.DurationTotalMilliseconds) < 0.01 || Math.Abs(p.StartTime.TotalMilliseconds - Pac.PacNullTime.TotalMilliseconds) < 0.01);
|
||||
if (!isInfo)
|
||||
{
|
||||
if (videoPlayerContainer.LastParagraph != p)
|
||||
|
Loading…
Reference in New Issue
Block a user