Hi there,
I've noticed that we're having issue with calculate the correct duration for live stream with DVR window after live ended.
I'll trying to explain the issue with example below, let's say:
- We have a live stream with DVR window, start at
10000
- User is watching at
10050
- User has
20 seconds buffered
- Live stream ended at
10600
Based all those things, while right before live ended, the status should be:
- videoElement.duration:
math.pow(2,32)
- minimumPosition:
10000
- maximumPosition:
10600
- position:
10050
In our codebase, we're calculate the current time and duration as:
currentTime: (position - minimumPosition) = 50
duration: (maximumPosition - minimumPosition) = 600
which is correct.
While live ended, we get:
- videoElement.duration:
10070 (10050 + 20 which is maxBufferedEnd)
- minimumPosition:
0
- maximumPosition:
10070 (which is equal to videoElement.duration)
- position:
10050
currentTime: (position - minimumPosition) = 10050
duration: (maximumPosition - minimumPosition) = 10070
All those value are totally incorrect, the expected value should be:
currentTime: 50
duration: 600
I've found a way to make current time to correct one, which is after live ended, I call videoElement.current = 50.1 to adjust the current time to correct one. But I can not do anything correct to make duration works fine unless I cache the last dynamic duration (I don't think it's a correct way)
From read code, I found the reason why duration is not correct:
We're change the duration to maxBufferredEnd here:
|
if (maxBufferedEnd < mediaSource.duration) { |
|
try { |
|
log.info("Init: Updating duration to what is currently buffered", maxBufferedEnd); |
|
mediaSource.duration = maxBufferedEnd; |
|
} catch (err) { |
|
log.warn( |
|
"Duration Updater: Can't update duration on the MediaSource.", |
|
err instanceof Error ? err : "", |
|
); |
|
return MediaSourceDurationUpdateStatus.Failed; |
|
} |
and after live ended, we're return duration (wrong value) directly:
|
if (manifest !== null) { |
|
if (!manifest.isDynamic && this.videoElement !== null) { |
|
return this.videoElement.duration; |
|
} |
|
return getMaximumSafePosition(manifest); |
Is there any other way to get it works? Thanks
Hi there,
I've noticed that we're having issue with calculate the correct duration for live stream with DVR window after live ended.
I'll trying to explain the issue with example below, let's say:
100001005020seconds buffered10600Based all those things, while right before live ended, the status should be:
math.pow(2,32)100001060010050In our codebase, we're calculate the current time and duration as:
currentTime:
(position - minimumPosition) = 50duration:
(maximumPosition - minimumPosition) = 600which is correct.
While live ended, we get:
10070 (10050 + 20 which is maxBufferedEnd)010070 (which is equal to videoElement.duration)10050currentTime:
(position - minimumPosition) = 10050duration:
(maximumPosition - minimumPosition) = 10070All those value are totally incorrect, the expected value should be:
currentTime:
50duration:
600I've found a way to make current time to correct one, which is after live ended, I call
videoElement.current = 50.1to adjust the current time to correct one. But I can not do anything correct to make duration works fine unless I cache the last dynamic duration (I don't think it's a correct way)From read code, I found the reason why duration is not correct:
We're change the duration to
maxBufferredEndhere:rx-player/src/mse/utils/media_source_duration_updater.ts
Lines 183 to 193 in 766e446
and after live ended, we're return duration (wrong value) directly:
rx-player/src/main_thread/api/public_api.ts
Lines 2646 to 2650 in 766e446
Is there any other way to get it works? Thanks