jellyfin-androidtv icon indicating copy to clipboard operation
jellyfin-androidtv copied to clipboard

Android TV App doesn't support HDR

Open fuzzynet opened this issue 5 years ago • 126 comments

The Android TV app on my Shield TV will direct play my 4k movies, but doesn't enable HDR. The same movie will enable HDR on the emby app.

fuzzynet avatar Feb 20 '19 15:02 fuzzynet

This is not enhancement, is a bug. Basically every 4k video has HDR and this makes those videos unwatchable, eg. washed out...

nextlooper42 avatar Sep 27 '19 16:09 nextlooper42

Since HDR support requires backend changes in addition to major front end changes to work, it is an enhancement and not a bug.

HDR support isn't magicaly included without us having to put in effort. It's a deliberate feature addition since currently, almost none of the JF stack is HDR capable (with 10.4.0 we have put one of a few required backend changes for HDR into place).

Given that Emby appears to still be shipping ffmpeg 4.0.*, they arent HDR capable anywhere in the stack either.

sparky8251 avatar Sep 27 '19 18:09 sparky8251

I get that. Just saying that JF should be developed with HDR and possible future "enhancements" in mind, that includes newer/current ffmpeg (nightly is now running on 4.0.2, which is quite old) to support features that matter in that time, not to be stuck in past.

Stop thinking about Emby (i hate that name), JF should be better than that :D

nextlooper42 avatar Sep 27 '19 23:09 nextlooper42

@nextlooper42 The good news is - we've updated our core server code to use either 4.0.x or 4.1, and work is ongoing for 4.2. We are thinking about it - it's just a matter of time.

anthonylavado avatar Sep 28 '19 02:09 anthonylavado

If I'm not mistaken, the nightly docker uses ffmpeg 4.2. But yeah, we have started with HDR support at ffmpeg (the absolute bottom of the stack).

If I'm not mistaken, @vitorsemeano has been working on HDR playback support (by moving to exoplayer) in web and/or android, but it's not going to land in 10.4.z since it still needs work.

We are getting there, slowly but surely. It's just a LOT of work to add in HDR support :)

sparky8251 avatar Sep 28 '19 12:09 sparky8251

Just wanted to check in here since Jellyfin uses ffmpeg 4.2.1 now. Hopefully this comment will stop more people from asking constantly.

viggy96 avatar Jan 05 '20 03:01 viggy96

HDR support should work in the app after #244 is merged as exoplayer 2 supports it.

nielsvanvelzen avatar Jan 05 '20 09:01 nielsvanvelzen

I built and installed the Android TV app yesterday, and while it plays HDR content, it does not properly display the HDR colours. This is most likely due to the server detecting that the video codec is not compatible, and the server is transcoding the file, when its not necessary. The file in question is HEVC, Main 10 profile, yuv420p10le pixel format.

viggy96 avatar Feb 04 '20 20:02 viggy96

I have the same problem as @viggy96 Files are transcoded when they should be able to be direct played.

cschlesselmann avatar Feb 05 '20 17:02 cschlesselmann

Is this another bug? Media being transcoded when it shouldn't be?

viggy96 avatar Feb 06 '20 02:02 viggy96

@nielsvanvelzen @thornbill I don’t know how you’d like to organize this one. I’ve stuck it in 0.11.1 for now, but move if needed.

anthonylavado avatar Feb 06 '20 05:02 anthonylavado

I spend about 2 hours debugging this issue and it needs quite a lot of changes to get it working properly.

Currently a lot of magic happens to determine support for various codecs. In the end most of it is hardcoded and doesn't really ask the OS if it supports everything. Next up, the logic is split and duplicated in multiple locations making it very hard to fix.

My conclusion in the end is that the whole ProfileHelper class needs to be rewritten to fix this issue.

I'll remove it from 0.11.1 but won't add it to 0.12.0 because I don't know if I or someone else wants to work on this.

nielsvanvelzen avatar Feb 06 '20 09:02 nielsvanvelzen

Is ExoPlayer capable of tonemapping HDR for SDR displays? Could AndroidTV profiles default to HDR support and then allow ExoPlayer to tonemap the video?

brianclinkenbeard avatar Feb 08 '20 09:02 brianclinkenbeard

@nielsvanvelzen can you catch me up on what you've found? I can start digging on the backend to figure out what needs to be done

Artiume avatar Feb 08 '20 22:02 Artiume

@Artiume it's been a few days but basically while testing no matter what I did (even when changing the profiles to allow everything to direct play) the server would transcode. It used different reasons like codecs not supported etc. (I suspect these come from the app side). When transcoding though, even when HDR profiles are specified it would always convert video to SDR. (yuv444 to yuv420)

I tested it on my Philips TV that has HDR support.

nielsvanvelzen avatar Feb 09 '20 09:02 nielsvanvelzen

IIRC, the video Transcoder is currently hard coded to force ffmpeg to do 8bit. Ffmpeg's default is to maintain the original bitrate. My thought is that maybe the original dev's couldn't get the builder to build correctly with a dynamic bitrate coming from ffmpeg.

Here's where I breakdown the state builder, I haven't flushed out the ffmpeg flags yet though https://github.com/jellyfin/jellyfin-docs/issues/202#issuecomment-583200809

Is that what happens when you disable the user from allowing to transcode or you mess with the client profile?

Here's the transcode and streaming logic https://github.com/jellyfin/jellyfin-docs/issues/202#issuecomment-580867893

Artiume avatar Feb 09 '20 14:02 Artiume

