Skip to content

A probe cannot settle TrueHD Atmos: the major-sync check runs only in a session, and .atmos covers E-AC-3 only #1035

Closed

Description

@Desima-AP

What should the engine do?

Offer an opt-in probe detail that settles TrueHD Atmos the way a session does since 7.40.1 (PR #838): when avformat_find_stream_info left a TrueHD track's profile unknown, read the track's first major sync within a budget and report Atmos, no Atmos, or not settled.

Motivating media or use case

A tvOS host app labels audio tracks in its library before playback from AetherEngine.probe(source:detecting:limits:cancellation:). For E-AC-3 the .atmos pass gives a firm answer. For TrueHD there is no equivalent, so the host cannot tell "TrueHD without Atmos" from "TrueHD the probe did not decode".

What the code does (read at 7.62.1 d879ef83, unchanged on main at db92bf68)

  • A probe's only TrueHD Atmos signal is TrackInfo.profile == "Dolby TrueHD + Dolby Atmos" (docs/api.md, TrackInfo). libavcodec sets that profile only once it has decoded a frame of the track, so a track whose first packet lies beyond the analysis window keeps AV_PROFILE_UNKNOWN and profile == nil. PR fix(audio): read TrueHD Atmos from the major sync when the probe never reached the track (7.40.1) #838 measured that at load on a real film (TrueHD from 22 s, 45.8 MB into the file, past a 16 MiB analysis budget).
  • In a controlled probe the caller's byte budget bounds that window as well: probeOpenProfile(limits:) in Sources/AetherEngine/AetherEngine+Probe.swift clamps probesize to ProbeLimits.maxInputBytes (8 MiB by default).
  • The fix of PR fix(audio): read TrueHD Atmos from the major sync when the probe never reached the track (7.40.1) #838 runs only in a session, and only when object rendering is requested on a build with the TrueHDObjectAudio trait: HLSVideoEngine.resolveUnlabelledTrueHDAtmos (Sources/AetherEngine/Video/HLSVideoEngine+SpatialAudio.swift) and the software host (Sources/AetherEngine/Native/SoftwarePlaybackHost+AudioProducer.swift) both gate on needsTrueHDMajorSyncVerdict before they call trueHDMajorSyncVerdict(demuxer:streamIndex:).
  • The .atmos detail pass in probe(source:detecting:...) runs only when the target track is AV_CODEC_ID_EAC3. docs/api.md states it: "Atmos detection means E-AC-3 JOC, not TrueHD Atmos."

What was measured, and what was not

  • tvOS Simulator: a plain TrueHD 5.1 track encoded by ffmpeg probes as codec == "truehd" with profile == nil (read out on 7.55.0; on 7.62.1 such a track is still not reported as Atmos). That is the correct negative, and it is the same nil an undecoded Atmos track gets, because VideoStreamFormat.profileName returns nil for AV_PROFILE_UNKNOWN.
  • Not reproduced by the host: a TrueHD Atmos track that a probe misses. No public tool writes a TrueHD Atmos stream, so I have no sample I can share, and nothing was measured on an Apple TV. The mechanism is the one PR fix(audio): read TrueHD Atmos from the major sync when the probe never reached the track (7.40.1) #838 documents, and the rest is read from the code above.

Expected

With the detail requested, a TrueHD track's answer is as reliable from a probe as from a session, and "not settled within the budget" is told apart from "no Atmos".

Suggestion

HLSVideoEngine.trueHDMajorSyncVerdict(demuxer:streamIndex:) is static, needs no session and no decoder (TrueHDMajorSync.isAtmos reads the packet bytes), and already returns a three-state answer. The .atmos pass already seeks to the start and reads the target track's packets under AtmosDetectionOptions, so a TrueHD target could take that route.

What the host does meanwhile

It shows an unmarked TrueHD track as plain TrueHD and never claims "no Atmos" for it.

Area

Audio

Host app / integration context

My own tvOS host app (custom integration)

Would you be willing to open a PR?

No


Prepared with an AI coding agent that works on the host app. Every measurement named above comes from its test runs on the versions stated; what was only read in the code is marked as such.

Activity

  1. added
    area: api
    area: audio
    enhancement
    on Nov 11, 2026
  2. superuser404notfound commented on Nov 11, 2026

    @superuser404notfound
    Owner

    Thanks for the precise write-up, the suggestion was exactly the right route.

    Landed on main in b46bff7 (feature commit e399524), unreleased for now:

    • With .atmos requested, a TrueHD target track is now read up to its first major sync inside the probe, under AtmosDetectionOptions and the same discard and input budget as the E-AC-3 pass. No decoder is opened.
    • The answer is the new TrackInfo.trueHDAtmos: TrueHDAtmosVerdict?: .atmos, .noAtmos (a major sync was read and declares no Atmos) or .unsettled (none within the budget). It is nil when the pass did not run for that track. A cap never turns into .noAtmos.
    • .atmos also sets profile to "Dolby TrueHD + Dolby Atmos", so code that labels from profile gets it too. isAtmos stays the E-AC-3 JOC answer.
    • aetherctl probe --detect-atmos prints truehd-atmos=....

    One thing to know for your library scan: under ProbeLimits the byte budget covers this pass as well. A TrueHD track that starts beyond maxInputBytes stops the whole probe with ProbeError.inputLimit instead of answering .noAtmos. So for the late-track case from PR #838 the budget has to reach the track (the test uses 256 MiB).

    Verified against a real TrueHD Atmos stream (FFmpeg FATE's truehd/atmos.thd) muxed into MKV behind 70 s of video: the header probe reports profile == nil, the .atmos pass reports .atmos. Plain TrueHD from FFmpeg's encoder reports .noAtmos.

    I'll leave this open until it ships in a release and you have had a chance to try it.

  3. superuser404notfound commented on Nov 12, 2026

    @superuser404notfound
    Owner

    Released in 7.63.0 (f81a8b5b).

  4. Desima-AP commented on Nov 13, 2026

    @Desima-AP
    ContributorAuthor

    Tried on 7.63.0 (f81a8b5b).

    Setup: a tvOS host app on the tvOS simulator, controlled probes through our custom IOReader, which counts every read (fed from a local file); one ProbeLimits (24 MiB input) shared by the calls. Fixture: a 4.8 MB MKV with a plain TrueHD 5.1 track and an AC-3 track.

    • Header-only call: 262,144 B in 1 read, trueHDAtmos == nil.
    • Then a call of its own with detecting: .atmos and AtmosDetectionOptions(targetTrackID:) set to the TrueHD track: .noAtmos. Both calls together: 786,560 B in 4 reads (the header again, then 262,272 B more up to the first major sync). Only the targeted track carries a verdict.
    • With no room left in the budget, and with a source that stops answering once the pass asks for the track's bytes: no verdict, and the header call's answer is unaffected.

    About your note on inputLimit: we run the .atmos pass as a separate call, after the picture details, so a late TrueHD track can only cost its own answer. We store .noAtmos as a fact and keep treating .unsettled and nil as "may be Atmos".

    Not measured: .atmos on a real TrueHD Atmos stream (we have no such stream in our fixtures), a track that starts late in a large file, a real Apple TV.

    Done from our side.

  5. superuser404notfound commented on Nov 13, 2026

    @superuser404notfound
    Owner

    Thanks for testing it this thoroughly, the read counts are useful to have on record. Running the .atmos pass as its own call is the right way around the inputLimit case, and treating .unsettled and nil as "may be Atmos" matches what the verdict means.

    Closing this. If a real TrueHD Atmos file or a late track in a large file ever answers something unexpected, reopen or file a new issue.

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

    area: apiarea: audioenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions