What should the engine do?
An external subtitle URL can be a media container holding several subtitle streams, and a host registers one ExternalSubtitleTrack per stream against that same URL.
decodeFile scans for AVMEDIA_TYPE_SUBTITLE and stops at the first match (SubtitleDecoder.swift:134-143), and ExternalSubtitleTrack carries no index (ExternalSubtitleTrack.swift:9-30). Every such track therefore decodes the first subtitle stream and renders identical cues, and each one refetches the whole container.
Ask: ExternalSubtitleTrack.sourceStreamIndex: Int32?, honoured by SubtitleDecoder.decodeFile.
- Absolute
AVStream index within the container, not the Nth subtitle stream.
nil keeps the current first-subtitle-stream behaviour.
This mirrors the existing audioSourceStreamIndexOverride (HLSVideoEngine.swift:1162-1175) — an absolute stream index validated by stream type via isAudioStream(demuxer:index:) — and the convention that embedded track ids are AVStream indices (RemoteHLSMediaSelection.swift:14). It differs only in reporting an invalid index instead of falling back to auto, since for subtitles a silent fallback is indistinguishable from the current behaviour.
Motivating media or use case
A container carrying several embedded subtitle streams — an MKV with English, English SDH and Spanish ASS tracks — reached through external track registration rather than as the played media. Registering one track per stream yields three selectable tracks that all render the first stream.
Area
Public API surface
Host app / integration
Custom
Would you be willing to open a PR?
Maybe, with guidance
Line references are from 6.2.1 (4e281c9).
What should the engine do?
An external subtitle URL can be a media container holding several subtitle streams, and a host registers one
ExternalSubtitleTrackper stream against that same URL.decodeFilescans forAVMEDIA_TYPE_SUBTITLEand stops at the first match (SubtitleDecoder.swift:134-143), andExternalSubtitleTrackcarries no index (ExternalSubtitleTrack.swift:9-30). Every such track therefore decodes the first subtitle stream and renders identical cues, and each one refetches the whole container.Ask:
ExternalSubtitleTrack.sourceStreamIndex: Int32?, honoured bySubtitleDecoder.decodeFile.AVStreamindex within the container, not the Nth subtitle stream.nilkeeps the current first-subtitle-stream behaviour.This mirrors the existing
audioSourceStreamIndexOverride(HLSVideoEngine.swift:1162-1175) — an absolute stream index validated by stream type viaisAudioStream(demuxer:index:)— and the convention that embedded track ids areAVStreamindices (RemoteHLSMediaSelection.swift:14). It differs only in reporting an invalid index instead of falling back to auto, since for subtitles a silent fallback is indistinguishable from the current behaviour.Motivating media or use case
A container carrying several embedded subtitle streams — an MKV with English, English SDH and Spanish ASS tracks — reached through external track registration rather than as the played media. Registering one track per stream yields three selectable tracks that all render the first stream.
Area
Public API surface
Host app / integration
Custom
Would you be willing to open a PR?
Maybe, with guidance
Line references are from 6.2.1 (
4e281c9).