Skip to content

Let callers bound the demux probe budget (probesize / analyze duration) per load #68

Closed

Description

What should the engine do?

Allow a caller to set the open-time probe limits per load(), instead of always using the fixed internal DemuxerOpenProfile.playback (50 MB / 60 s). Two optional LoadOptions fields, both defaulting to today's values so nothing changes unless set:
• probesize: Int64? — maps to AVFormatContext.probesize
• maxAnalyzeDuration: Int64? — maps to AVFormatContext.max_analyze_duration (µs)

Motivating media or use case

A Jellyfin client streaming large remote remuxes from a remote CDN over HTTPS. Example: ~45 GB MKV, HEVC Main 10 4K HDR, multiple AC3 + TrueHD tracks, SubRip + HDMV PGS subtitles, and an mjpeg cover attachment. The sparse PGS and mjpeg streams never resolve codec params, so find_stream_info reads to the full 50 MB budget on every open — ~13–14 s before first frame over the network. Video + audio resolve almost immediately; the rest is spent on streams playback doesn't need. The budget is tuned for local disk (where reading 50 MB is free) and there's currently no way for a remote caller to cap it.

Area

Codec / container support

Host app / integration context

Custom integration — a Multi-Server (Jellyfin, Plex, etc.) client that direct-plays remote CDN-served files through the engine.

Would you be willing to open a PR?

Maybe, with guidance

Activity

  1. ghost added
    enhancement
    on Jun 25, 2026
  2. superuser404notfound commented on Jun 26, 2026

    @superuser404notfound
    Owner

    Shipped in 4.2.0.

    LoadOptions now carries two optional probe-budget knobs, both defaulting to nil so nothing changes unless you set them:

    public var probesize: Int64?           // bytes  -> AVFormatContext.probesize
    public var maxAnalyzeDuration: Int64?  // micros -> AVFormatContext.max_analyze_duration

    For your remote-remux case (the layout is already known from the server's MediaInfo, so a full probe is wasted):

    try await engine.load(url: remoteURL, options: LoadOptions(
        httpHeaders: authHeaders,
        probesize: 4 * 1024 * 1024,        // 4 MB instead of 50 MB
        maxAnalyzeDuration: 5 * 1_000_000  // 5 s instead of 60 s
    ))

    The cap lands on every main-playback open that runs find_stream_info (the routing probe that becomes the session demuxer, the software/audio fallback opens, the audio/title-switch reopens so a switch does not re-pay the cost, and the native HLS fallback open and live reopen). It is deliberately left at the full 50 MB / 60 s on paths where a complete probe is load-bearing: the subtitle side-demuxer (sparse PGS/DVB detection), the probe(url:) metadata API, the Dolby Vision probe, and still extraction.

    Two things worth knowing, both documented on the fields:

    • An over-tight budget fails open, not closed. find_stream_info still returns success with a logged warning, so a late-resolving track goes silently missing rather than erroring. Worth a track-count sanity check after load if you push the budget hard.
    • maxAnalyzeDuration: 0 is not "no cap": FFmpeg maps 0 to a container-dependent heuristic (~5-7 s for MPEG-TS, longer elsewhere) that is shorter than the 60 s default. Use a positive value for an explicit cap.

    Leaving this open until you can confirm the first-frame win on your 45 GB remux over the real CDN. Thanks for the precise report, the sparse-PGS/mjpeg detail made the scope easy to get right.

  3. ghost closed this as completedon Jun 26, 2026
  4. superuser404notfound commented on Jun 26, 2026

    @superuser404notfound
    Owner

    Appreciate the thorough validation, and good to have it closed. ~2 s open / ~3.7 s first frame down from ~13-14 s is exactly the win this was for, and confirming fail-open enumerated all six streams (the PGS codec params resolving lazily on first packet, as expected) is the reassuring part. Feeding the track index from server MediaInfo to skip the probe(url:) pre-probe entirely is the right call client-side, since that path keeps the full budget by design. Thanks again for the precise reports across #68, #69, and #71.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions