Skip to content

fix(playback): preserve video for Android EAC3 fallback - #790

Closed
blurbery wants to merge 1 commit into
Silo-Server:mainfrom
blurbery:contrib/android-mobile-eac3-direct-stream
Closed

blurbery wants to merge 1 commit into
Silo-Server:mainfrom
blurbery:contrib/android-mobile-eac3-direct-stream

Conversation

@blurbery

@blurbery blurbery commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

What I changed

I added an Android-mobile fallback for multichannel E-AC-3 on Bluetooth outputs that advertise no E-AC-3 passthrough. Direct play remains the first choice. If Android rejects that route, the next HLS plan copies the original video bitstream and converts only E-AC-3 audio to AAC. Full video transcoding remains available only if the direct-stream route also fails.

Why

I reproduced this with the exact same media file on Android and iPhone. The iPhone direct-played H.264 High Level 4.0 with E-AC-3/Atmos and reached first frame. The Android phone advertised ample H.264 hardware support, but returned ERROR_CODE_DECODING_FAILED for both original HTTP and a codec-copy HLS remux. The old final fallback then re-encoded H.264 to H.264 as well as converting the audio.

That video encode did not address the observed failure and added unnecessary quality loss and compute. The deployed correction now reaches first frame as server_remux_hls with one transformation, audio_to_aac; the H.264 video is copied byte-for-byte. In media-server terms this is Direct Stream/Remux, not video transcoding.

The rule is capability-scoped rather than model-scoped: Android platform, mobile form factor, Bluetooth sink, empty passthrough set, E-AC-3, and at least six channels. It therefore covers Android mobile models reporting the same route facts. The live validation device was one Pixel 7; the test fixture uses a non-Pixel Android model to verify that planning does not depend on manufacturer or model.

Validation

Passed against current upstream main:

go test ./internal/playback -run 'Test(AndroidMobileBluetoothEAC3Fallback|AFTKRTEAC3HLSCorrection|DeviceQuirkProtocol)' -count=1
ok github.com/Silo-Server/silo-server/internal/playback 1.436s

The production fork passed its complete Go, Web, and docs GitHub Actions gates. After deployment, the live plan selected server_remux_hls, copied H.264, converted only audio to AAC, reached first frame, and stopped cycling.

Scope and risk

A working direct route is never displaced. Android TV, speaker output, stereo E-AC-3, Apple clients, passthrough-capable routes, and other codecs keep existing planning. No API, schema, migration, configuration, or Jellyfin compatibility changes are included.

Source implementation and production validation: blurbery/silo-server#51.

Related issue: N/A — narrow fix reproduced on a live deployment.

AI Disclosure

  • Tool(s): OpenAI Codex desktop
  • Model(s): gpt-5.6-sol
  • Involvement: AI-assisted; I designed the capability boundary, reviewed the implementation, compared both clients on the same source, and validated the deployed route
  • Adversarial review: Checked that direct play remains first, the fallback copies video, and the correction cannot activate for TV, speaker, stereo, passthrough-capable, Apple, or non-E-AC-3 routes. Focused positive and negative tests passed against current upstream main.

Summary by CodeRabbit

  • Bug Fixes
    • Improved playback for E-AC-3 audio on Android mobile devices connected via Bluetooth.
    • Automatically falls back to HLS with AAC audio conversion while preserving video when required.
    • Maintains expected audio behavior for speaker outputs and Android TV devices.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ea4d1291-bb7b-40b9-a11d-4cad162be415

📥 Commits

Reviewing files that changed from the base of the PR and between 87821e7 and be9e152.

📒 Files selected for processing (2)
  • internal/playback/device_quirks_v3.go
  • internal/playback/device_quirks_v3_test.go

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Adds an Android mobile Bluetooth E-AC-3 quirk. The correction applies when passthrough codecs are unavailable and audio has at least six channels. Tests verify AAC fallback behavior and excluded device outputs.

Changes

Android Bluetooth E-AC-3 fallback

Layer / File(s) Summary
Bluetooth output detection
internal/playback/device_quirks_v3.go
Adds QuirkAndroidMobileEAC3BluetoothV3 and detects Android mobile Bluetooth outputs with no passthrough codecs.
E-AC-3 correction and validation
internal/playback/device_quirks_v3.go, internal/playback/device_quirks_v3_test.go
Applies the quirk for E-AC-3 audio with at least six channels. Tests verify HLS remux with copied video and AAC audio, and exclude Speaker and Android TV outputs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to be9e1

This localized playback change preserves video while converting only E-AC-3 audio for the targeted Android Bluetooth fallback, with existing direct-play behavior retained. No actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: quick104

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preserving video during the Android EAC3 fallback in playback.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@blurbery

Copy link
Copy Markdown
Contributor Author

Related loop-hardening work: #789 and Silo-Server/silo-android#250. Those prevent false route churn; this PR preserves copied video when Android reports a real multichannel E-AC-3 Bluetooth decoder failure.

@blurbery

Copy link
Copy Markdown
Contributor Author

Closing this for now. #1938 reworked the planner around this block (it downmixes for a channel ceiling instead of transcoding video), and I can't give honest before and after evidence without retesting on a current Android build with Bluetooth audio. Main still falls back to a full transcode in this case, so playback works, just with a video re-encode it doesn't need. I'll come back either with evidence from the current Android release or with an Android-side fix that reports a two-channel ceiling for A2DP so #1938 handles it, whichever turns out cleaner.

@blurbery blurbery closed this Oct 10, 2026
@blurbery
blurbery deleted the contrib/android-mobile-eac3-direct-stream branch November 6, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant