canalplus / rx-player

DASH/Smooth HTML5 Video Player
https://developers.canal-plus.com/rx-player/
Apache License 2.0
859 stars 131 forks source link

fromFirstPosition does not start from actual first position in live DASH manifest (multi period live with SSAI) #1410

Open m-scheepers opened 6 months ago

m-scheepers commented 6 months ago

Background we are working on a project with server-side ad insertion (for live streaming). In this case we will have a multi-period DASH stream where a period is inserted which will include the pre-roll ad. We would like to start the live stream from the beginning of the manifest (which is the beginning of the pre-roll ad).

Currently using Rxplayer v3

We are using fromFirstPosition for the startAt in LoadVideourl options however we notice that the stream does not seems to start from the actual start moment and is 4-6 seconds away from this moment.

Based on some discussion via Teams we found there are various calculations with rxplayer and safety margins taken into account to determine the start position. However we would like to have a way to force the player to start from the beginning of the live stream in order to playback the advertisement content from the start.

Would there be a way to accommodate this within rxplayer? Or a way to force the playback to the begin moment?

peaBerberian commented 6 months ago

Hi,

First sorry I know we had another channel of discussion and didn't take the time to answer there yet (I now just did a little late).

As discussed, the first segment the RxPlayer can load is determined through a complex combination of multiple MPD attributes. The most important ones seen on the MPD you communicated were: the UTCTiming element (providing here the live position), the MPD@availabilityStartTime attribute (providing the base offset), the MPD@timeShiftBufferDepth attribute (providing the buffer depth server-side, which we for now consider as a delta from the live position derived from the value extracted from the UTCTiming element) and the list of announced segments (to simplify, we determine the intersection of both time ranges derived from [live position - timeShiftBufferDepth, live position] and the one derived from [time of first segment, time of last segment] to understand what segments are actually available).

Here it seems that the timeShiftBufferDepth is I would say "pessimistic" as it did not include the full range of the ad inserted before the actual live content, thus the RxPlayer believes that older segments for the pre-roll ad announced in the MPD are already to old to be requested. I think that not setting the timeShiftBufferDepth or setting one high enough will allow the RxPlayer to understand that those segments are still valid but I understand that the tool you have to produce the stream's MPD is not able to do that.

I'm not convinced by the idea of indicating through some API that all segments seen in the initial MPD are all valid because of several issues:

So I would first prefer to exchange with the provider of this ad-insertion tool to be able to find a solution which would be more viable.

m-scheepers commented 6 months ago

@peaBerberian we are checking with the provider of the streaming platform in what way we can further "tweak" the streams in order to start at the beginning of the inserted pre-rolls ads. Once I have an update on this I will share the results.