This commit is contained in:
nilaoda 2022-12-12 00:18:54 +08:00
parent 3855834d63
commit 04de21e594
2 changed files with 10 additions and 5 deletions

View File

@ -152,14 +152,19 @@ namespace N_m3u8DL_RE.Common.Entity
} }
//确实存在时间轴错误的情况,才修复 //确实存在时间轴错误的情况,才修复
if ((this.Cues.Count > 0 && sub.Cues.Count > 0 && sub.Cues.First().StartTime < this.Cues.Last().EndTime) || this.Cues.Count == 0) if ((this.Cues.Count > 0 && sub.Cues.Count > 0 && sub.Cues.First().StartTime < this.Cues.Last().EndTime && sub.Cues.First().EndTime != this.Cues.Last().EndTime) || this.Cues.Count == 0)
{ {
//The MPEG2 transport stream clocks (PCR, PTS, DTS) all have units of 1/90000 second //The MPEG2 transport stream clocks (PCR, PTS, DTS) all have units of 1/90000 second
var seconds = (sub.MpegtsTimestamp - baseTimestamp) / 90000; var seconds = (sub.MpegtsTimestamp - baseTimestamp) / 90000;
for (int i = 0; i < sub.Cues.Count; i++) var offset = TimeSpan.FromSeconds(seconds);
//当前预添加的字幕的起始时间小于实际上已经走过的时间(如offset已经是100秒而字幕起始却是2秒),才修复
if (sub.Cues.Count > 0 && sub.Cues.First().StartTime < offset)
{ {
sub.Cues[i].StartTime += TimeSpan.FromSeconds(seconds); for (int i = 0; i < sub.Cues.Count; i++)
sub.Cues[i].EndTime += TimeSpan.FromSeconds(seconds); {
sub.Cues[i].StartTime += offset;
sub.Cues[i].EndTime += offset;
}
} }
} }
} }

View File

@ -18,7 +18,7 @@ namespace N_m3u8DL_RE.CommandLine
{ {
internal partial class CommandInvoker internal partial class CommandInvoker
{ {
public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20221210"; public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20221211";
[GeneratedRegex("((best|worst)\\d*|all)")] [GeneratedRegex("((best|worst)\\d*|all)")]
private static partial Regex ForStrRegex(); private static partial Regex ForStrRegex();