Skip to content

fix correct hlsSegmentFormat for HLS streams with AAC audio in castable-video - #232

Merged
ronald-urbina merged 1 commit into
muxinc:mainfrom
ronald-urbina:fix/castable-video-aac-chromecast
Apr 29, 2026
Merged

ronald-urbina merged 1 commit into
muxinc:mainfrom
ronald-urbina:fix/castable-video-aac-chromecast

Conversation

@ronald-urbina

@ronald-urbina ronald-urbina commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Chromecast playback stalls silently for HLS streams that have separate audio
renditions using raw ADTS AAC segments (.aac). The LOAD request sent to the
receiver had hlsSegmentFormat: "ts" because format detection only inspected
the video variant playlist then applied that format to the audio field too.

The receiver interprets hlsSegmentFormat as the audio segment format. Telling
it "audio is MPEG-TS" when it receives raw .aac files causes it to hang
indefinitely with no error.

Fixes 224.

Changes

castable-utils.js

  • Add parseAudioRenditionUrl() — finds the first #EXT-X-MEDIA TYPE=AUDIO
    URI in the master playlist
  • getPlaylistSegmentFormat() now separately detects video and audio formats,
    fetching the audio rendition playlist when present
  • Returns { videoFormat, audioFormat } instead of a single string
  • Fix parseSegment() to trim the returned line (handles CRLF line endings)

castable-mixin.js

  • Set hlsSegmentFormat from audioFormat, hlsVideoSegmentFormat from
    videoFormat
  • .aac audio → hlsSegmentFormat = AAC, hlsVideoSegmentFormat = MPEG2_TS
  • TS video/audio → hlsSegmentFormat = TS, hlsVideoSegmentFormat = MPEG2_TS
    (also fixes the latent bug where HlsVideoSegmentFormat.TS was undefined)
  • FMP4 → both remain FMP4

Note

Medium Risk
Changes HLS manifest parsing and Chromecast LoadRequest metadata for segment format selection; mistakes could regress casting playback for some HLS variants despite being scoped to HLS-only logic.

Overview
Fixes Chromecast stalls on HLS streams that use separate AAC audio renditions by detecting audio and video segment formats independently.

getPlaylistSegmentFormat() now returns { videoFormat, audioFormat }, trims parsed segment URLs, and (when present) fetches the #EXT-X-MEDIA TYPE=AUDIO playlist to determine audio segment type. The sender LoadRequest mapping is updated to set hlsSegmentFormat from the audio format (including explicit AAC handling) and hlsVideoSegmentFormat from the video format, using MPEG2_TS for TS video.

Reviewed by Cursor Bugbot for commit 947ef46. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Apr 28, 2026

Copy link
Copy Markdown

@ronald-urbina is attempting to deploy a commit to the Mux Team on Vercel.

A member of the Team first needs to authorize it.

@snyk-io

snyk-io Bot commented Apr 28, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@ronald-urbina
ronald-urbina merged commit 039b0cf into muxinc:main Apr 29, 2026
4 of 6 checks passed
ronald-urbina added a commit to ronald-urbina/media-elements that referenced this pull request Apr 29, 2026
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.

<castable-video> Chromecast fails for HLS with separate audio rendition (TS video + AAC audio)

2 participants