Skip to content

Transcode: audio above 48 kHz is converted, and the local gate agrees with the profile - #1049

Merged
GLinnik21 merged 5 commits into
mainfrom
fix/transcode-audio-rate-48k
Oct 26, 2026
Merged

GLinnik21 merged 5 commits into
mainfrom
fix/transcode-audio-rate-48k

Conversation

@GLinnik21

@GLinnik21 GLinnik21 commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #951

PMS converted a 96 kHz FLAC to AAC and kept 96 kHz, and an LG B8 refused that Load (smp_cb type=18 num=100). Where that limit lives in the TV is not determined. 48 kHz is the highest rate any Load path here is known to accept, so audio above it is now converted, not handed over.

  • Profile: profile_for_delivery emits an audio.samplingRate upperBound of devcaps::AUDIO_RATE_CEILING (48 kHz) for every audio codec it lists. Before, only the app-decoded PCM codecs had one. Fixed HLS bounds its aac target whatever the caps say.

  • Local gate: devcaps::pcm_track_fits becomes audio_track_fits, the one rate-fit predicate, so the planner agrees with the profile on the new axis:

    • PCM codecs keep the exact pcmInfo table check;
    • every other codec passes when its rate is unstated or at most the ceiling.

    The paths that decide without PMS's /decision all go through it already: the in-place audio switch, the track menu's "converted" mark, the cold-start pick, the Detail preview and Force Direct Play. So none of them hands the TV a 96 kHz AAC.

  • DTS is exempt (devcaps::audio_rate_bounded). The app feeds only the DTS core (ff.rs dts_core_packet), which is 48 kHz at most, so a DTS-HD 96/24 track keeps direct play and its copy lane.

  • What users see: an AAC (or other non-DTS) track above 48 kHz no longer direct-plays or copies; the server converts it. Under Force Direct Play it is refused before the Load with the codec-named read-out, the way an over-wide PCM track already is.

  • Docs: prose that called the profile's audio lanes "shared with the local gate", or blamed PCM_SAMPLE_RATES for the AAC refusal, is corrected (docs/agent-reference.md included).

Verification

  • Red first: four tests failed on main (or the first commit) and pass now:
    • devcaps: a 96 kHz AAC is not admitted, DTS is exempt;
    • route: a 96 kHz AAC is converted by the paths that skip /decision;
    • plan: it is not direct-played in Auto or Forced;
    • transcoder: every codec is bounded, and the profile and the local gate agree.
  • Crate suites:
    • plx_platform: test result: ok. 290 passed; 0 failed
    • plx_plex: test result: ok. 735 passed; 0 failed
    • plx_media: test result: ok. 1754 passed; 0 failed; 64 ignored
  • Not verified:
  • No TV run, no FFI change.

🤖 Generated with Claude Code

GLinnik21 and others added 2 commits October 26, 2026 03:20
PMS converts a 96 kHz FLAC to AAC and keeps 96 kHz, and an LG B8 refuses
that Load (`smp_cb type=18 num=100`). The profile bounded
`audio.samplingRate` only for the app-decoded PCM codecs, so the server
was free to hand the pipeline any rate on every other codec.

libpf's rate vocabulary stops at 48 kHz (`devcaps::PCM_SAMPLE_RATES`,
read from libpf-1.0 on the B8). The one samplingRate limitation loop in
`profile_for_delivery` now covers every codec of the transcode target
audio list (ac3, eac3, aac, dca, opus, as the caps allow) as well as the
PCM codecs, from the same ceiling, so PMS converts a wider track instead
of delivering a rate the pipeline refuses. The PCM clause is unchanged.

The assumed-caps golden string gains the three new clauses, as its own
comment prescribes for a deliberate profile edit.

Closes #951

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…empt (#951)

The first commit asked PMS for audio.samplingRate <= 48000 on every
transcode target audio codec, but the app's own gate only checked the rate
of PCM (FLAC) tracks. Every path that decides without PMS's /decision --
the in-place audio switch (commit_audio_route -> NativeAudioReload),
legacy_action, retarget_audio, the track menu's "converted by your server"
mark, audio_intent_needs_conversion, pick_audio, classify_outcome --
therefore still direct-played a 96 kHz AAC, the Load an LG B8 refuses.

C. devcaps::pcm_track_fits is now devcaps::audio_track_fits, the one
rate-fit predicate. PCM codecs keep the exact-table check; every other
codec passes at an unstated rate (0) or at most AUDIO_RATE_CEILING (48 kHz).
plex::is_dp_audio_track and the planner's audio_direct_plays_with already
called it, so no call site is new; Force Direct Play applies it as it
applies the PCM limits (a 96 kHz AAC is refused, not failed at the Load).
The profile's samplingRate clauses and the predicate read the same
audio_rate_bounded set and the same ceiling.

B. DTS (dca) is not bounded: the app feeds only the DTS core
(ff.rs dts_core_packet), 48 kHz at most by format, so bounding it would
push DTS-HD 96/24 sources that play today into a lossy AC-3 conversion.
Opus, AC-3 and E-AC-3 are 48 kHz at most by format, so their bound is a
no-op, kept so "every codec but DTS" stays the one rule.

D. The prose no longer claims libpf's pcmInfo rate table is why a >48 kHz
Load is refused; that table is the pcmInfo lookup and the AAC Load carries
no rate. The measured fact is: an LG B8 refused a 96 kHz AAC Load (#951,
smp_cb type=18 num=100); where the limit lives is not determined, and 48 kHz
is the highest rate any Load path here is known to accept. Prose that
described the profile and the gate as sharing only membership and channel
bounds (devcaps, transcoder, plan, decision, agent-reference) now names
the rate axis.

The fixed-HLS target's aac bound no longer depends on aac being in the
caps: the target codec list is per delivery.

Effect: a source above 48 kHz in AAC (or any non-DTS codec) loses direct
play and copy and is converted by the server; DTS is unaffected.

Verification: the profile bound was NOT verified against PMS for a source
above 48 kHz. On the configured PMS, as seen by the Guest account, no audio
stream above 48 kHz turned up among the items probed (the ten titles whose
default track is TrueHD or DTS-HD MA, per stream; the rest of the movie and
show libraries by default codec only). The wire syntax is confirmed: the
decision endpoint answers 200 to the profile with and without the clause,
and a 48 kHz AAC item stays "copy" either way. Whether PMS converts a 96 kHz
source down to 48 kHz on this clause is requested but not yet verified.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21 GLinnik21 added bug Something isn't working playback Playback, the player and its controls labels Oct 26, 2026
GLinnik21 and others added 2 commits October 26, 2026 12:39
…ate-48k

# Conflicts:
#	rust-modules/media/src/route/decision.rs
#	rust-modules/media/src/route/plan.rs
#	rust-modules/platform/src/devcaps.rs
#	rust-modules/plex/src/plex/transcoder.rs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit 659542b into main Oct 26, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the fix/transcode-audio-rate-48k branch October 26, 2026 10:00
GLinnik21 added a commit that referenced this pull request Oct 26, 2026
audio_converted_by_server reads the attempt since S2b; the merged #1049 test still used the
three-argument form.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working playback Playback, the player and its controls

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server-converted audio keeps a 96 kHz source rate, and the TV refuses the AAC Load

1 participant