Skip to content

feat: add maxFragmentDuration and bump index version to v3#57

Merged
gkozlenko merged 1 commit intomasterfrom
fragment-list-max-fragment-duration
Feb 16, 2026
Merged

feat: add maxFragmentDuration and bump index version to v3#57
gkozlenko merged 1 commit intomasterfrom
fragment-list-max-fragment-duration

Conversation

@gkozlenko
Copy link
Copy Markdown
Owner

Add maxFragmentDuration() method to FragmentList. This returns the maximum duration among all fragments, which is required for calculating a precise HLS #EXT-X-TARGETDURATION.

BREAKING CHANGE:
The index file format version has been bumped from 2 to 3. The header size has increased from 32 to 40 bytes. Existing index files generated with version 2 are incompatible and must be regenerated.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @gkozlenko, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new capability to determine the maximum duration of individual fragments within a media stream, which is essential for precise HLS manifest generation. This enhancement necessitated a significant update to the internal index file format, leading to a breaking change that requires regeneration of existing index files.

Highlights

  • New Feature: maxFragmentDuration(): A new method, maxFragmentDuration(), has been added to FragmentList to calculate and return the maximum duration among all fragments. This is crucial for accurately determining the HLS #EXT-X-TARGETDURATION.
  • Breaking Change: Index Version Bump: The index file format version has been upgraded from 2 to 3. This change increases the header size from 32 to 40 bytes, making existing index files generated with version 2 incompatible. Users must regenerate their index files.
  • Index File Structure Update: The index file now stores the maximum fragment duration within its header, requiring updates to both the indexer and the indexed fragment list reader.
Changelog
  • README.md
    • Added documentation for the new maxFragmentDuration() method under the FragmentList section.
  • lib/fragment-list.js
    • Implemented the maxFragmentDuration() method, which iterates through all fragments to find and return the maximum duration, adjusted by the timescale.
  • lib/index/fragment-list-indexer.js
    • Introduced variables to track the position and value of the maximum fragment duration during index creation.
    • Allocated an additional 8 bytes in the index header for storing the maximum fragment duration.
    • Calculated the maxFragmentDuration while iterating through fragments for indexing.
    • Wrote the calculated maxFragmentDuration into the designated placeholder in the index buffer.
  • lib/index/indexed-fragment-list.js
    • Updated the header parsing logic to read the new _maxFragmentDuration (8 bytes) from the index buffer.
    • Applied timescale conversion to the read _maxFragmentDuration.
    • Added a maxFragmentDuration() getter method to expose the stored maximum fragment duration.
  • lib/index/utils.js
    • Updated the INDEX_VERSION constant from 2 to 3.
    • Increased the HEADER_SIZE constant from 32 to 40 bytes to accommodate the new field.
  • test/fragment-list.js
    • Added a new test suite for maxFragmentDuration() to ensure it correctly identifies the maximum fragment duration.
  • test/indexer.js
    • Updated the expected index version assertion in tests from 2 to 3.
    • Added an assertion to verify that the maxFragmentDuration read from an indexed file matches the original fragment list's value.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 16, 2026

Test Coverage Summary Statistics

  • Lines: 94.66%
  • Statements: 94.7%
  • Functions: 92.61%
  • Branches: 78.4%

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a maxFragmentDuration() method to FragmentList and updates the index file format to version 3 to include this information. The changes are well-implemented and include corresponding updates to documentation and tests. I have a couple of minor suggestions to improve code clarity and conciseness.

Add `maxFragmentDuration()` method to `FragmentList`. This returns
the maximum duration among all fragments, which is required for
calculating a precise HLS `#EXT-X-TARGETDURATION`.

BREAKING CHANGE:
The index file format version has been bumped from 2 to 3. The header
size has increased from 32 to 40 bytes. Existing index files generated
with version 2 are incompatible and must be regenerated.
@gkozlenko gkozlenko force-pushed the fragment-list-max-fragment-duration branch from 01fd408 to 5726a5e Compare February 16, 2026 19:25
@gkozlenko
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a maxFragmentDuration() method to FragmentList and updates the index file format to include this information. The changes are well-implemented, including updates to documentation and tests. The index version bump for the breaking change is handled correctly. I have one suggestion regarding code duplication to improve maintainability.

@gkozlenko gkozlenko merged commit 2068fe5 into master Feb 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant