You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optionally emit the active subtitle as a native HLS subtitle rendition (#EXT-X-MEDIA:TYPE=SUBTITLES → WebVTT, served by HLSLocalServer from the already-decoded cues) and expose it through the legible AVMediaSelectionGroup, so AVPlayer renders the subtitle itself. That is the only way subtitles can survive Picture-in-Picture, AirPlay, and external-display playback, where a host-drawn overlay never appears.
Motivating media or use case
Scenario: a tvOS/iOS client playing any title with an embedded or sidecar text subtitle (e.g. an MKV with an embedded ASS dialogue track, or a .srt/.vtt sidecar) where the user turns on Picture-in-Picture, AirPlay, or connects an external display.
Today: subtitles are surfaced to the host as decoded cues ($subtitleCues + the preserveASSMarkup/assHeader host-render contract from #30/#48) and the host paints them with swift-ass renderer. That works inline, but the overlay is a sibling layer outside the AVPlayerItem's video output, so subtitles disappear the moment playback moves to PiP / AirPlay / external display.
Why a host can't fix this itself (so this has to live in the engine):
A host overlay view (or AVPlayerViewController.contentOverlayView) is not shown in PiP by AVKit,
and isn't sent over AirPlay / to an external display.
The AssVideoComposition CoreImage videoComposition route can't be used either — CIFilter video
compositions are unsupported on HLS assets, and the engine plays the loopback media.m3u8 / master.m3u8. So there is no host-side path to get rendered subtitles into the frames AVPlayer emits.
The only thing the OS renders in PiP/AirPlay is what lives inside the AVPlayerItem — i.e. a native
legible selection. This also lines up with the AVMediaSelection wiring is a tracked follow-up note in AetherEngine.subtitleCues's doc comment; VideoSegmentProvider.masterClosedCaptions is currently "NONE" and there's no EXT-X-MEDIA:TYPE=SUBTITLES rendition.
Thanks for the detailed writeup. The diagnosis is exactly right: a host-drawn overlay lives outside the AVPlayerItem, so PiP / AirPlay / external display only ever show what is inside the item, which means a native legible selection. We want this, and it has to live in the engine.
We prototyped the WebVTT-rendition path you outlined (EXT-X-MEDIA:TYPE=SUBTITLES plus a /subs.m3u8 of WebVTT segments served from the decoded cues, exposed through the legible group) and hit a structural tension with how the engine routes playback. Sharing the reasoning, because it points at a cleaner option.
Why the WebVTT rendition is awkward for this engine specifically
A WebVTT rendition only exists in a multivariant (master) playlist. EXT-X-MEDIA cannot live in a media playlist. But the loopback server serves the media playlist directly (no master) for a large, deliberate set of cases.
That media-direct routing is not incidental, it protects SDR/HDR/DV playback. A master that advertises VIDEO-RANGE=PQ against an SDR-locked panel gets rejected by AVPlayer (CoreMediaErrorDomain -11848 / -11868), so the engine deliberately bypasses the master on SDR and non-DV-ready panels (and on Dolby Vision Profile 5). Forcing a master back onto those paths just to carry a subtitle rendition re-enters exactly the picture-routing logic we worked hard to stabilize.
AVPlayer fixes its media selection groups at asset load. The subtitle's presence therefore has to be declared before the user ever turns subtitles on, which means routing the master from the start for essentially every subtitled title, broadening the master path well past where it is needed today.
Dolby Vision Profile 5 cannot be wrapped in a master at all: its CODECS is dvh1.05 with no non-DV fallback, and AVPlayer's master-level codec filter drops it on a non-DV panel (it fetches the master repeatedly and never advances to the media playlist). So a WebVTT rendition is structurally impossible for native P5 on a non-DV display, the picture would not even start.
Why tx3g (mov_text) muxed into the fMP4 looks like the better fit
Instead of a separate rendition, declare a text track (tx3g / mov_text) as a third trak inside the existing fragmented-MP4 media stream the engine already produces, alongside video and audio.
It rides the media.m3u8 path that is already served, so it needs no master. That sidesteps the entire SDR/HDR/DV routing question: which playlist AVPlayer loads and what video signaling it sees are byte-identical to today. The subtitle is just another track in the same fMP4.
It works uniformly across SDR / HDR10 / HLG / Dolby Vision, including P5, because it never depends on master-level variant selection.
AVPlayer still surfaces it as a legible AVMediaSelectionOption, so PiP / AirPlay / external display render it natively, which is the whole goal.
The "declare at load" constraint still applies (the text trak has to be in the init moov), but that is a self-contained change in the MP4 segment muxer, not a change to playback routing.
The cost is real muxer work (the segment muxer currently writes video plus optional audio; this adds an empty tx3g trak to the init moov and appends mov_text samples as cues are decoded), but it is isolated and stays out of the sensitive routing code.
Both tx3g and WebVTT are plain-text only natively, so rich ASS styling would keep being host-rendered inline for the non-PiP case in either approach. Bitmap subtitles (PGS/DVB) cannot become a native text track either way and stay host-only (or would need burn-in, which is out of scope here).
Before we commit: is there a constraint on your side that specifically needs the WebVTT rendition (a client that already consumes EXT-X-MEDIA subtitle groups, tooling, and so on), or would the tx3g-in-fMP4 route work for your use case? Given how it interacts with the SDR/HDR/DV routing, tx3g is our lean, but we would rather hear your take before building.
Thanks, this lines up with where we landed. We went with tx3g/mov_text muxed into the existing fMP4 stream (no master, so the SDR/HDR/DV routing is untouched), and yes, the engine uses libavformat's mov_text path.
Your duplicate-menu point is exactly why it is strictly opt-in. The native track is only declared when the host sets a prepareNativeSubtitles load option; with it off the muxer output is byte-identical to today and AVPlayerViewController shows no subtitle menu. So a host that draws its own subtitles either leaves it off, or turns it on and suppresses the stock legible menu in its own player UI. The engine never forces the track on. The track is also declared disposition:default=0 / defaultOption == nil, so even when present it is not auto-displayed: the host selects it explicitly (we expose setNativeSubtitleSelected(_:)), which is what makes it appear in PiP/AirPlay/external while inline stays host-rendered.
On the two tiers: v1 is the "simple text" one, a single active text track (embedded or sidecar) carried as plain mov_text, with rich ASS still host-rendered inline. "Flatten ASS styling into the track" and "carry all text tracks, not just the active one" are both sensible follow-ups (mov_text can hold basic style boxes), but we are keeping v1 plain and opt-in to avoid the duplicate-menu and styling-mismatch surprises. Worth noting both are plain-text only natively, so a flattened-ASS track in PiP would still differ from the inline swift-ass render.
(Separately, AirPlay on AetherPlayer for Mac is a good shout, that belongs in the AetherPlayer repo.)
Agreed, and that is the next round. To enumerate languages in the stock AVPlayerViewController menu, every text track has to be present as its own tx3g trak with a language tag, plus a track-selection API so the host (or the user, via the native menu) can pick one.
v1 just landed on main: the single active text track muxed as tx3g, so the currently selected subtitle survives PiP / AirPlay / external display. We kept v1 to one track to ship the core win and keep the opt-in surface minimal. The follow-up carries all text tracks (embedded + sidecar) with language metadata so the native menu lists them, which is exactly your point. A single side-demuxer pass can decode every text stream into per-track stores, so it stays one extra read pass, not N.
Status update (device-tested 2026-06-29, iOS 26.5.1)
The engine side of this is built and works: a real WebVTT SUBTITLES rendition is served over the loopback (master + subs_N.m3u8 + per-segment subs_N_M.vtt), gated behind LoadOptions.prepareNativeSubtitles, on branch feat/pip-subs-dual-renderer-probe. Device-confirmed: a subtitle does render inside the iOS PiP window, so the serving pipeline is correct.
The blocker is not engine-side. It is AVKit on the host: AVPlayerViewController's AVSmartSubtitlesController reconciles away a programmatically-selected legible track (only a select(nil) -> hop -> select(option) re-assert attaches the renderer at all; criteria and DEFAULT=YES render nothing), and it disables the selection after about 2 seconds. So the rendition is reliable to serve but not reliable to display via our custom-transport AVPlayerViewController.
Tracking the host/AVKit reliability question (where the actual help is needed) in superuser404notfound/Sodalite#32. Engine machinery stays on the branch, gated and inert on main, until that is resolved.
The final shape is the WebVTT rendition this issue originally proposed, not the tx3g detour discussed above: in-band timed text turned out to be non-conformant for HLS (AVPlayer rejected the stream with -11829/-12848), so every text subtitle track is now served as a language-tagged EXT-X-MEDIA:TYPE=SUBTITLES rendition over the loopback master (windowed per-video-segment WebVTT), exposed through the standard legible AVMediaSelection group.
Two engine problems had to fall to make it reliable:
Producer restarts now continue the fMP4 media timeline instead of zero-basing it. A restart used to detach AVKit's legible renderer, which was the "renders once, dies after a seek" wall from the linked Sodalite investigation.
Subtitle cues are harvested from the producer's existing read instead of a side demuxer, so they are available instantly at zero extra bandwidth, even on remote sources.
Renditions ship DEFAULT=NO,AUTOSELECT=NO so a host overlay never double-renders; selection is host-driven via setNativeSubtitleSelected(track:) (with an automatic re-assert when AVFoundation drops a selection during a stall recovery). Details in docs/formats.md. Device-verified on iOS 26.5.1: rendering in PiP, surviving seeks in both directions.
Thanks @edde746 for the original proposal and @DrHurt for the static-VOD reference test that isolated the root cause.
Activity
superuser404notfound commentedon Jun 22, 2026
Thanks for the detailed writeup. The diagnosis is exactly right: a host-drawn overlay lives outside the
AVPlayerItem, so PiP / AirPlay / external display only ever show what is inside the item, which means a native legible selection. We want this, and it has to live in the engine.We prototyped the WebVTT-rendition path you outlined (
EXT-X-MEDIA:TYPE=SUBTITLESplus a/subs.m3u8of WebVTT segments served from the decoded cues, exposed through the legible group) and hit a structural tension with how the engine routes playback. Sharing the reasoning, because it points at a cleaner option.Why the WebVTT rendition is awkward for this engine specifically
A WebVTT rendition only exists in a multivariant (master) playlist.
EXT-X-MEDIAcannot live in a media playlist. But the loopback server serves the media playlist directly (no master) for a large, deliberate set of cases.That media-direct routing is not incidental, it protects SDR/HDR/DV playback. A master that advertises
VIDEO-RANGE=PQagainst an SDR-locked panel gets rejected by AVPlayer (CoreMediaErrorDomain -11848 / -11868), so the engine deliberately bypasses the master on SDR and non-DV-ready panels (and on Dolby Vision Profile 5). Forcing a master back onto those paths just to carry a subtitle rendition re-enters exactly the picture-routing logic we worked hard to stabilize.AVPlayer fixes its media selection groups at asset load. The subtitle's presence therefore has to be declared before the user ever turns subtitles on, which means routing the master from the start for essentially every subtitled title, broadening the master path well past where it is needed today.
Dolby Vision Profile 5 cannot be wrapped in a master at all: its
CODECSisdvh1.05with no non-DV fallback, and AVPlayer's master-level codec filter drops it on a non-DV panel (it fetches the master repeatedly and never advances to the media playlist). So a WebVTT rendition is structurally impossible for native P5 on a non-DV display, the picture would not even start.Why tx3g (mov_text) muxed into the fMP4 looks like the better fit
Instead of a separate rendition, declare a text track (tx3g / mov_text) as a third
trakinside the existing fragmented-MP4 media stream the engine already produces, alongside video and audio.media.m3u8path that is already served, so it needs no master. That sidesteps the entire SDR/HDR/DV routing question: which playlist AVPlayer loads and what video signaling it sees are byte-identical to today. The subtitle is just another track in the same fMP4.AVMediaSelectionOption, so PiP / AirPlay / external display render it natively, which is the whole goal.trakhas to be in the initmoov), but that is a self-contained change in the MP4 segment muxer, not a change to playback routing.The cost is real muxer work (the segment muxer currently writes video plus optional audio; this adds an empty tx3g
trakto the initmoovand appends mov_text samples as cues are decoded), but it is isolated and stays out of the sensitive routing code.Both tx3g and WebVTT are plain-text only natively, so rich ASS styling would keep being host-rendered inline for the non-PiP case in either approach. Bitmap subtitles (PGS/DVB) cannot become a native text track either way and stay host-only (or would need burn-in, which is out of scope here).
Before we commit: is there a constraint on your side that specifically needs the WebVTT rendition (a client that already consumes
EXT-X-MEDIAsubtitle groups, tooling, and so on), or would the tx3g-in-fMP4 route work for your use case? Given how it interacts with the SDR/HDR/DV routing, tx3g is our lean, but we would rather hear your take before building.edde746 commentedon Jun 22, 2026
No constraint on my side.
feat(subtitles): inject mov_text samples per segment cut in the produ…
DrHurt commentedon Jun 22, 2026
Funny I was thinking about that before opening an issue on AetherPlayer (Mac) to request AirPlay support.
Adding an opt in “include simple text subtitles in fMP4 segments” and maybe “include all text subtitles” to additionally include flattened ASS.
Optional to allow players to use custom renderers for customisation of wanted.
If forced on, AVPlayerViewController will always show a subtitles menu and custom renderers will end up having a duplicate menu.
Ffmpeg already has a converter via the -c:s mov_text command
feat(subtitles): full-decode into mov_text store + native selection A…
superuser404notfound commentedon Jun 22, 2026
Thanks, this lines up with where we landed. We went with tx3g/mov_text muxed into the existing fMP4 stream (no master, so the SDR/HDR/DV routing is untouched), and yes, the engine uses libavformat's mov_text path.
Your duplicate-menu point is exactly why it is strictly opt-in. The native track is only declared when the host sets a
prepareNativeSubtitlesload option; with it off the muxer output is byte-identical to today andAVPlayerViewControllershows no subtitle menu. So a host that draws its own subtitles either leaves it off, or turns it on and suppresses the stock legible menu in its own player UI. The engine never forces the track on. The track is also declareddisposition:default=0/defaultOption == nil, so even when present it is not auto-displayed: the host selects it explicitly (we exposesetNativeSubtitleSelected(_:)), which is what makes it appear in PiP/AirPlay/external while inline stays host-rendered.On the two tiers: v1 is the "simple text" one, a single active text track (embedded or sidecar) carried as plain mov_text, with rich ASS still host-rendered inline. "Flatten ASS styling into the track" and "carry all text tracks, not just the active one" are both sensible follow-ups (mov_text can hold basic style boxes), but we are keeping v1 plain and opt-in to avoid the duplicate-menu and styling-mismatch surprises. Worth noting both are plain-text only natively, so a flattened-ASS track in PiP would still differ from the inline swift-ass render.
(Separately, AirPlay on AetherPlayer for Mac is a good shout, that belongs in the AetherPlayer repo.)
docs(subtitles): document the embedded-subtitle park vs producer buff…
docs(subtitles): document the native mov_text subtitle track (#55)
DrHurt commentedon Jun 22, 2026
All tracks would need to be included for AVPlayerViewController to enumerate them in the menu so users can select the desired one.
fix(subtitles): re-thread the cue store + shift across producer resta…
Merge: native subtitle track via tx3g (mov_text) for PiP/AirPlay/exte…
superuser404notfound commentedon Jun 22, 2026
Agreed, and that is the next round. To enumerate languages in the stock
AVPlayerViewControllermenu, every text track has to be present as its owntx3gtrak with a language tag, plus a track-selection API so the host (or the user, via the native menu) can pick one.v1 just landed on main: the single active text track muxed as
tx3g, so the currently selected subtitle survives PiP / AirPlay / external display. We kept v1 to one track to ship the core win and keep the opt-in surface minimal. The follow-up carries all text tracks (embedded + sidecar) with language metadata so the native menu lists them, which is exactly your point. A single side-demuxer pass can decode every text stream into per-track stores, so it stays one extra read pass, not N.Thanks for pushing on this.
DrHurt commentedon Jun 22, 2026
Why a subtitles API? I thought FFmpeg would just copy all tracks at once on the fly via the -c:s mov_text and -map 0
feat(subtitles): add stateless mov_text sample builder (superuser404n…
15 remaining items
chore(release): 3.13.1 — embedded ASS feed batching (#56)
feat(engine): rank subtitle-language pick by disposition, surface for…
chore(release): prep 4.5.0 — disposition-ranked subtitle pick + nativ…
fix(subtitles): bound the embedded subtitle side-demuxer open on remo…
Render in-band CEA-608 closed captions (#77)
fix(captions): guard the CC tap against pump overlap, clear cues on C…
feat(ios): lazy native-subtitle readers + setNativeSubtitleForPiP (#15)
test(integration): AVPlayer-open + legible-exposure harness for the s…
superuser404notfound commentedon Jun 29, 2026
Status update (device-tested 2026-06-29, iOS 26.5.1)
The engine side of this is built and works: a real WebVTT
SUBTITLESrendition is served over the loopback (master +subs_N.m3u8+ per-segmentsubs_N_M.vtt), gated behindLoadOptions.prepareNativeSubtitles, on branchfeat/pip-subs-dual-renderer-probe. Device-confirmed: a subtitle does render inside the iOS PiP window, so the serving pipeline is correct.The blocker is not engine-side. It is AVKit on the host:
AVPlayerViewController'sAVSmartSubtitlesControllerreconciles away a programmatically-selected legible track (only aselect(nil)-> hop ->select(option)re-assert attaches the renderer at all;criteriaandDEFAULT=YESrender nothing), and it disables the selection after about 2 seconds. So the rendition is reliable to serve but not reliable to display via our custom-transportAVPlayerViewController.Tracking the host/AVKit reliability question (where the actual help is needed) in superuser404notfound/Sodalite#32. Engine machinery stays on the branch, gated and inert on
main, until that is resolved.feat(subtitles): pump tap harvests text-subtitle cues from the produc…
Merge probe/pip-subs-retention: 4.9.0 - PiP subtitles, restart timeli…
superuser404notfound commentedon Jul 2, 2026
Shipped in 4.9.0 (plus the 4.9.1 tvOS build hotfix): https://github.com/superuser404notfound/AetherEngine/releases/tag/4.9.0
The final shape is the WebVTT rendition this issue originally proposed, not the tx3g detour discussed above: in-band timed text turned out to be non-conformant for HLS (AVPlayer rejected the stream with -11829/-12848), so every text subtitle track is now served as a language-tagged
EXT-X-MEDIA:TYPE=SUBTITLESrendition over the loopback master (windowed per-video-segment WebVTT), exposed through the standard legibleAVMediaSelectiongroup.Two engine problems had to fall to make it reliable:
Renditions ship
DEFAULT=NO,AUTOSELECT=NOso a host overlay never double-renders; selection is host-driven viasetNativeSubtitleSelected(track:)(with an automatic re-assert when AVFoundation drops a selection during a stall recovery). Details in docs/formats.md. Device-verified on iOS 26.5.1: rendering in PiP, surviving seeks in both directions.Thanks @edde746 for the original proposal and @DrHurt for the static-VOD reference test that isolated the root cause.
refactor: remove dead in-band mov_text/tx3g subtitle muxing