Route multichannel FLAC to the FFmpeg decoder instead of the AOSP decoder (SHIELD) - #1720
Route multichannel FLAC to the FFmpeg decoder instead of the AOSP decoder (SHIELD)#1720sudolulo wants to merge 2 commits into
Conversation
The AOSP software FLAC decoder (c2.android.flac / OMX.google.flac) advertises multichannel support but fails at runtime with "no streaminfo metadata block", so 5.1 FLAC can't Direct Play and stalls or falls back to transcoding. Report multichannel (>2 channel) FLAC as unsupported in a MediaCodecAudioRenderer subclass so the track selector routes it to the bundled FFmpeg extension decoder, but only when the AOSP software FLAC decoder is the one that would be used, so devices with a vendor FLAC decoder, stereo FLAC, and every other format keep using the platform decoder, unchanged.
|
Could use further testing to be sure its an AOSP decoder issue and not nvidia shield specific but I don't have the hardware. In that case this could be narrowed in scope. |
|
This sounds like a device limitation. My TV plays 7.1 FLAC just fine. |
do you use an nvidia shield or other android player Does works fine mean it doesnt transcode? |
|
This definitely needs more investigation and shouldn't be applied globally for all devices. For the nvidia shield, looks like a couple people online suggest disabling Dolby Processing in the OS advanced sound settings. |
I just tried a couple of the timestamps I've been using and disabling Dolby processing in advanced settings did not change anything. The same timestamps plays fine on my debug build with this fix. I am narrowing the scope of this PR back to being just the nvidia shield 2019 non pro. |
|
The problem with multichannel FLAC is not exoplayer. It’s usually the TV’s HDMI LPCM channel limit. Exoplayer decodes FLAC 7.1 to LPCM 7.1 and if your TV does not support multichannel LPCM over HDMI, it’ll either need to be re-encoded to stereo PCM or re-encoded to AC3 to passthrough as multichannel. Few TVs support multichannel LPCM over HDMI. |
Would the fact that this is a decoder error mean it is upstream of the HDMI? Forgive me if I am incorrect. I am not swapping anything with exoplayer, I am swapping the renderer used from MediaCodecAudioRenderer to FfmpegAudioRenderer. Both then feed multichannel LPCM over HDMI is my understanding. Personally I am feeding a Denon AVR-X1800H receiver that can handle LPCM 7.1 over HDMI, and am consuming multichannel audio with this fix. |
Gate the reroute on KnownDefects.multichannelFlacBug, keyed on Build.DEVICE "sif" (the 2019 non-Pro SHIELD), instead of applying it to every device whose FLAC decoder is the AOSP software codec. Other devices decode multichannel FLAC natively and keep the platform decoder, unchanged.
|
I haven't been able to replicate the Are you able to share sample media that causes the error? |
I have a weird situation with a TCL 65C7K connected to a Onkyo TX-NR7100 via HDMI eARC. I run Wholphin directly on the TV. When I play content in Wholphin, Dolby TrueHD 5.1 tracks get sent to the receiver as "MCH PCM 5.1". So multichannel PCM via HDMI definitely works, I guess some component just doesn't support bitstreaming TrueHD which is fine for now. But when I attempt to play multichannel 5.1 FLAC, it gets cut down to "PCM 2.0" and the worst part is it isn't even downmixed, it's literally just the two front L/R streams playing as-is. I can tell because dialogue is almost inaudible (Center channel is missing) and effects are missing too (rear surround channels). What's perhaps even more weird, when I play native multichannel 5.1 PCM audio it also gets cut down to PCM 2.0 (again, no downmix, extra channels just discarded). Also when I skip the Onkyo Receiver and set playback directly to the internal speakers of the TV, I don't get the nice codec information on the receiver but I can still very clearly hear the same problem: even without the HDMI eARC and the receiver involved at all, FLAC 5.1 and PCM 5.1 get cut back to just front left and right channels being played judging from the inaudible dialogue. I have tried every decoder setting in the official Jellyfin Android TV app and in Wholphin but nothing fixes 5.1 FLAC and 5.1 PCM except the experimental setting "Prefer AC3 for Surround Sound - Always transcode non-Stereo Audio to AC3/DD". With this enabled, FLAC 5.1 and PCM 5.1 tracks play in their full "fidelity" (disregarding the fact that the codec is lossy, but no more missing channels). Is there anything I can change on the Android TV itself to better support 5.1 PCM and 5.1 FLAC playback or is it something that Wholphin has to address? EDIT: Also, im willing to help test any settings or beta builds regarding this issue. Besides the aforementioned TCL TV and the Onkyo AVR I also have a Yamaha R-N1000A stereo receiver (2.1 only!) with HDMI ARC input I could test with. |
The AOSP software FLAC decoder (c2.android.flac / OMX.google.flac) advertises multichannel support on the 2019 nvidia shield "sif" but 5.1 FLAC can't Direct Play and stalls or falls back to transcoding.
Description
This reports multichannel FLAC as unsupported in a MediaCodecAudioRenderer subclass so the track selector routes it to the bundled FFmpeg extension decoder, but only when the device is a 2019 nvidia shield non pro (sif).
Related issues
Fixes #1719
play a file with FLAC 5.1 audio on an nvidia shield and wait
Testing
Tested on my NVIDIA SHIELD Android TV 2019. I have been running this fix and it allows previously broken files to play across multiple series compared to the unmodified client. It does not alter the clients ability to play any other audio types or cause them to fall back to transcoding.
Files with multichannel FLAC audio fall back to the ffmpeg decoder while FLAC 2.0 files continue to use the default decoder. Nothing else changes.
Screenshots
no ui changes
AI or LLM usage
Diagnosis and the initial patch were assisted with AI.