Live TV: a tuner channel's audio codec is never checked, so an undecodable soundtrack direct-plays and no transcode is ever offered
Description of the bug
For a tuner-backed Live TV channel, StreamBuilder never compares the audio codec against the client's device profile. The comparison is skipped, not failed, so the verdict comes back DirectPlay no matter what the soundtrack is, and PlaybackInfo answers with TranscodingUrl: null and TranscodeReasons: 0. A client whose profile does not list that audio codec is handed the raw stream anyway, and there is no offer of a transcode for it to fall back to.
This is invisible on almost every channel, because broadcast audio is usually AC-3 or AAC and every client lists those. It becomes visible on an ATSC 3.0 (NextGen TV) channel, whose audio is AC-4: jellyfin-ffmpeg can decode it (jellyfin-ffmpeg#387, shipped since v6.0.1-8), but the client is told to direct-play it and never sees the re-encode the server was able to offer.
The chain, read on master:
HdHomerunHost.GetMediaSourcebuilds the lineup-derived streams withIndex = -1and leavesIsDefaultunset: https://github.com/jellyfin/jellyfin/blob/master/src/Jellyfin.LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs (theMediaStreams = new MediaStream[] { ... }block)MediaSourceManager.OpenLiveStreamInternalonly probes whenMediaStreams.Any(i => i.Index != -1)is false andSupportsProbingis set, so on this path the lineup-derived streams survive as they are,IsDefaultincluded.User.PlayDefaultAudioTrackdefaults totruefor every user (Userconstructor), soSetDefaultAudioStreamIndexsetssource.DefaultAudioIndexSource |= AudioIndexSource.Default.StreamBuilder.BuildVideoItemthen narrows the candidates to default-flagged streams:candidateAudioStreams = item.MediaStreams.Where(stream => stream.Type == MediaStreamType.Audio && stream.IsDefault).ToArray();No lineup-derived stream carries that flag, so the collection is empty.StreamBuilder.GetVideoDirectPlayProfileguards the audio check on that collection:if (candidateAudioStreams.Count != 0) { ... SupportsAudioCodec ... }With it empty,AudioCodecNotSupportedcan never be raised. Containertsand the video codec pass,failureReasons == 0, and the result isPlayMethod.DirectPlay.MediaInfoHelper.SetDeviceSpecificDataonly builds aTranscodingUrlunderif (!mediaSource.SupportsDirectPlay && ...), andTranscodeReasonsis only assigned on the path that runs whenstreamInfodescribes something other than a clean direct play. So the answer carries neither.
A useful confirmation that this is the mechanism rather than a permissions problem: toggling Allow playback remuxing, Allow video transcoding and Allow audio transcoding in every combination changes nothing. Those three gate SupportsTranscoding, which is never consulted once DirectPlay has won at step 5.
The same source asked again with EnableDirectPlay: false behaves correctly: the direct-play block is skipped entirely, BuildStreamVideoItem finds no candidate with a supported codec, raises AudioCodecNotSupported, and a TranscodingUrl comes back. That is a workaround a client can implement, not a fix, because a client cannot tell "this channel genuinely direct-plays" from "the audio was never looked at".
Reproduction steps
- Set up an HDHomeRun tuner host whose lineup contains a channel with an audio codec your client's device profile does not list. An ATSC 3.0 channel (AC-4 audio) on an HDHomeRun 4K is the clearest case, since no client profile lists AC-4.
- From a client whose posted
DeviceProfilehas a videoDirectPlayProfilefor containertsthat does not name that audio codec,POST /Items/{channelId}/PlaybackInfowithAutoOpenLiveStream=true. - Read the returned
MediaSourceInfo.
An ATSC 1.0 channel from the same station is the control: it behaves identically, which is the point, its audio just happens to be decodable.
What is the current bug behavior?
The response carries TranscodingUrl: null and TranscodeReasons: 0, and the media source is marked as direct-playable, although the source's only audio stream carries a codec the posted profile does not list. The client either plays the channel silently or stalls on it, with nothing in the answer to indicate why, and no transcode offered to fall back to.
What is the expected correct behavior?
The audio codec of a tuner-derived source should be compared against the profile like any other source. When it is not supported, AudioCodecNotSupported should appear in TranscodeReasons and a TranscodingUrl should be offered, so the server can re-encode audio it can decode into something the client can play.
A minimal shape for this would be to not let the candidate narrowing produce an empty set, for example in BuildVideoItem, falling back to the selected audioStream when the filtered collection comes out empty. That keeps the preference behavior for sources with real dispositions and restores the check for sources that have none. Setting IsDefault on the lineup-derived stream in HdHomerunHost would fix the HDHomeRun case specifically, but not the same shape arriving from another tuner host.
Jellyfin Server version
Observed on 12.1.0. Every code reference above was read on master.
Environment
- Tuner: HDHomeRun 4K, ATSC 3.0 channel with HEVC video and AC-4 audio, via the HDHomeRun tuner host.
- Client: a third-party tvOS client posting a device profile whose
tsdirect-play profile listsaac,aac_latm,ac3,eac3,mp3,mp2,...and, deliberately, noac4.
Source: jellyfin/jellyfin