video-dev / video-dev/hls.js

Buffer gap when playing Low Latency HLS with parts that may not start with IDR

Open
#7,782 1 comment 0 reactions 1 assignee View on GitHub

@dzianis-dashkevich is already working on this.

Since Apr 7, 2026.

Bug
Dominant language
TypeScript
Stars
16.9k
Forks
2.8k
Avg merge
1d 12h
Merged PRs (30d)
27

Description

What version of Hls.js are you using?

v1.6.15

What browser (including version) are you using?

Chrome 146.0.7680.178 (Official Build) (arm64)

What OS (including version) are you using?

macOS 26.4 (25E246)

Test stream

No response

Configuration
{
  "debug": true,
  "enableWorker": true,
  "lowLatencyMode": true,
  "backBufferLength": 90
}
Additional player setup steps

No response

Checklist
Steps to reproduce

Example fragment parts:
I -> D -> I -> D -> D -> D

Here is an example of mid "independent" part that does not start with IDR:

    -----+-----+------+------------+------------+----------+----------------------------------------------
    Part | Pkt | Type | Rel PTS    | Rel DTS    | CTS      | Label
    -----+-----+------+------------+------------+----------+----------------------------------------------
       1 |   0 |  IDR |   0.050000 |   0.000000 | 0.050000 | <-- Part 1 start | IDR KEYFRAME | GOP begins here
       1 |   1 |    P |   0.183333 |   0.016667 | 0.166666 |
       1 |   2 |    B |   0.116667 |   0.033333 | 0.083334 |
       1 |   3 |    B |   0.083333 |   0.050000 | 0.033333 |
       1 |   4 |    P |   0.066667 |   0.066667 | 0.000000 |
       1 |   5 |    B |   0.100000 |   0.083333 | 0.016667 |
       1 |   6 |    B |   0.150000 |   0.100000 | 0.050000 |
       1 |   7 |    B |   0.133333 |   0.116667 | 0.016666 |
       1 |   8 |    B |   0.166667 |   0.133333 | 0.033334 |
       1 |   9 |    P |   0.316667 |   0.150000 | 0.166667 |
       1 |  10 |    B |   0.250000 |   0.166667 | 0.083333 |
       1 |  11 |    B |   0.216667 |   0.183333 | 0.033334 |
       1 |  12 |    P |   0.200000 |   0.200000 | 0.000000 |
       1 |  13 |    B |   0.233333 |   0.216667 | 0.016666 |
       1 |  14 |    B |   0.283333 |   0.233333 | 0.050000 |
       1 |  15 |    B |   0.266667 |   0.250000 | 0.016667 |
       1 |  16 |    B |   0.300000 |   0.266667 | 0.033333 |
       1 |  17 |    P |   0.450000 |   0.283333 | 0.166667 |
       1 |  18 |    B |   0.383333 |   0.300000 | 0.083333 |
       1 |  19 |    B |   0.350000 |   0.316667 | 0.033333 |
       1 |  20 |    P |   0.333333 |   0.333333 | 0.000000 |
       1 |  21 |    B |   0.366667 |   0.350000 | 0.016667 |
       1 |  22 |    B |   0.416667 |   0.366667 | 0.050000 |
       1 |  23 |    B |   0.400000 |   0.383333 | 0.016667 |
       1 |  24 |    B |   0.433333 |   0.400000 | 0.033333 |
       1 |  25 |    P |   0.583333 |   0.416667 | 0.166666 |
       1 |  26 |    B |   0.516667 |   0.433333 | 0.083334 |
       1 |  27 |    B |   0.483333 |   0.450000 | 0.033333 |
       1 |  28 |    P |   0.466667 |   0.466667 | 0.000000 |
       1 |  29 |    B |   0.500000 |   0.483333 | 0.016667 |
       1 |  30 |    B |   0.550000 |   0.500000 | 0.050000 |
       1 |  31 |    B |   0.533333 |   0.516667 | 0.016666 |
       1 |  32 |    B |   0.566667 |   0.533333 | 0.033334 |
       1 |  33 |    P |   0.716667 |   0.550000 | 0.166667 |
       1 |  34 |    B |   0.650000 |   0.566667 | 0.083333 |
       1 |  35 |    B |   0.616667 |   0.583333 | 0.033334 |
       1 |  36 |    P |   0.600000 |   0.600000 | 0.000000 |
       1 |  37 |    B |   0.633333 |   0.616667 | 0.016666 |
       1 |  38 |    B |   0.683333 |   0.633333 | 0.050000 |
       1 |  39 |    B |   0.666667 |   0.650000 | 0.016667 |
       1 |  40 |    B |   0.700000 |   0.666667 | 0.033333 |
       1 |  41 |    P |   0.850000 |   0.683333 | 0.166667 |
       1 |  42 |    B |   0.783333 |   0.700000 | 0.083333 |
       1 |  43 |    B |   0.750000 |   0.716667 | 0.033333 |
       1 |  44 |    P |   0.733333 |   0.733333 | 0.000000 |
       1 |  45 |    B |   0.766667 |   0.750000 | 0.016667 |
       1 |  46 |    B |   0.816667 |   0.766667 | 0.050000 |
       1 |  47 |    B |   0.800000 |   0.783333 | 0.016667 | <-- Part 1 end | GOP continues into Part 2...
    -----+-----+------+------------+------------+----------+----------------------------------------------
       2 |   0 |    B |   0.833333 |   0.800000 | 0.033333 | <-- Part 2 start (dependent) | same GOP, no IDR
       2 |   1 |    P |   0.983333 |   0.816667 | 0.166666 |
       2 |   2 |    B |   0.916667 |   0.833333 | 0.083334 |
       2 |   3 |    B |   0.883333 |   0.850000 | 0.033333 |
       2 |   4 |    P |   0.866667 |   0.866667 | 0.000000 |
       2 |   5 |    B |   0.900000 |   0.883333 | 0.016667 |
       2 |   6 |    B |   0.950000 |   0.900000 | 0.050000 |
       2 |   7 |    B |   0.933333 |   0.916667 | 0.016666 |
       2 |   8 |    B |   0.966667 |   0.933333 | 0.033334 |
       2 |   9 |    P |   1.116667 |   0.950000 | 0.166667 |
       2 |  10 |    B |   1.050000 |   0.966667 | 0.083333 |
       2 |  11 |    B |   1.016667 |   0.983333 | 0.033334 |
       2 |  12 |    P |   1.000000 |   1.000000 | 0.000000 |
       2 |  13 |    B |   1.033333 |   1.016667 | 0.016666 |
       2 |  14 |    B |   1.083333 |   1.033333 | 0.050000 |
       2 |  15 |    B |   1.066667 |   1.050000 | 0.016667 |
       2 |  16 |    B |   1.100000 |   1.066667 | 0.033333 |
       2 |  17 |    P |   1.250000 |   1.083333 | 0.166667 |
       2 |  18 |    B |   1.183333 |   1.100000 | 0.083333 |
       2 |  19 |    B |   1.150000 |   1.116667 | 0.033333 |
       2 |  20 |    P |   1.133333 |   1.133333 | 0.000000 |
       2 |  21 |    B |   1.166667 |   1.150000 | 0.016667 |
       2 |  22 |    B |   1.216667 |   1.166667 | 0.050000 |
       2 |  23 |    B |   1.200000 |   1.183333 | 0.016667 |
       2 |  24 |    B |   1.233333 |   1.200000 | 0.033333 |
       2 |  25 |    P |   1.383333 |   1.216667 | 0.166666 |
       2 |  26 |    B |   1.316667 |   1.233333 | 0.083334 |
       2 |  27 |    B |   1.283333 |   1.250000 | 0.033333 |
       2 |  28 |    P |   1.266667 |   1.266667 | 0.000000 |
       2 |  29 |    B |   1.300000 |   1.283333 | 0.016667 |
       2 |  30 |    B |   1.350000 |   1.300000 | 0.050000 |
       2 |  31 |    B |   1.333333 |   1.316667 | 0.016666 |
       2 |  32 |    B |   1.366667 |   1.333333 | 0.033334 |
       2 |  33 |    P |   1.516667 |   1.350000 | 0.166667 |
       2 |  34 |    B |   1.450000 |   1.366667 | 0.083333 |
       2 |  35 |    B |   1.416667 |   1.383333 | 0.033334 |
       2 |  36 |    P |   1.400000 |   1.400000 | 0.000000 |
       2 |  37 |    B |   1.433333 |   1.416667 | 0.016666 |
       2 |  38 |    B |   1.483333 |   1.433333 | 0.050000 |
       2 |  39 |    B |   1.466667 |   1.450000 | 0.016667 |
       2 |  40 |    B |   1.500000 |   1.466667 | 0.033333 |
       2 |  41 |    P |   1.650000 |   1.483333 | 0.166667 |
       2 |  42 |    B |   1.583333 |   1.500000 | 0.083333 |
       2 |  43 |    B |   1.550000 |   1.516667 | 0.033333 |
       2 |  44 |    P |   1.533333 |   1.533333 | 0.000000 |
       2 |  45 |    B |   1.566667 |   1.550000 | 0.016667 |
       2 |  46 |    B |   1.616667 |   1.566667 | 0.050000 |
       2 |  47 |    B |   1.600000 |   1.583333 | 0.016667 | <-- Part 2 end | GOP continues into Part 3...
    -----+-----+------+------------+------------+----------+----------------------------------------------
       3 |   0 |    B |   1.633333 |   1.600000 | 0.033333 | <-- Part 3 start (INDEPENDENT=YES) | still no IDR!
       3 |   1 |    P |   1.783333 |   1.616667 | 0.166666 |
       3 |   2 |    B |   1.716667 |   1.633333 | 0.083334 |
       3 |   3 |    B |   1.683333 |   1.650000 | 0.033333 |
       3 |   4 |    P |   1.666667 |   1.666667 | 0.000000 |
       3 |   5 |    B |   1.700000 |   1.683333 | 0.016667 |
       3 |   6 |    B |   1.750000 |   1.700000 | 0.050000 |
       3 |   7 |    B |   1.733333 |   1.716667 | 0.016666 |
       3 |   8 |    B |   1.766667 |   1.733333 | 0.033334 |
       3 |   9 |    P |   1.916667 |   1.750000 | 0.166667 |
       3 |  10 |    B |   1.850000 |   1.766667 | 0.083333 |
       3 |  11 |    B |   1.816667 |   1.783333 | 0.033334 |
       3 |  12 |    P |   1.800000 |   1.800000 | 0.000000 |    ... 24 dependent frames before IDR (DROPPED)
       3 |  13 |    B |   1.833333 |   1.816667 | 0.016666 |
       3 |  14 |    B |   1.883333 |   1.833333 | 0.050000 |
       3 |  15 |    B |   1.866667 |   1.850000 | 0.016667 |
       3 |  16 |    B |   1.900000 |   1.866667 | 0.033333 |
       3 |  17 |    P |   2.033333 |   1.883333 | 0.150000 |
       3 |  18 |    B |   1.983333 |   1.900000 | 0.083333 |
       3 |  19 |    B |   1.950000 |   1.916667 | 0.033333 |
       3 |  20 |    P |   1.933333 |   1.933333 | 0.000000 |
       3 |  21 |    B |   1.966667 |   1.950000 | 0.016667 |
       3 |  22 |    B |   2.016667 |   1.966667 | 0.050000 |
       3 |  23 |    B |   2.000000 |   1.983333 | 0.016667 | <-- last pre-IDR frame (24 frames without IDR!)
       3 |  24 |  IDR |   2.050000 |   2.000000 | 0.050000 | <-- IDR KEYFRAME | new GOP starts
       3 |  25 |    P |   2.183333 |   2.016667 | 0.166666 |
       3 |  26 |    B |   2.116667 |   2.033333 | 0.083334 |
       3 |  27 |    B |   2.083333 |   2.050000 | 0.033333 |
       3 |  28 |    P |   2.066667 |   2.066667 | 0.000000 |
       3 |  29 |    B |   2.100000 |   2.083333 | 0.016667 |
       3 |  30 |    B |   2.150000 |   2.100000 | 0.050000 |
       3 |  31 |    B |   2.133333 |   2.116667 | 0.016666 |
       3 |  32 |    B |   2.166667 |   2.133333 | 0.033334 |
       3 |  33 |    P |   2.316667 |   2.150000 | 0.166667 |
       3 |  34 |    B |   2.250000 |   2.166667 | 0.083333 |
       3 |  35 |    B |   2.216667 |   2.183333 | 0.033334 |
       3 |  36 |    P |   2.200000 |   2.200000 | 0.000000 |
       3 |  37 |    B |   2.233333 |   2.216667 | 0.016666 |
       3 |  38 |    B |   2.283333 |   2.233333 | 0.050000 |
       3 |  39 |    B |   2.266667 |   2.250000 | 0.016667 |
       3 |  40 |    B |   2.300000 |   2.266667 | 0.033333 |
       3 |  41 |  IDR |   2.333333 |   2.283333 | 0.050000 | <-- IDR KEYFRAME | new GOP starts
       3 |  42 |    B |   2.400000 |   2.300000 | 0.100000 |
       3 |  43 |    B |   2.366667 |   2.316667 | 0.050000 |
       3 |  44 |    B |   2.350000 |   2.333333 | 0.016667 |
       3 |  45 |    B |   2.383333 |   2.350000 | 0.033333 |
       3 |  46 |    B |   2.466667 |   2.366667 | 0.100000 |
       3 |  47 |    B |   2.433333 |   2.383333 | 0.050000 | <-- Part 3 end
    -----+-----+------+------------+------------+----------+----------------------------------------------

here is the example scenario, the player buffers parts on rendition A, then ABR triggers a switch to rendition B.
The player selects Part 3 on the new rendition (marked INDEPENDENT=YES) in the playlist, appends the new init segment, and loads the part expecting it to produce continuous buffer from its playlist start time (video buffer [58.0–61.633], start time reported from playlist is 61.6). However, the Part 3 contains 24 dependent B/P frames (packets 0–23, PTS 1.633–2.033 relative) before its first IDR keyframe at packet #24 (PTS 2.050 relative). These pre-IDR frames belong to a GOP that started in Part 1 and spans through Part 2, referencing Part 2's P-frames which are not in the buffer since we switched renditions. The SourceBuffer drops those 24 undecidable frames and starts the new buffer range at PTS 62.050 instead of 61.600, creating a ~0.4s gap (61.633→62.050) in the video buffer.

Expected behaviour

playing without freezes and gaps.

What actually happened?

~0.4s freeze and jump over gap via gap-controller.

Console output
n/a
Chrome media internals output
n/a

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.