From 11b66df5e61a4f8a0025f51e8b366fc66c5b752b Mon Sep 17 00:00:00 2001 From: nilaoda Date: Sun, 10 Jul 2022 18:23:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=9B=B4=E6=92=ADstartNumber?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs b/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs index 9724d8a..be8f59f 100644 --- a/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs +++ b/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs @@ -145,6 +145,11 @@ namespace N_m3u8DL_RE.Parser.Extractor "audio" => MediaType.AUDIO, _ => null }; + //优化字幕场景识别 + if (streamSpec.Codecs == "stpp" || streamSpec.Codecs == "wvtt") + { + streamSpec.MediaType = MediaType.SUBTITLES; + } streamSpec.Playlist.IsLive = isLive; //设置刷新间隔 timeShiftBufferDepth / 2 if (timeShiftBufferDepth != null) @@ -328,11 +333,8 @@ namespace N_m3u8DL_RE.Parser.Extractor var availableTime = DateTime.Parse(availabilityStartTime); var ts = now - availableTime; var updateTs = XmlConvert.ToTimeSpan(timeShiftBufferDepth); - if (startNumberStr == null) - { - //(当前时间到发布时间的时间差 - 最小刷新间隔) / 分片时长 - startNumber = (long)((ts.TotalSeconds - updateTs.TotalSeconds) * timescale / duration); - } + //(当前时间到发布时间的时间差 - 最小刷新间隔) / 分片时长 + startNumber += (long)((ts.TotalSeconds - updateTs.TotalSeconds) * timescale / duration); totalNumber = (long)(updateTs.TotalSeconds * timescale / duration); } for (long index = startNumber, segIndex = 0; index < startNumber + totalNumber; index++, segIndex++) @@ -341,7 +343,7 @@ namespace N_m3u8DL_RE.Parser.Extractor var mediaUrl = ParserUtil.ReplaceVars(ParserUtil.CombineURL(segBaseUrl, media), varDic); MediaSegment mediaSegment = new(); mediaSegment.Url = PreProcessUrl(mediaUrl); - mediaSegment.Index = segIndex; + mediaSegment.Index = isLive ? index : segIndex; //直播直接用startNumber mediaSegment.Duration = duration / (double)timescale; streamSpec.Playlist.MediaParts[0].MediaSegments.Add(mediaSegment); }