video-dev / video-dev/hls.js

Irregular fmp4 fragment durations with "progressive" setting

Open
#6,764 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

What do you want to do with Hls.js?

Hi, given a HLS VOD with fragmented mp4s (6s fragments, 2s chunks) using byterange requests, I'm wondering why the loaded fragments are of different durations when using the fetch-loader vs xhr-loader.

Given this stream: https://hlsjs.video-dev.org/demo/?src=https%3A%2F%2Fd3bao5x7qmqzgm.cloudfront.net%2Fchunked%2Fmaster.m3u8&demoConfig=eyJlbmFibGVTdHJlYW1pbmciOnRydWUsImF1dG9SZWNvdmVyRXJyb3IiOnRydWUsInN0b3BPblN0YWxsIjpmYWxzZSwiZHVtcGZNUDQiOmZhbHNlLCJsZXZlbENhcHBpbmciOi0xLCJsaW1pdE1ldHJpY3MiOi0xfQ==

Example with xhr-loader showing consistent ~6s fragments for audio and video in the Timeline:

{
  "debug": true,
  "enableWorker": true,
  "backBufferLength": 90,
  "progressive": false
}
Screenshot 2024-10-09 at 9 36 24 PM

Example with fetch-loader showing fragments of varying durations in the Timeline:

{
  "debug": true,
  "enableWorker": true,
  "backBufferLength": 90,
  "progressive": true
}
Screenshot 2024-10-09 at 9 37 28 PM

The reason I am interested in using fetch-loader is to reduce startup time by allowing playback as soon as a chunk is downloaded rather than a full fragment. Is there a less experimental way to achieve this that you recommend?

Thank you

What have you tried so far?
  • Different chunk durations (500ms, 1s, 2s)
  • A custom fetch-loader, but the magic comes from more than just using fetch it is actually appending the chunks as they come which I have not re-implemented

I wanted to try next:

  • fmp4 fragments of equal length as the chunk (6s fragments, 6s chunk with single moof+mdat)

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.

Research direction

Reproduce the stream in the linked Hls.js demo with progressive set to false and true, then compare the fetch-loader and xhr-loader paths and their timeline durations. Start with the loader behavior described in the issue; done means determining whether the varying fMP4 durations are expected or identifying a focused fix or recommendation for chunked playback.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.