Skip to content

Subtitle side-demuxer's 5 s analyze ceiling adds a flat ~5 s startup stall for PGS/bitmap tracks on URL sources #87

Description

@rrgomes

On a remote (URL/HTTP) source, opening the embedded-subtitle side-demuxer for a PGS/HDMV bitmap track blocks for the full analyzeCeiling (5.0 s) before it yields: such tracks never satisfy has_codec_parameters, so find_stream_info reads to the budget cap. When that open is on the startup path (host selectSubtitleTrack at load, or LoadOptions.preferredSubtitleLanguages auto-select), the 5 s lands as a flat pause before playback begins.

Root cause

Demuxer.swift, DemuxerOpenProfile.subtitleSideDemuxer:

let probeCeiling:   Int64 = 4 * 1024 * 1024   // 4 MB
let analyzeCeiling: Int64 = 5 * 1_000_000     // 5.0 s

The profile's own doc comment already describes it: PGS streams "keep has_codec_parameters false to the budget cap (the #75 pattern)," so find_stream_info runs to the full ceiling. A fast LAN hides it; a slower/remote URL blocks ~5 s. Since EmbeddedSubtitleDecoder only needs codec_id / codec_type (resolved by avformat_open_input from the container header / MPEG-TS PMT) and seeds the bitmap canvas from the source video size, the find_stream_info chase is pure cost.

Repro

A 1080p/4K HEVC file with embedded PGS (HDMV bitmap) subtitle tracks served over an HTTP/URL source (custom AVIO); select that PGS track at load. Result: ~5 s paused before playback self-starts. The same open is instant on a local file.

Suggested fix direction

Cap the subtitle side-demuxer's analyzeCeiling to sub-second (codec params come from the header/PMT before find_stream_info), or skip find_stream_info for the side-demuxer and read codec_type / codec_id directly, or make the open non-blocking with respect to the startup gate. Related: #52, #75, #76.

Host-side note: integrators can mitigate by deferring selectSubtitleTrack past the first playing state, but the 5 s budget is unnecessary regardless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions