Skip to content

Silent video-only fallback when the eac3 encoder is absent — AudioBridge should cascade to FLAC #165

Closed

Description

@htrung14

What happened?

I called engine.load() on a DTS 5.1 MKV (native AVPlayer path) with the default audioBridgeMode (.surroundCompat), on an FFmpeg build compiled without --enable-encoder=eac3 (the flac encoder is present). I expected audio to play — via the FLAC bridge if EAC3 re-encode isn't possible.

Instead the session silently fell back to video-only: AudioBridge.init(..., mode: .surroundCompat) throws AudioBridgeError.encoderNotFound, and buildProducerWithAudioCascade makes a single bridge attempt — any thrown error drops straight to the video-only path. Every bridge-required codec (DTS, TrueHD, MP3, Opus, Vorbis, PCM, MP2, LATM-AAC) plays with no audio, and the only signal is one log line.

Two smaller aggravators:

  • The routing log line prints a hardcoded "decoding + FLAC re-encode" label regardless of the actual configured mode (it was EAC3), which misdirects debugging.
  • The function's doc-comment describes a cascade ("Stream-copy -> FLAC-bridge -> video-only") that the code doesn't implement across bridge modes.

Steps to reproduce

  1. Build/link FFmpeg without --enable-encoder=eac3 (flac encoder present)
  2. Configure LoadOptions with the default audioBridgeMode (.surroundCompat)
  3. engine.load(url:) on any DTS or TrueHD MKV
  4. Observe: video plays, no audio; log shows AudioBridge init failed (AudioBridge: bridge encoder not registered ...), falling back to video-only

AetherEngine version or commit SHA

5.13.0 (verified the same single-attempt code is present at 5.15.0, Video/HLSVideoEngine+AudioRoute.swift)

Host app

Custom / my own integration

Platform

tvOS

OS version

tvOS 26

Device / chip

Apple TV 4K (3rd gen, 2022)

Playback path

Native AVPlayer

Source media (for playback bugs)

MKV, HEVC Main 10, 3840x2160; audio DTS 5.1 (also reproduced with TrueHD/Atmos 7.1 — any requiresBridge == true codec)

Error codes / log lines

[HLSVideoEngine] audio: override accepted, sourceStreamIndex=1 (auto would have picked 1)
[HLSVideoEngine] audio: codec=dts (bridge required), decoding + FLAC re-encode
[HLSVideoEngine] AudioBridge init failed (AudioBridge: bridge encoder not registered (FFmpeg build missing --enable-encoder=flac / --enable-encoder=eac3?)), falling back to video-only
[AetherEngine] published active audio reconciled to the session's real pick: nil (was 1)

(Note the second line's "FLAC re-encode" label is hardcoded — the actual attempted mode was EAC3.)

Anything else

Root cause and a fix are in hand. I have a small patch (~50 lines, Video/HLSVideoEngine+AudioRoute.swift only) that restores a bridge-mode cascade: try the configured mode, catch encoderNotFound, retry .lossless (FLAC), and emit a loud ERROR before any video-only fallback so a missing encoder is never silent. No behavior change when the configured encoder exists (first attempt succeeds as today). Verified on hardware: Apple TV 4K, DTS 5.1 and TrueHD Atmos MKVs over network streams — audio plays via the FLAC bridge after the patch; a downstream client's full unit suite (1038 tests) runs green against it. The patch applies clean to 5.15.0 — happy to open a PR if you want it.

Activity

  1. superuser404notfound commented on Jul 20, 2026

    @superuser404notfound
    Owner

    Fixed in 5.15.4 (just released). Thank you for the exact root cause, the codec-by-codec impact list, and especially the hardware verification, that made this a quick, confident fix, so no PR needed on your side, but the offer was appreciated.

    What shipped, matching your patch:

    • buildProducerWithAudioCascade now cascades across bridge modes instead of making a single attempt. It tries the configured audioBridgeMode, and only on AudioBridgeError.encoderNotFound falls through to the other mode's encoder (EAC3 <-> FLAC) before any video-only fallback. Every other init failure is source-specific, so it stops immediately without a pointless retry.
    • A loud ERROR line is now emitted (not a quiet info line) before the silent video-only fallback, so a missing encoder is never invisible.
    • No behavior change when the configured encoder is present: the first attempt succeeds exactly as today.
    • Both aggravators are fixed: the routing log no longer hardcodes "FLAC re-encode" (it reflects the configured mode now), and the buildProducerWithAudioCascade doc-comment matches the real routing.

    The ordering decision is a pure bridgeModeCascade(configured:) with unit coverage in Issue165BridgeModeCascadeTests; the encoder-absent runtime path itself is not unit-testable since CI's FFmpeg build carries both encoders, so your on-device pass is what proves the end-to-end behavior. Full suite is green (841/841), strict-concurrency clean, tvOS Simulator build succeeds.

    Release: https://github.com/superuser404notfound/AetherEngine/releases/tag/5.15.4

    Closing as fixed; reopen if a build without eac3 still comes up silent on your end.

  2. superuser404notfound commented on Jul 20, 2026

    @superuser404notfound
    Owner

    Reopening to keep this open until you have confirmed the 5.15.4 fix on your end (a build without eac3 now playing via the FLAC bridge). No rush, just did not want to close it out from under your retest.

  3. htrung14 commented on Jul 20, 2026

    @htrung14
    Author
  4. htrung14 commented on Jul 21, 2026

    @htrung14
    Author

    Confirmed fixed on hardware with 5.15.4.

    Apple TV 4K (3rd gen), tvOS 26.5, DTS 5.1 source over a network stream, on an FFmpeg build without --enable-encoder=eac3 (flac present). Device log from the run:

    [HLSVideoEngine] audio: codec=dts (bridge required), decoding + EAC3 re-encode
    [AudioBridge] init: mode=lossless srcCodec=dts sampleRate=48000 sourceChannels=8 encoderChannels=8
    [HLSVideoEngine] audio bridge cascaded surroundCompat → lossless (configured encoder absent); DTS → FLAC bridge
    [NativeAVPlayerHost] item.audioTrack codec='flac' enabled=true sr=48000 ch=8 (readyToPlay)
    

    Before 5.15.4 this went straight to video-only; now the encoderNotFound cascade falls through to FLAC and audio plays. The de-hardcoded routing log ("EAC3 re-encode" reflecting the configured mode, then the explicit cascade line) also made this trivial to verify from a log pull. Thanks for the fast turnaround — closing on our end.

  5. superuser404notfound commented on Jul 21, 2026

    @superuser404notfound
    Owner

    Thanks for the hardware confirmation and the full device log. That is exactly the cascade path we wanted to see: surroundCompat falling through to lossless on the absent encoder, DTS routed to the FLAC bridge, and the track coming up readyToPlay with audio. Good to hear the de-hardcoded routing lines made the log pull easy to read as well.

    Closing as fixed in 5.15.4. Reopen anytime if a build without eac3 ever comes up silent again.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions