How is duration determined by hls.js ? #5073
-
I have a playlist file like so:
Unfortunately, I can't share the segments. When I load this with hls.js sometimes the duration is the length of the 2 segments (so 20 sec) and sometimes it is the length of the original video. This is a part of the original video, with only 2 segments. Can someone help me debug this, please? I don't understand how hls.js determines the duration and why there is some sort of race condition. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
HLS.js determines duration first based on the Playlist (20 seconds using the example above). As it parses each segment, it updates its model of the playlist, based on the duration of the media parsed. After processing the first segment, if it finds that it has only 9.5s of audio or video, then the duration will be updated from accordingly (20 -> 19.5). Very small amounts of change are ignored, and reducing the duration is avoided (see buffer-controller for how MediaSource duration is set). |
Beta Was this translation helpful? Give feedback.
HLS.js determines duration first based on the Playlist (20 seconds using the example above). As it parses each segment, it updates its model of the playlist, based on the duration of the media parsed. After processing the first segment, if it finds that it has only 9.5s of audio or video, then the duration will be updated from accordingly (20 -> 19.5).
Very small amounts of change are ignored, and reducing the duration is avoided (see buffer-controller for how MediaSource duration is set).