简体   繁体   中英

How do I jump to a concrete UTC timestamp in an hls stream via hls.js

We are using an audioplayer that uses the hls.js library to playback radio livestreams in hls format. We are trying to implement a feature that allows our users to jump back in the livestream to a certain point in time (the starttime of a song). From each song that was played in a timeframe of the last two hours we have the starttime of that song as a UTC timestamp. As hls.js doesn't seem to offer any utility method to directly seek to the position of a certain utc timestamp we tried to figure out other ways to calculate that point in the stream.

Our idea is to figure out the utc timestamp at which the stream is playing at the moment, use this timestamp to calculate the difference in seconds between that livetime in the stream and the starttime of the song we want to jump to and add that difference to the current position of the player in the stream (we get this position as the time of seconds the stream is playing in hour two hour time window). But unfortunately we only managed to figure out the starttime of the currently played fragment in the stream but fail to find the exact point in time where the stream is actually playing in the fragment. As we have a fragment duration of 5 seconds our calculation of the jump position is hence not that exact.

Does anyone have an idea how to get the exact utc timestamp at which the livestream is currently playing via hls.js? On Android with the exoplayer for example one could calculate the utc timestamp of the current position in the livestream with the help of the HLSManifest class. That class offers a method that returns at any time the utc timestamp of the startingpoint of the configured hls time window. By adding the time of the current position in that time window (in seconds) one could easily calculate the exact utc timestamp at which the stream is at a certain point in time.

Any help, even the smallest hint on how to that with hls.js is appreciated. Thanks in advance.

Were you able to resolve this? I could implement this for MPD (DASH) but not for M3U8 (HLS) For MPD, used below tags to achieve the same.

to keep the video on demand

type="static"
mediaPresentationDuration="PT2M7.3S"
minBufferTime="PT10.0S">

to allow video to start only at specific time

type="dynamic"
minimumUpdatePeriod="PT5S"
suggestedPresentationDelay="PT5S"
availabilityStartTime="2020-07-16T09:23:30Z"
publishTime="2020-07-16T09:23:30Z"
timeShiftBufferDepth="PT20M50.0S"
minBufferTime="PT10.0S">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM