jellyfin / jellyfin-androidtv

Android TV Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
2.85k stars 488 forks source link

Stereo and multichannel PCM don't passthrough correctly #1755

Open branches78 opened 2 years ago

branches78 commented 2 years ago

I've got two Android TV certified devices, the Mecool KT1 with Android 10 and the Realme 4K stick with Google TV 11, both are connected to a multichannel AV receiver.

On both devices I'm having the issue where multichannel music in the FLAC format plays correctly if the frequency and bit depth are 44.1Khz and 16 or 24 bits, however, files higher than that (I only have some in 88.2Khz and 96Khz) are not playing at all or are getting transcoded to mp3:

On the KT1 with Android 10, the 88.2Khz and 96Khz don't output audio, but the progress bar in the music player moves.

On the realme stick with Google TV 11, the 88.2Khz ones don't output audio, but the progress bar in the music player moves, while the 96Khz ones are getting downmixed to mp3.

The only reference where all these files play correctly is VLC.

FFmpeg Logs:

/audio/ae6b609a-94e6-1beb-96c3-2b0dbe345edb/stream.mp3

{"Protocol":0,"Id":"ae6b609a94e61beb96c32b0dbe345edb","Path":"D:\Musica\Musica en 5.1\C\u00E9line Dion - My Heart Will Go On (Love Theme from Titanic).flac","EncoderPath":null,"EncoderProtocol":null,"Type":0,"Container":"flac","Size":325755872,"Name":"C\u00E9line Dion - My Heart Will Go On (Love Theme from Titanic)","IsRemote":false,"ETag":"814e1de05a12dea7f8dc05af411481e2","RunTimeTicks":3107999488,"ReadAtNativeFramerate":false,"IgnoreDts":false,"IgnoreIndex":false,"GenPtsInput":false,"SupportsTranscoding":true,"SupportsDirectStream":true,"SupportsDirectPlay":true,"IsInfiniteStream":false,"RequiresOpening":false,"OpenToken":null,"RequiresClosing":false,"LiveStreamId":null,"BufferMs":null,"RequiresLooping":false,"SupportsProbing":true,"VideoType":null,"IsoType":null,"Video3DFormat":null,"MediaStreams":[{"Codec":"flac","CodecTag":null,"Language":null,"ColorRange":null,"ColorSpace":null,"ColorTransfer":null,"ColorPrimaries":null,"Comment":null,"TimeBase":"1/96000","CodecTimeBase":"1/96000","Title":null,"VideoRange":null,"localizedUndefined":null,"localizedDefault":null,"localizedForced":null,"DisplayTitle":"FLAC - 5.1","NalLengthSize":null,"IsInterlaced":false,"IsAVC":null,"ChannelLayout":"5.1","BitRate":8384966,"BitDepth":24,"RefFrames":null,"PacketLength":null,"Channels":6,"SampleRate":96000,"IsDefault":false,"IsForced":false,"Height":null,"Width":null,"AverageFrameRate":null,"RealFrameRate":null,"Profile":null,"Type":0,"AspectRatio":null,"Index":0,"Score":null,"IsExternal":false,"DeliveryMethod":null,"DeliveryUrl":null,"IsExternalUrl":null,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Path":null,"PixelFormat":null,"Level":0,"IsAnamorphic":null},{"Codec":"mjpeg","CodecTag":null,"Language":null,"ColorRange":null,"ColorSpace":"bt470bg","ColorTransfer":null,"ColorPrimaries":null,"Comment":"Cover (front)","TimeBase":"1/90000","CodecTimeBase":"0/1","Title":null,"VideoRange":null,"localizedUndefined":null,"localizedDefault":null,"localizedForced":null,"DisplayTitle":null,"NalLengthSize":null,"IsInterlaced":false,"IsAVC":null,"ChannelLayout":null,"BitRate":null,"BitDepth":8,"RefFrames":1,"PacketLength":null,"Channels":null,"SampleRate":null,"IsDefault":false,"IsForced":false,"Height":500,"Width":500,"AverageFrameRate":null,"RealFrameRate":90000,"Profile":"Baseline","Type":3,"AspectRatio":"1:1","Index":1,"Score":null,"IsExternal":false,"DeliveryMethod":null,"DeliveryUrl":null,"IsExternalUrl":null,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Path":null,"PixelFormat":"yuvj420p","Level":-99,"IsAnamorphic":null}],"MediaAttachments":[],"Formats":[],"Bitrate":8384966,"Timestamp":null,"RequiredHttpHeaders":{},"TranscodingUrl":null,"TranscodingSubProtocol":null,"TranscodingContainer":null,"AnalyzeDurationMs":null,"DefaultAudioStreamIndex":null,"DefaultSubtitleStreamIndex":null}

d:\aplicaciones\jellyfin\system\ffmpeg.exe -i file:"D:\Musica\Musica en 5.1\Céline Dion - My Heart Will Go On (Love Theme from Titanic).flac" -threads 0 -vn -ab 128000 -ac 2 -id3v2_version 3 -write_id3v1 1 -y "d:\aplicaciones\jellyfin\data\transcodes\dc0a775285c42077d30b43840ca35ac1.mp3"

ffmpeg version n4.3.2-Jellyfin Copyright (c) 2000-2021 the FFmpeg developers built with gcc 10.2.0 (Rev9, Built by MSYS2 project) configuration: --disable-static --enable-shared --cc='ccache gcc' --cxx='ccache g++' --extra-version=Jellyfin --disable-ffplay --disable-debug --enable-lto --enable-gpl --enable-version3 --enable-bzlib --enable-iconv --enable-lzma --enable-zlib --enable-sdl2 --enable-fontconfig --enable-gmp --enable-libass --enable-libzimg --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libdav1d --enable-opencl --enable-dxva2 --enable-d3d11va --enable-amf --enable-libmfx --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvenc --enable-nvdec --enable-ffnvcodec --enable-gnutls libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat 58. 45.100 / 58. 45.100 libavdevice 58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc 55. 7.100 / 55. 7.100 Input #0, flac, from 'file:D:\Musica\Musica en 5.1\Céline Dion - My Heart Will Go On (Love Theme from Titanic).flac': Metadata: replaygain_track_gain: +3.87 dB replaygain_track_peak: 0.571049 Album : Titanic (5.1) Artist : Céline Dion Genre : Soundtrack Title : My Heart Will Go On (Love Theme from "Titanic") track : 14 Date : 1997 album_artist : James Horner Duration: 00:05:10.80, start: 0.000000, bitrate: 8384 kb/s Stream #0:0: Audio: flac, 96000 Hz, 5.1(side), s32 (24 bit) Side data: replaygain: track gain - 3.870000, track peak - 0.000013, album gain - unknown, album peak - unknown, Stream #0:1: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 500x500 [SAR 96:96 DAR 1:1], 90k tbr, 90k tbn, 90k tbc (attached pic) Metadata: comment : Cover (front) Stream mapping: Stream #0:0 -> #0:0 (flac (native) -> mp3 (libmp3lame)) Press [q] to stop, [?] for help Output #0, mp3, to 'd:\aplicaciones\jellyfin\data\transcodes\dc0a775285c42077d30b43840ca35ac1.mp3': Metadata: replaygain_track_gain: +3.87 dB replaygain_track_peak: 0.571049 TALB : Titanic (5.1) TPE1 : Céline Dion TCON : Soundtrack TIT2 : My Heart Will Go On (Love Theme from "Titanic") TRCK : 14 TYER : 1997 TPE2 : James Horner TSSE : Lavf58.45.100 Stream #0:0: Audio: mp3 (libmp3lame), 48000 Hz, stereo, s32p (24 bit), 128 kb/s Metadata: encoder : Lavc58.91.100 libmp3lame Side data: replaygain: track gain - 3.870000, track peak - 0.000013, album gain - unknown, album peak - unknown, size= 256kB time=00:00:16.39 bitrate= 127.9kbits/s speed= 20x
size= 512kB time=00:00:41.59 bitrate= 100.8kbits/s speed=31.5x
size= 1024kB time=00:01:09.81 bitrate= 120.2kbits/s speed=38.3x
size= 1280kB time=00:01:37.41 bitrate= 107.6kbits/s speed= 42x
size= 1792kB time=00:02:05.40 bitrate= 117.1kbits/s speed=44.4x
size= 2304kB time=00:02:34.10 bitrate= 122.5kbits/s speed=46.4x
size= 2816kB time=00:03:02.32 bitrate= 126.5kbits/s speed=47.7x
size= 3072kB time=00:03:30.16 bitrate= 119.7kbits/s speed=48.6x
size= 3584kB time=00:03:59.01 bitrate= 122.8kbits/s speed=49.5x
size= 4096kB time=00:04:26.71 bitrate= 125.8kbits/s speed=50.1x
size= 4352kB time=00:04:52.24 bitrate= 122.0kbits/s speed=50.2x
size= 4857kB time=00:05:10.80 bitrate= 128.0kbits/s speed=50.6x
video:0kB audio:4857kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.016850%

Server System (please complete the following information):

Client System (please complete the following information):

branches78 commented 2 years ago

