Repository navigation
Description
What should the engine do?
Allow the main playback probe to finish once the parameters required for safe audio/video playback are ready, even when already-enumerated PGS subtitle tracks still lack dimensions. Keep those tracks available and complete their remaining metadata during playback or when selected. An opt-in load policy would also meet our integration need.
On our measured Matroska source, four unresolved PGS tracks keep the shared probe reading to its 50 MiB ceiling, costing 13.46–14.39 seconds before playback can be constructed.
Motivating media / integration
We are optimizing startup in Syncnext / SyncnextHybrid. The controlled measurements below are from a macOS Release native-player probe using the same engine pin as our tvOS integration.
- AetherEngine 7.45.0, commit
52802afaaf035a7f729bba1043b640ad4d9ebb3e. - FFmpegBuild 3.9.0, commit
3b398c8f6340fe5fb4a7cb9a2a211a16677171e0; FFmpeg version headern8.1.3. - Apple M2 Ultra; macOS 27.0.1 (26A434).
- Native AVPlayer through the engine's local remux/HLS path; HTTP URL input from a local SwiftBun media-source proxy, held source connection and progressive segment delivery.
- AVPlayer forward-buffer preference held at 4 seconds.
- Finite 64.4 GiB Matroska VOD: 1 video + 12 audio + 13 subtitle streams, 26 total.
- Default main-probe budget:
probesize = 52,428,800bytes,max_analyze_duration = 60,000,000microseconds. The latter is a media-analysis budget, not a 60-second wall-clock deadline.
Observed behavior and reproduction
- Start a fresh source process and resolve the same media again.
- Load its HTTP URL with the settings above.
- Measure
containerOpened → streamsProbedusing the engine checkpoints and a monotonic clock. - Observe the main shared probe reach its byte ceiling, with PGS streams 13, 14, 21 and 24 still reporting
unspecified size.
Two runs used the same Release binary and source configuration; only detailed probe logging / thread sampling changed:
| Measurement | Detailed logging + sampling | Normal logging |
|---|---|---|
| Main-probe wall time | 13.464 s | 14.389 s |
| Whole player-process CPU during that interval | 0.536 s | 0.260 s |
| Wall time minus process CPU | 12.928 s | 14.129 s |
| Unresolved subtitle stream indices at exit | 13, 14, 21, 24 | 13, 14, 21, 24 |
Whole-process CPU includes every app thread and logging; it is an upper bound on probe CPU, not exclusive FFmpeg time. The separate source process is outside that measurement.
In the detailed run:
- All 26 streams were already enumerated before
avformat_find_stream_info. - AVIO cumulative bytes read increased from 262,144 to 52,754,165: 52,492,021 additional bytes, about 50.060 MiB, at about 3.899 MB/s.
- The explicit exit reason was the 52,428,800-byte probe ceiling. The four PGS tracks were the remaining codec-parameter warnings.
- The function performed no seeks. Tail-index requests occurred after this probe.
- From the byte-ceiling log to the function's “After” log took about 0.842 ms.
- In an eight-second middle-window thread sample, 698 / 711 demux-thread samples (98.17%) were in
AVIOReader.readPersistent → NSCondition.waitUntilDate; the source-pump thread was waiting inHeldSourceConnection.readFromSocket.
This supports waiting for source delivery as the dominant elapsed cost. It does not separate proxy scheduling from external-origin or network delays, and the sampling fraction is not an exact whole-probe wait-time measurement.
Log excerpt, with process-specific context pointers removed:
Before avformat_find_stream_info() pos: 15887 bytes read:262144 seeks:0 nb_streams:26
Probe buffer size limit of 52428800 bytes reached
Could not find codec parameters for stream 13 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Could not find codec parameters for stream 14 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Could not find codec parameters for stream 21 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Could not find codec parameters for stream 24 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
After avformat_find_stream_info() pos: 52634935 bytes read:52754165 seeks:0 frames:27406
The logged frames counter describes packets in the shared scan, not decoded video-frame count.
Why this needs a main-probe policy
The pinned main probeStreams path invokes avformat_find_stream_info. FFmpeg's PGS parameter check requires a width; its shared readiness / byte-limit loop explains why an unresolved subtitle can prevent early completion. This is consistent with the observed warnings and exit reason.
Related work:
- Subtitle side-demuxer's 5 s analyze ceiling adds a flat ~5 s startup stall for PGS/bitmap tracks on URL sources #87 already avoids this chase for the subtitle side-demuxer. This report concerns the main playback probe, before session construction.
- find_stream_info reads to the full probe budget chasing an unresolvable attached-picture (mjpeg cover) stream, slowing remote open #75 addressed the analogous main-probe cost from an unresolved attached picture.
- Let callers bound the demux probe budget (probesize / analyze duration) per load #68 supplies useful global
probesize/maxAnalyzeDurationcontrols. A smaller global budget still does not express “finish the A/V information we need, but defer sparse subtitle dimensions.”
We are requesting the supported upstream approach, without prescribing a particular implementation.
Required behavior / validation
- Preserve the A/V analysis needed for correct playback, including video reorder/DTS information and audio parameters.
- Keep all enumerated subtitle tracks, indices and language metadata; unresolved dimensions should remain pending rather than making the tracks disappear.
- Verify selecting each of the four PGS tracks after startup, actual bitmap cues and canvas placement, switching, seeking and cancellation. Track counts alone are insufficient.
- Keep the 4-second AVPlayer buffer preference for comparison. Compare probe bytes/time, first decoded frame, verified playback progress and subsequent stalls so the result does not merely move waiting past startup.
Evidence limits
These measurements use our patched consumer integration, not a pristine upstream build. The consumer carries integration and request-diagnostics patches; this experiment did not change FFmpeg or the main probeStreams algorithm/default budget, whose implementation was checked against the pin.
The exact earlier instant when all required A/V parameters become ready has not been measured. Consequently, the full ~14 seconds is not a claimed achievable saving. This diagnostic baseline also did not validate cue rendering for every subtitle track; the deferred-subtitle behavior remains a request to implement and verify.
The input is a private media source; no public minimal media reproducer is attached. Source URLs, headers, credentials and raw private traces are omitted.
Area
Performance / public API surface
Activity
Merge fix/pgs-probe-parking-858: PGS tracks sit out the playback probe (
superuser404notfound commentedon Oct 25, 2026
Thanks for the thorough report. The FFmpeg pointers and the evidence limits made this quick to pin down.
Fixed on main in de860e4 (merge b194dce). It will ship with the next release.
What changed: the main playback probe now parks every PGS track whose codec is already known as
ATTACHMENTfor the duration ofavformat_find_stream_info. That is the same lever the engine already uses for undecodable audio (#466) and cover art (#75), and the tracks are restored right after the probe.has_codec_parametersasks nothing of an attachment, so the pass ends as soon as audio and video are resolved. Video reorder/DTS information and audio parameters go through the probe exactly as before.The tracks keep their index, language, codec and disposition. Their width stays 0, which is exactly what a full-budget probe left on your source anyway. Playback never needed that width from the probe:
EmbeddedSubtitleDecodertakes the canvas from the decoded presentation composition segment and falls back to the video size, the same footing the subtitle side reader has had since #87. No new API or opt-in is involved; it applies to every main open.Measured with
aetherctlagainst a 1080p MKV with two PGS tracks whose first cue sits at 150 s, behind a throttled 4 MB/s HTTP origin, two runs per arm:find_stream_infoThis fixture stops at the 60 s analyze-duration budget rather than the 50 MiB ceiling because its bitrate is low. On your source, the ceiling was the exit.
Subtitle validation (
aetherctl play --subs pgssub): I used a 720p video carrying a 1920x1080 PGS canvas, which is the case where the probe-resolved width could have mattered. Early cues (inside the old probe window) and late cues (past it) land at the identical normalized position and canvas on both builds. Every authored cue arrives in 3 of 3 runs, and cues keep arriving after a seek. The new unit test uses a synthetic transport stream with a cue-less PGS PID: the open reads 262,144 bytes instead of 1,572,864, and the track is still listed as a subtitle.What I could not reproduce here: your 26-stream source, track switching across all four PGS tracks, and the 4 s AVPlayer buffer comparison on tvOS. Numbers from your harness after the next release would be very welcome, especially first decoded frame and any later stalls.
perf(demux): park PGS tracks out of the playback probe (superuser404n…
superuser404notfound commentedon Oct 26, 2026
Released in 7.48.0 (263dc11). Leaving this open for the retest.
qoli commentedon Nov 6, 2026
Verified on the original 64.4 GiB Matroska source with all 26 streams on a physical Apple TV running tvOS 26.6.1. Syncnext 1.212 (579) used AetherEngine 7.56.0 (
76ad51a7), FFmpegBuild 3.12.1 and the effective 4.00 s AVPlayer forward-buffer preference.find_stream_infowith the default 50 MiB budget. AVIO had read 262,144 bytes before the call and 262,144 bytes after it, so the call added 0 bytes to that counter. All 13 PGS tracks were enumerated and restored, including indices 13, 14, 21 and 24. The earlier 7.45.0 macOS runs on the same media took 13.46–14.39 s, with 52,492,021 additional AVIO bytes in the detailed run.The original playback and all four deferred subtitle tracks passed device acceptance.