Skip to content

Conversation

@sebastianpiq
Copy link

@sebastianpiq sebastianpiq commented Oct 7, 2025

L3D-DASH Support

This pull request introduces the support for Low-Latency & Low-Delay DASH (L3D)

Functionality Overview

The L3D implementation generates individual chunks from full segments, enabling progressive media delivery. The system uses writeSubSegment to handle chunk requests and prepareChunks to divide segments into smaller temporal units. Chunk duration can be configured explicitly via URL parameters.

Main Changes

  1. MPD Generation Enhancements (when Low Delay/SSR is enabled)
    Added DASHProfileLinear profile for SSR streaming compliance
    Implemented EssentialProperty with urn:mpeg:dash:ssr:2023 schema reference
    Implemented SupplementalProperty with urn:mpeg:dash:adaptation-set-switching:2016
    Set startWithSAP=1 for proper stream initialization
    Added SegmentSequenceProperties with sapType=1 and cadence=1 to enable playback initialization on any chunk
    Implemented SubNumber on media Segment Template
  2. Segment Timeline Improvements
    Introduced calculateK function to compute S@k value for proper segment indexing
    Enhanced sub-segment chunking support for low-latency & low-delay delivery
  3. URL Configuration System
    Created SSR UI section in the URL generator for easy configuration
    Added ssrAS and chunkDurSSR URL parameter for enabling Low Delay mode for both video and audio adaptation sets.
    Updated URL generation logic to properly handle low-delay streaming parameters
  4. MPD Generation Enhancements (when Low Delay and Low Latency is enabled)
    Implemented EssentialProperty with urn:mpeg:dash:ssr:2023 schema reference
    Implemented SupplementalProperty with urn:mpeg:dash:adaptation-set-switching:2016
    Set startWithSAP=1 for proper stream initialization
    Implemented SubNumber on media Segment Template
    Compute S@k
  5. Library and Dependency Updates
    Updated dash-mpd library to v0.13.0 for improved MPD parsing and generation capabilities
    Adapted to new S type struct from the updated dash-mpd library

How to generate a Low Delay URL

  1. Select the testpic_2s_low_delay asset
  2. Navigate to the SSR section
  3. Set the SSR configuration using the following format: adaptationSetId,ssrValue;adaptationSetId,ssrValue;... where ssrValue is the value of ssr EssentialProperty (supports both video and audio adaptation set)
  4. Set the chunk duration for the low delay using the following format: adaptationSetId,chunkDuration;adaptationSetId,chunkDuration;... (supports both video and audio adaptation set)

How to generate a L3D (Low Delay & Low Latency) URL

  1. Select the testpic_2s_low_delay asset
  2. Navigate to the Low latency section
  3. Set chunk duration for low-latency
  4. Navigate to the SSR section
  5. Set the SSR configuration using the following format: adaptationSetId,ssrValue;adaptationSetId,ssrValue;... where ssrValue is the value of ssr EssentialProperty (supports both video and audio adaptation set)
  6. Set the chunk duration for low delay using the following format: adaptationSetId,chunkDuration;adaptationSetId,chunkDuration;... (supports both video and audio adaptation set)

Supported Use Cases

  • Basic Low Delay to Low Latency Video Content Switching: Start with low delay content and fall back to low-latency content.

Configuration example:
SSR Configuration: 1,0
Switching Logic:
AS1: SSR value="0" → Next reproduction is AS0
AS0: No SSR → Final low-latency regular content

  • Progressive Low Delay Video Degradation Chain: Start with the most aggressive low delay setting, progressing through intermediate low-delay configuration, and finally falling back to low-latency content.

Configuration example:
SSR Configuration: 2,1;1,0
chunk duration for low delay: 2,0.2;1,0.5
Switching Logic:
AS2: SSR value="1" → Next reproduction is AS1
AS1: SSR value="0" → Next reproduction is AS0
AS0: No SSR → Final low-latency regular content

  • Basic Low Delay to Low Latency Audio Content Switching: Start with low delay video and audio content and fall back to low-latency video and audio content.

Configuration example:
SSR Configuration: `3,2;1,0
Switching Logic:
**AS1 (video) **: SSR value="0" → Next reproduction is AS0 (video)
AS0 (video): No SSR → Final low-latency regular content
**AS3 (audio) **: SSR value="2" → Next reproduction is AS2 (audio)
AS2 (audio): No SSR → Final low-latency regular content

  • Switching from low delay to regular renditions (non low latency) should work with the current logic, but haven't been tested since it is out of this PR scope

Wiki Update Suggestion

1. Preparing Content for L3D Assets

Target Wiki Page: Preparing Content for livesim2

Suggested Addition: L3D Content Requirements

Add a new section covering content preparation for L3D streaming:

L3D Content Preparation

For L3D to work, content should be encoded with the following considerations:

Video Encoding Parameters: GOP size must be aligned with the chunk duration in frames (e.g. if your video has a GOP size of 6 frames and a frame rate of 30fps, the GOP duration is 6 / 30 = 0.2 seconds. The chunk duration should be a multiple of this value (e.g., 0.2, 0.4))

FFmpeg sample

ffmpeg
-f lavfi -i smptebars=size=1920x1080:rate=30:duration=8
-vf "drawtext=text='1920x1080@30fps':x=(w-text_w)/2:y=80*(h/1080):fontsize=72*(h/1080):fontcolor=white:box=1:[email protected]:boxborderw=18,
drawtext=timecode='00:00:00:00':rate=30:x=(w-tw)/2:y=280*(h/1080):fontsize=144*(h/1080):fontcolor=white:box=1:[email protected]:boxborderw=30,
drawtext=text='2000 kbit/s - Low Delay':x=(w-text_w)/2:y=480*(h/1080):fontsize=72*(h/1080):fontcolor=white:box=1:[email protected]:boxborderw=18"
-c:v libx264 -g 6 -r 30 -keyint_min 6 -sc_threshold 0 -force_key_frames "expr:gte(t,n_forced*0.2)" -b:v 2M
-y low_delay_1080p.mp4

gpac example

gpac -r
-i sources/low_delay_1080p.mp4:#ASID=1
-i sources/audio.mp4:#ASID=2
-o out/Manifest.mpd:template='r$RepresentationID$_seg$Number$':timescale=1000:segdur=2:dmode=static:profile=live

2. New URL Parameters

Target Wiki Page: URL Parameters

Suggested Addition: Low Delay Parameters

Add documentation for the new Low Delay URL parameter:

Low Delay Parameters

Parameter Description Example
ssrAS Enables Low Delay (SSR) mode on the specified adaptation sets. The following format is required: adaptationSetId,ssrValue;adaptationSetId,ssrValue;... where ssrValue is the next adaptation set id /livesim2/ssras_{adaptationSetId, ssrValue}/testpic_2s_low_delay/Manifest.mpd

Low Delay Mode Effects: When ssrAS is specified in the URL path, the following modifications are applied to the generated MPD:

  • Profile: Set to DASHProfileLinear for L3D compliance
  • Essential Property: Includes urn:mpeg:dash:ssr:2023 specification
  • SupplementalProperty: Includes urn:mpeg:dash:adaptation-set-switching:2016 specification
  • SAP Configuration: AdaptationSet@startWithSAP=1 for proper stream access points
  • SegmentSequenceProperties element is included in the low-delay AdaptationSet with the sapType=1 and cadence=1 attributes

Usage Pattern:
/livesim2/[other-params]/ssras_{adaptationSetId, ssrValue}/[asset-name]/Manifest.mpd

Compatibility Notes:

  • Low Delay requires Low Delay Chunk Duration URL Parameter
  • Low Delay mode works in combination with Low Latency URL parameters
  • Low Delay mode works in combination with other URL parameters
  • Requires properly encoded content with an appropriate GOP structure

Suggested Addition: Low Delay Chunk Duration Parameters

Add documentation for the new Low Delay Chunk Duration URL parameter:

Low Delay Chunk Duration Parameters

Parameter Description Example
chunkDurSSR Enables sub segment generation on the specified adaptation sets using the specified chunk duration. The following format is required: adaptationSetId,chunkDur;adaptationSetId,chunkDur;... where chunkDur /livesim2/chunkdurssr_{adaptationSetId, chunkDur}/testpic_2s_low_delay/Manifest.mpd

Low Delay Chunk Duration Mode Effects: When chunkDurSSR is specified in the URL path, the following modifications are applied to the generated MPD:

  • Sub-segment Generation: Enhanced timeline generation with chunk duration support

Usage Pattern:
/livesim2/[other-params]/chunkdurssr_{adaptationSetId, chunkDur}/[asset-name]/Manifest.mpd

Compatibility Notes:

  • Low Delay Chunk Duration requires Low Delay URL Parameter ssrAS
  • Low Delay mode works in combination with other URL parameters
  • Requires properly encoded content with an appropriate GOP structure

cotid-qualabs and others added 2 commits October 7, 2025 14:00
Squash merge l3d-dash (#12)

* Add low delay config to urlgen

* Fix low delay config in urlgen and read it on livempd

* mpd profile DASHProfileLinear

* add SchemeIdUriSSR to essential property on representations

* Set Role as main in main Adaptation Set

* cleanup for fresh start

* update LowDelay flag to take value from url instead of query parameter

* add essential property, role and startWithSAP at Adaptation Set level

* PartialSegments configuracion added to ResponseConfig and urlgen form

* Revert "PartialSegments configuracion added to ResponseConfig and urlgen form"

This reverts commit 491b159.

* add SubNumber for Low Delay to SegmentTimeline with $Number$

* rename LowDelayFlag

* l3d-dash/S@k (#3)

* Add chunkDuration parameter to generateTimelineEntries and related functions, calculating s@k and adding it to mpd
* Add simple Unit Tests for Calculate K function
* Add unit test for generateTimelineEntries with chunkDuration cases
* Moved Low Delay Checkbox to Low Latency section
* Update code to only send `s@K` if Low Latency flag is on

* Add LowDelay support and refactor related configurations

* l3d-dash/calc_subsegment_part_unit_tests (#5)

* Enhance calcSubSegementPart function to handle errors and add comprehensive unit tests

* Refactor segment handling: split writeChunkedSegment into prepareChunks and setHeaders for improved readability and error handling

* Add TestWriteSubSegment for validating sub-segment handling and error cases

* Refactor TestWriteSubSegment: remove unused mediaTimescale and cancelContext fields for clarity

* Update cmd/livesim2/app/livesegment_test.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Refactor TestWriteSubSegment: add availabilityTimeOffsetS to test cases for improved accuracy

* Fix wrong chunk index generation

* Implement SegmentSequenceProperties for l3d

* Undo SegmentSequenceProperties implementation

* Implement single chunk generation in the sub segments

* Remove unused lowDelay config

* Remove unnecessary sleep on writing sub segemnts

* Add l3d testdata

* Fix writeSubSegment debug messages

* Fix wrong asset naming

* Update l3d dash to no-cmaf

* Fix return segements without a sub segment

* Add audio to de l3d-dash sample and fix template generation

* Fix unit test

* Update Low Delay sample

* Add SubNumber to $Time$ with SegmentTimeline

* feat: update dash-mpd to v0.13.0 and improve Makefile

* fix: use new S type struct from dash-mpd

* feat: add L3D to Number wo timeline

* fix: failing tests with K

* feat: Add SegmentSequenceProperties element

* fix: availabilityTimeOffset not defined issue

* fix: lint errors

* fix: lint errors

* remove unnecessary withe spaces

* refactor: rename chunk duration parameters for clarity

* refactor: update comments related with low-delay for clarity

* refactor: rename chunk duration in seconds variable for clarity

* refactor: rename DASH profile constant for consistency and update usage in LiveMPD function

* fix: remove duration attribute from Period element for clarity

* refactor: Add chunkIndex explanation comment in the chunkSegment generation

* rafactor: Update ssr schme uri constant naming aligment

* rafactor: update writeSubSegment comments for clarity

* rafactor: remove harcoded role for low delay assets

* refactor: rename low delay mode to SSR and update related configurations

* refactor ssr essential property

* switching implementation

* remove cfg EnableSSR from handler livesim

* fix

* test fix

* fix

* add lowdelay chunk duration config

* parse low dealy chunk duration

* add unit test cases

* add chunk duration for low delay

* bugfix

* bugfix - representation id regex update when the id string is a substring of other representation id

* update assets for low delay and regular renditions

* update assets for low delay and regular renditions

* refactor low delay flag and implement k for low latency

* code refactor

* code refactor

* remove unused parameter

* add comment

* condition refactor

* refactor segment template for low delay and added low latency  cadence

* fix linter issues

* ssr html name update

* remove segment sequence properties from low delay low latency

* remove cadence from low latency and add ssr

* low latency start with sap

* low delay audio

* rename low delay adaptation set to ssrAS

* rename low delay chunk duration to chunk dur ssr

* Fixed validation to ensure adaptationSetId is a non-negative integer

* Adding ProfileAdvancedLinear only if it is not already included

* Fix typo

* Error handling for pairs different than 2

* Error handling for extra spaces on configuration

* Error handling chunk duration greater than segment duration

* Error handling for empty and invalid configurations

* Fix chunking fallback

* AvailabilityTimeOffset left as default and ignored for SSR

* Remove availabilityTimeOffset from write sub segment test

* remove space

* fix chunkdurssr cant be used on its own

* Fix chunking fallback

* fix chunkdurssr cant be used on its own

* AvailabilityTimeOffset left as default and ignored for SSR

* remove space

* error handling for ssras not configured when using chunkdurssr

* unit test fix

* fixes after main merge

* revert anchor regex for matching representations

---------

Co-authored-by: Juan Manuel Gonzalez <[email protected]>
Co-authored-by: Sebastian Piquerez <[email protected]>
Co-authored-by: Juan Manuel Gonzalez <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Sebastian Piquerez <[email protected]>
Co-authored-by: Emil Santurio <[email protected]>
Co-authored-by: Torbjörn Einarsson <[email protected]>
Thumbnails cannot be chunked like MP4 segments and were failing in
low-latency streams.
@tobbee
Copy link
Contributor

tobbee commented Oct 23, 2025

Sorry for the long time to respond. Thanks for the PR.
Have you checked this towards any player like dash.js, which is developing this feature as well.

I haven't looked at the code yet, but regarding the documentation, I think it would benefit by a description that L3D is a solution using multiple tools and explain what these tools are. For example, SSR is used in many places, but the SSR abbreviation is not explained.

I plan to look more into this when I'm back from Demuxed.

cotid-qualabs and others added 4 commits November 6, 2025 12:03
* fix k calculation for no timeline

* Update cmd/livesim2/app/livempd.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

---------

Co-authored-by: ¨Constanza <¨[email protected]¨>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Squash merge l3d-dash (#12)

* Add low delay config to urlgen

* Fix low delay config in urlgen and read it on livempd

* mpd profile DASHProfileLinear

* add SchemeIdUriSSR to essential property on representations

* Set Role as main in main Adaptation Set

* cleanup for fresh start

* update LowDelay flag to take value from url instead of query parameter

* add essential property, role and startWithSAP at Adaptation Set level

* PartialSegments configuracion added to ResponseConfig and urlgen form

* Revert "PartialSegments configuracion added to ResponseConfig and urlgen form"

This reverts commit 491b159.

* add SubNumber for Low Delay to SegmentTimeline with $Number$

* rename LowDelayFlag

* l3d-dash/S@k (#3)

* Add chunkDuration parameter to generateTimelineEntries and related functions, calculating s@k and adding it to mpd
* Add simple Unit Tests for Calculate K function
* Add unit test for generateTimelineEntries with chunkDuration cases
* Moved Low Delay Checkbox to Low Latency section
* Update code to only send `s@K` if Low Latency flag is on

* Add LowDelay support and refactor related configurations

* l3d-dash/calc_subsegment_part_unit_tests (#5)

* Enhance calcSubSegementPart function to handle errors and add comprehensive unit tests

* Refactor segment handling: split writeChunkedSegment into prepareChunks and setHeaders for improved readability and error handling

* Add TestWriteSubSegment for validating sub-segment handling and error cases

* Refactor TestWriteSubSegment: remove unused mediaTimescale and cancelContext fields for clarity

* Update cmd/livesim2/app/livesegment_test.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Refactor TestWriteSubSegment: add availabilityTimeOffsetS to test cases for improved accuracy

* Fix wrong chunk index generation

* Implement SegmentSequenceProperties for l3d

* Undo SegmentSequenceProperties implementation

* Implement single chunk generation in the sub segments

* Remove unused lowDelay config

* Remove unnecessary sleep on writing sub segemnts

* Add l3d testdata

* Fix writeSubSegment debug messages

* Fix wrong asset naming

* Update l3d dash to no-cmaf

* Fix return segements without a sub segment

* Add audio to de l3d-dash sample and fix template generation

* Fix unit test

* Update Low Delay sample

* Add SubNumber to $Time$ with SegmentTimeline

* feat: update dash-mpd to v0.13.0 and improve Makefile

* fix: use new S type struct from dash-mpd

* feat: add L3D to Number wo timeline

* fix: failing tests with K

* feat: Add SegmentSequenceProperties element

* fix: availabilityTimeOffset not defined issue

* fix: lint errors

* fix: lint errors

* remove unnecessary withe spaces

* refactor: rename chunk duration parameters for clarity

* refactor: update comments related with low-delay for clarity

* refactor: rename chunk duration in seconds variable for clarity

* refactor: rename DASH profile constant for consistency and update usage in LiveMPD function

* fix: remove duration attribute from Period element for clarity

* refactor: Add chunkIndex explanation comment in the chunkSegment generation

* rafactor: Update ssr schme uri constant naming aligment

* rafactor: update writeSubSegment comments for clarity

* rafactor: remove harcoded role for low delay assets

* refactor: rename low delay mode to SSR and update related configurations

* refactor ssr essential property

* switching implementation

* remove cfg EnableSSR from handler livesim

* fix

* test fix

* fix

* add lowdelay chunk duration config

* parse low dealy chunk duration

* add unit test cases

* add chunk duration for low delay

* bugfix

* bugfix - representation id regex update when the id string is a substring of other representation id

* update assets for low delay and regular renditions

* update assets for low delay and regular renditions

* refactor low delay flag and implement k for low latency

* code refactor

* code refactor

* remove unused parameter

* add comment

* condition refactor

* refactor segment template for low delay and added low latency  cadence

* fix linter issues

* ssr html name update

* remove segment sequence properties from low delay low latency

* remove cadence from low latency and add ssr

* low latency start with sap

* low delay audio

* rename low delay adaptation set to ssrAS

* rename low delay chunk duration to chunk dur ssr

* Fixed validation to ensure adaptationSetId is a non-negative integer

* Adding ProfileAdvancedLinear only if it is not already included

* Fix typo

* Error handling for pairs different than 2

* Error handling for extra spaces on configuration

* Error handling chunk duration greater than segment duration

* Error handling for empty and invalid configurations

* Fix chunking fallback

* AvailabilityTimeOffset left as default and ignored for SSR

* Remove availabilityTimeOffset from write sub segment test

* remove space

* fix chunkdurssr cant be used on its own

* Fix chunking fallback

* fix chunkdurssr cant be used on its own

* AvailabilityTimeOffset left as default and ignored for SSR

* remove space

* error handling for ssras not configured when using chunkdurssr

* unit test fix

* fixes after main merge

* revert anchor regex for matching representations

---------

Co-authored-by: Juan Manuel Gonzalez <[email protected]>
Co-authored-by: Sebastian Piquerez <[email protected]>
Co-authored-by: Juan Manuel Gonzalez <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Sebastian Piquerez <[email protected]>
Co-authored-by: Emil Santurio <[email protected]>
Co-authored-by: Torbjörn Einarsson <[email protected]>
* fix k calculation for no timeline

* Update cmd/livesim2/app/livempd.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

---------

Co-authored-by: ¨Constanza <¨[email protected]¨>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@tobbee
Copy link
Contributor

tobbee commented Nov 7, 2025

There is now a dash.js Release candidate: https://github.com/Dash-Industry-Forum/dash.js/tree/RC_v5.1.0
that includes l3d support. Have you tested against it?

@tobbee
Copy link
Contributor

tobbee commented Nov 7, 2025

There was some merge in this PR yesterday, so the git history looks quite strange, see this screenshot from SourceTree
Screenshot 2025-11-07 at 14 47 57

Please fix and force-push a straight line of commits based on "main", and without any loops/merges.

@tobbee
Copy link
Contributor

tobbee commented Nov 25, 2025

@cotid-qualabs @sebastianpiq Any update on this?

Would be great if you can update with the playback status with dash.js and other players.

A rebase om the main branch with a linear git commit history for this PR would also be nice before approving and merging this PR.

I think there may be some collisions with PR #272 on Pattern, but I can wait a bit more with that one.

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.

4 participants