fix: #4736 Calculate duration for periods without duration field#4746
fix: #4736 Calculate duration for periods without duration field#4746KimmyWFox wants to merge 2 commits intoDash-Industry-Forum:developmentfrom
Conversation
|
|
||
| function _getSafeDuration(periods) { | ||
| const sumPeriodDurations = periods.reduce((totalDuration, period) => totalDuration + period.duration, 0); | ||
| if (isNaN(sumPeriodDurations)) { |
There was a problem hiding this comment.
Should this be !sNaN(sumPeriodDurations) to return the value in case it is not NaN
|
|
||
| const lastPeriod = periods[periods.length - 1]; | ||
| if (lastPeriod.duration) { | ||
| return lastPeriod.start + lastPeriod.duration; |
There was a problem hiding this comment.
Add a check to verify that lastPeriod.start is not undefined or null or NaN
| return lastPeriod.start + lastPeriod.duration; | ||
| } | ||
|
|
||
| const segmentTemplate = lastPeriod.AdaptationSet.filter((set) => set.mimeType === 'video/mp4')[0].Representation[0].SegmentTemplate; |
There was a problem hiding this comment.
This will cause an issue if there is no AdaptationSet with mimeType set to video/mp4. Please add some checks if the attributes are accessible. Please also add a try...catch statement in the function and return NaN in the catch block.
For instance, in this manifest the mimeType is on Representation level: https://dash.akamaized.net/dash264/TestCases/5a/nomor/1.mpd
| } | ||
|
|
||
| const segmentTemplate = lastPeriod.AdaptationSet.filter((set) => set.mimeType === 'video/mp4')[0].Representation[0].SegmentTemplate; | ||
| const segments = segmentTemplate.SegmentTimeline.S; |
There was a problem hiding this comment.
Can we cover the case in which SegmentTemplate is used without SegmentTimeline
| } | ||
|
|
||
| function _getSegmentDuration(s) { | ||
| return (s.r ? s.d * (s.r + 1) : s.d); |
There was a problem hiding this comment.
Does not cover the case of negative r values, see TimelineSegmentsGetter.iterateSegments
|
@KimmyWFox Did you have the chance to check my comments? |
|
@KimmyWFox Any updates from your side? |
This fixes issue #4736.
If the sum of periods is
NaN, calculate the duration using segment information from the last period.