Repository navigation
Declare sidecar subtitles as renditions on the nativeRemoteHLS bypass (#316) - #330
Merged
superuser404notfound merged 2 commits intoAug 7, 2026
Conversation
…LS bypass (#316) The nativeRemoteHLS branch returns from load() well before the probe path registers LoadOptions.externalSubtitles, so a host that declared sidecars at load time got an empty subtitleTracks back: no error, no log line, and no way to tell a dropped declaration from a source that simply has no subtitles. The AE#154 reroute onto the same bypass dropped them too. Both branches now register the declaration themselves, and the AE#154 legible discovery merges instead of assigning: it used to overwrite subtitleTracks wholesale, which would have delisted the sidecars again a beat after they were registered on any source that carries its own renditions. Also lands the pure master rewriter the rendition work needs. Media selection on an HLS asset comes from the playlist and nowhere else, so a sidecar can only become a legible rendition if the engine writes the master. The rewriter absolutises every variant, audio and key URI against the origin, so the media still comes straight from the origin and E-AC-3/Atmos passthrough is untouched; only the master moves. Rendition URIs stay relative so the #86/#227 AirPlay swap to the LAN IP carries them along. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE
…e-HLS bypass (#316) Media selection on an HLS asset comes from the playlist and nowhere else. There is no API that adds an AVMediaSelectionOption to a remote AVURLAsset, so addExternalSubtitleTrack could only ever drive the host overlay, which is not drawn once the picture leaves the host's view hierarchy. PiP, AirPlay and a wired external display lost the subtitle, and for a Plex or Jellyfin transcode told subtitles=none the sidecar is the only copy there is. For a VOD source the engine now writes the master itself: it fetches the origin's, absolutises every variant, audio and key URI against it, adds one EXT-X-MEDIA:TYPE=SUBTITLES per text sidecar (joining the origin's own group when it has one, so a variant's group choice cannot lose them) and serves that from the loopback origin. The media never moves: AVPlayer still fetches all A/V bytes from the origin, which is the property the bypass exists for. Rendition URIs stay relative so the #86/#227 AirPlay swap to the LAN IP carries them. The tracks keep their external ids, and selecting one drives AVMediaSelection instead of the sidecar decode, or the overlay would draw the same cues on top of the ones AVPlayer renders. Live playlists, bitmap sidecars, an unrewritable playlist and an origin slower than the 5 s budget all keep the origin URL and overlay-only subtitles; the load is never failed over this. Measured against Apple's own CMAF master rather than assumed: AVMediaSelectionOption.displayName is NOT the rendition's NAME. AVFoundation derives a localized language name from LANGUAGE and drops NAME entirely, so NAME="DE" reads back as "German" and the origin's "简体中文" as "Chinese". The verbatim attribute survives in commonMetadata under m3u8/NAME, which is what both the selection lookup and the dedupe key on. Keying on displayName matched nothing and published the sidecar twice. Verified on that master end to end: 8 legible renditions surfaced (7 origin + 1 injected, no duplicate), HEVC 1080p playing straight from the CDN, selecting external id 100000 fetches subs_0.m3u8 and subs_0_0.vtt from the loopback. aetherctl gains `play --sidecar <lang>=<path>` so the chain is observable without a device, and the run summary prints the settled track list. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE
superuser404notfound
deleted the
feat/issue-316-remote-hls-external-subtitle-renditions
branch
August 7, 2026 16:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #316. Two things were wrong, and the smaller one was invisible.
The declaration was dropped without a trace
load()routesnativeRemoteHLSintoloadRemoteHLSand returns before the probe path registersLoadOptions.externalSubtitles, so a host that declared sidecars on a remote HLS source got an emptysubtitleTracksback: no error, no log line, nothing to distinguish a dropped option from a source that simply has no subtitles. The AE#154 reroute onto the same bypass dropped them too. And the legible-group discovery would have undone the registration anyway: it assignedsubtitleTrackswholesale rather than merging, so on any source carrying its own renditions the sidecars would have been delisted a beat after they appeared.Both branches now register the declaration, and the discovery merges.
Renditions
The report suggested
AVMutableMediaSelectionGroup. That route does not exist: media selection on an HLS asset comes from the playlist and from nowhere else, and there is no API to add an option to a remoteAVURLAsset. SoaddExternalSubtitleTrackreally is overlay-only by construction, and the only way to a rendition is a master the engine writes.For a VOD source the engine now fetches the origin master, absolutises every variant, audio, I-frame and key URI against it, adds one
EXT-X-MEDIA:TYPE=SUBTITLESper text sidecar, and serves that master from the loopback origin. The media never moves. AVPlayer still fetches every A/V byte straight from the origin, which is exactly the property the bypass exists for, so E-AC-3 / Atmos passthrough is untouched; only the master and the WebVTT renditions are local.Details that turned out to matter:
DEFAULT=NO,AUTOSELECT=NO, noFORCED, the same discipline as the loopback master (fix(native): apply externalMetadata on iOS too #15 / Sodalite#38). Nothing self-engages; the host that declared the sidecar decides when it plays.AVMediaSelectionrather than the sidecar decode. Doing both would draw the same cues twice, and only the rendition survives PiP / AirPlay / an external display.EXT-X-ENDLIST), bitmap sidecars, a playlist that will not rewrite, a server that will not bind and an origin slower than the 5 s budget all keep the origin URL and overlay-only subtitles, with one log line naming the reason. The load is never failed over a subtitle feature.One measurement worth recording
AVMediaSelectionOption.displayNameis not the rendition's NAME. AVFoundation derives a localized language name from LANGUAGE and ignores NAME entirely: against Apple's own CMAF master, an injectedNAME="DE"reads back as"German"and the origin'sNAME="简体中文"as"Chinese". The verbatim attribute does survive, incommonMetadataunder them3u8/NAMEidentifier, and that is what both the selection lookup and the dedupe key on now. The first implementation keyed ondisplayName, matched nothing, and published the sidecar twice.Verification
Full suite 1595/1595, tvOS and iOS Simulator builds green.
End to end against
devstreaming-cdn.apple.com/.../cmaf.m3u8with an.srtsidecar:HEVC 1080p playing from the CDN throughout, no duplicate entry for the sidecar, and the origin's seven renditions keep their group ordinals.
aetherctl play --sidecar <lang>=<path>is new so the whole chain is reproducible without a device, and the run summary now prints the settled track list.