IIRC, the video Transcoder is currently hard coded to force ffmpeg to do 8bit.

So we need a backend update to get HDR working when transcoding?

Is that what happens when you disable the user from allowing to transcode or you mess with the client profile?

I changed the client code to allow the codecs used in my HDR test file.

nielsvanvelzen avatar Feb 09 '20 16:02 nielsvanvelzen

So we need a backend update to get HDR working when transcoding?

Yes, hdr transcoding is the holy grail. For now, direct play is the goal.

I changed the client code to allow the codecs used in my HDR test file.

Disable the permissions to transcode/remux and see what you get (ensure it direct plays, check to make sure no ffmpeg logs are generated). If you get a black screen, either there's libs missing in AndroidTV or the TV doesn't support the file.

Here's a good read for tone mapping control with ffmpeg. https://web.archive.org/web/20190722004804/https://stevens.li/guides/video/converting-hdr-to-sdr-with-ffmpeg/

Artiume avatar Feb 09 '20 17:02 Artiume

I spend about 2 hours debugging this issue and it needs quite a lot of changes to get it working properly.

Currently a lot of magic happens to determine support for various codecs. In the end most of it is hardcoded and doesn't really ask the OS if it supports everything. Next up, the logic is split and duplicated in multiple locations making it very hard to fix.

My conclusion in the end is that the whole ProfileHelper class needs to be rewritten to fix this issue.

I'll remove it from 0.11.1 but won't add it to 0.12.0 because I don't know if I or someone else wants to work on this.

If this wont be solved then jellyfin will be a no go for many users. In plex (shield 2019) works perfect with exo player.

I tried both libvlc and exoplayer, and hdr files (mkv h265, 4k) are played correctly only if you dont use switch refresh rate. If you use refresh rate switch, they switch from 4k to 720p but with correct hdr color space (hdr mode activated on tv). I think there is hope to make this work

yanakis71 avatar Feb 24 '20 12:02 yanakis71

@Artiume it's been a few days but basically while testing no matter what I did (even when changing the profiles to allow everything to direct play) the server would transcode. It used different reasons like codecs not supported etc. (I suspect these come from the app side). When transcoding though, even when HDR profiles are specified it would always convert video to SDR. (yuv444 to yuv420)

I tested it on my Philips TV that has HDR support.

On shield pro 2019 mkv hdr 4k is working with direct play using libvlc, video stream is displayed correctly at 60hz. Refresh rate option makes it switch to 720p, but still with correct colors. So, it is partially working. I am willing to further test, just send some other scenarios. Regards

yanakis71 avatar Feb 24 '20 12:02 yanakis71

AFAIK, modifying the profiles probably won't get you anywhere as of now until we make backend cognizant of hdr. Disabling backend from transcoding is what I wanted to verify that if the profiles were correct, the client would handle hdr. For your Philips TV, what client was used? Glad to see hdr was working on your shield.

Artiume avatar Feb 24 '20 12:02 Artiume

AFAIK, modifying the profiles probably won't get you anywhere as of now until we make backend cognizant of hdr. Disabling backend from transcoding is what I wanted to verify that if the profiles were correct, the client would handle hdr. For your Philips TV, what client was used? Glad to see hdr was working on your shield.

I forgot to mention that I also disabled transcoding.Thanks.

yanakis71 avatar Feb 24 '20 13:02 yanakis71

If this wont be solved then jellyfin will be a no go for many users. In plex (shield 2019) works perfect with exo player.

We are definitely aware that HDR compatibility is an issue, but solving this is a big undertaking (read: lots and lots of developer hours) and very likely will not make it into the 0.12 release.

In general, improving playback is very high up on our list of features we (or in this case @nielsvanvelzen) would like to work on though :)

AndreasGB avatar Feb 24 '20 21:02 AndreasGB

Another issue for us as devs is hardware. I don't know if anyone even has hdr capability so a lot of us work off theory to add support

Artiume avatar Feb 24 '20 21:02 Artiume

I greatly respect and appreciate your work, I suppose it takes a lot of hours put in but just keep in mind we do live in hdr era, bluray rips, etc. So keep this feature close to your priorities. It does work to some extent, but it also can be perfect :). Keep up the good work guys, excelent job! If you want me to help you with hdr testing, let me know. I have a shield tv pro 2019, a Sony Android TV, oneplus 7 phone, unraid nas, omv nas, windows 10 machine.

Kind regards

yanakis71 avatar Feb 24 '20 22:02 yanakis71

I would also be happy to help testing. I have a Shield TV 2019 and a LG C9 OLED TV. Currently i work around this issue by creating a samba share of my media and directly watching HDR content through the vlc app over smb.

cschlesselmann avatar Feb 25 '20 07:02 cschlesselmann

I would also be happy to help testing. I have a Shield TV 2019 and a LG C9 OLED TV. Currently i work around this issue by creating a samba share of my media and directly watching HDR content through the vlc app over smb.

You can use the Android client with libvlc player but make sure you disable transcoding on the server side

yanakis71 avatar Feb 25 '20 09:02 yanakis71

@yanakis71 I know, but i need transcoding enabled when im not watching something on the tv. Or is there an option to disable transcoding for specific clients/ips?

cschlesselmann avatar Feb 25 '20 09:02 cschlesselmann

Not sure, I will test with transcoding also but with libvlc.

yanakis71 avatar Feb 25 '20 09:02 yanakis71

Thanks for the offers of helping to test things, we will gladly come back to you on it when it is time :)

AndreasGB avatar Feb 25 '20 13:02 AndreasGB