From 616da62f7490e7cfc843f8a53ae2134eb715a63e Mon Sep 17 00:00:00 2001 From: nilaoda Date: Thu, 17 Nov 2022 22:15:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=86=E5=88=AB=E9=83=A8=E5=88=86`presentati?= =?UTF-8?q?onTimeOffset`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs b/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs index 77970d5..1f2d4aa 100644 --- a/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs +++ b/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs @@ -300,6 +300,8 @@ namespace N_m3u8DL_RE.Parser.Extractor var varDic = new Dictionary(); varDic[DASHTags.TemplateRepresentationID] = streamSpec.GroupId; varDic[DASHTags.TemplateBandwidth] = bandwidth?.Value; + //presentationTimeOffset + var presentationTimeOffsetStr = segmentTemplate.Attribute("presentationTimeOffset")?.Value ?? segmentTemplateOuter.Attribute("presentationTimeOffset")?.Value ?? "0"; //timesacle var timescaleStr = segmentTemplate.Attribute("timescale")?.Value ?? segmentTemplateOuter.Attribute("timescale")?.Value ?? "1"; var durationStr = segmentTemplate.Attribute("duration")?.Value ?? segmentTemplateOuter.Attribute("duration")?.Value; @@ -318,7 +320,7 @@ namespace N_m3u8DL_RE.Parser.Extractor if (segmentTimeline != null) { //使用了SegmentTimeline 结果精确 - var segNumber = Convert.ToInt32(startNumberStr); + var segNumber = Convert.ToInt64(startNumberStr); var Ss = segmentTimeline.Elements().Where(e => e.Name.LocalName == "S"); var currentTime = 0L; var segIndex = 0; @@ -373,6 +375,9 @@ namespace N_m3u8DL_RE.Parser.Extractor { var now = publishTime == null ? DateTime.Now : DateTime.Parse(publishTime); var availableTime = DateTime.Parse(availabilityStartTime!); + //可用时间+偏移量 + var offsetMs = TimeSpan.FromMilliseconds(Convert.ToInt64(presentationTimeOffsetStr) / 1000); + availableTime = availableTime.Add(offsetMs); var ts = now - availableTime; var updateTs = XmlConvert.ToTimeSpan(timeShiftBufferDepth!); //(当前时间到发布时间的时间差 - 最小刷新间隔) / 分片时长