With the latest 10.8.1 version of the server, music is not transcoded to MP3 anymore but they get downmixed to stereo or don't play at all.

Note: L/R means that the mono channel is played on the left and right channels instead of being sent to the center channel.

Exoplayer results:

On Android 10:

image

On Android 11:

image

libVLC results:

On Android 10:

image

On Android 11:

image

branches78 commented 2 years ago

With the latest stable version 0.14.4 of the Android TV app and latest stable server 10.8.5, Exoplayer and libVLC are the same, and they improved and worsen a little bit as well.

I don't have the Android 10 device anymore so I can only share the Android 11 device's tests:

image

branches78 commented 1 year ago

With the latest stable version of the server on Windows 11 and the latest stable version of the Android TV app on Android 11, this is what currently happens when playing music with Exoplayer and libVLC, the only thing that changed is that the 192Khz resolution with 7.1 channels is playing and it's even bypassing the Android 48Khz limitation, which means, the file is playing in its highest quality available, however, this doesn't happen with the rest of the audio channels of the 192Khz resolution, the 88.2Khz and 96Khz so I guess it is something you need to look at:

image

branches78 commented 1 year ago

With new server 10.8.9 and new Android TV app 0.15.3 this is what I've got:

image

branches78 commented 1 year ago

With version 0.15.5, only the ones in green are the ones working as it should:

image

branches78 commented 1 year ago

I have now two devices to test this and compare, therefore, I'm getting the exact same results on both devices with version 0.15.6 (Homatics Box R 4K Plus with Android 11 and Realme Stick 4K with Android 11 as well), I just hope this gets resolved:

image

branches78 commented 1 year ago

The Homatics Box R 4K Plus received a firmware update as part of a beta program they are running which includes a security patch dated april 2023 which I tested with Jellyfin's 0.15.10 version and I was able to play back 5.1 and 7.1 streams in the whole range of resolutions, the ones in green are those that now play correctly, while the ones in yellow still need to be addressed, here's to hope another firmware update fixes this for good, otherwise, Jellyfin devs should address it instead:

image

Meanwhile, the Realme stick still carries the same security patch and playback remains the same as in the screenshot of the previous comment.

Dnkhatri commented 1 year ago

If I recall correctly Kodi implements its own iec packer as well the option to output raw data as android boxes do not implement audio output properly so it needs to be selected per device. I think unless similar option is added audio will likely always be a hit and miss.

jellyfin-bot commented 9 months ago

This issue has gone 120 days without comment. To avoid abandoned issues, it will be closed in 21 days if there are no new comments.

If you're the original submitter of this issue, please comment confirming if this issue still affects you in the latest release or master branch, or close the issue if it has been fixed. If you're another user also affected by this bug, please comment confirming so. Either action will remove the stale label.

This bot exists to prevent issues from becoming stale and forgotten. Jellyfin is always moving forward, and bugs are often fixed as side effects of other changes. We therefore ask that bug report authors remain vigilant about their issues to ensure they are closed if fixed, or re-confirmed - perhaps with fresh logs or reproduction examples - regularly. If you have any questions you can reach us on Matrix or Social Media.

branches78 commented 9 months ago

This issue is still as in my last comment.

jellyfin-bot commented 4 months ago

This issue has gone 120 days without comment. To avoid abandoned issues, it will be closed in 21 days if there are no new comments.

If you're the original submitter of this issue, please comment confirming if this issue still affects you in the latest release or master branch, or close the issue if it has been fixed. If you're another user also affected by this bug, please comment confirming so. Either action will remove the stale label.

This bot exists to prevent issues from becoming stale and forgotten. Jellyfin is always moving forward, and bugs are often fixed as side effects of other changes. We therefore ask that bug report authors remain vigilant about their issues to ensure they are closed if fixed, or re-confirmed - perhaps with fresh logs or reproduction examples - regularly. If you have any questions you can reach us on Matrix or Social Media.

jellyfin-bot commented 4 weeks ago

This issue has gone 120 days without comment. To avoid abandoned issues, it will be closed in 21 days if there are no new comments.

If you're the original submitter of this issue, please comment confirming if this issue still affects you in the latest release or master branch, or close the issue if it has been fixed. If you're another user also affected by this bug, please comment confirming so. Either action will remove the stale label.

This bot exists to prevent issues from becoming stale and forgotten. Jellyfin is always moving forward, and bugs are often fixed as side effects of other changes. We therefore ask that bug report authors remain vigilant about their issues to ensure they are closed if fixed, or re-confirmed - perhaps with fresh logs or reproduction examples - regularly. If you have any questions you can reach us on Matrix or Social Media.

branches78 commented 1 week ago

I just hope this gets improved because it is still the same.