theothernt / AerialViews

A screensaver for Android TV devices including Nvidia Shield, Fire TV, and Chromecast with Google TV. Inspired by Apple TV's video screensaver.
GNU General Public License v3.0
418 stars 32 forks source link

HDR Playback issue on Philips TV #26

Open Plazzmex opened 2 years ago

Plazzmex commented 2 years ago

Hey,

I'm trying to understand why my Philips tv doesn't play the HDR Videos. I have the Philips Android TV model PUS8505 from last year.

  1. The TV spec sheet says that it supports all the HDR formats and video formats including Dolby Vision, hdr10, hdr10+, hlg and vp9, avc and hevc codecs.

  2. Netflix and other apps shows Dobly vision content perfectly and the TV shows a notification that Dolby vision is being used.

  3. In the debug section of the app everything shows as True, but the HDR Videos are still black screen. The debug screen also shows that my tv is at 1080p at 60hz, maybe it has something to do with this? Although it is a 4k screen and as mentioned earlier Other video apps do support 4k content with Dolby Vision.

  4. I've tested both the 1080p HDR stream and 4k HDR stream and both get black screen instead of the video and no Dolby vision notification is shown

Is there anything else that can be done? Or am I doomed to use SDR ?

Regards

theothernt commented 1 year ago

Here is the beta version which includes the option to enable the fix for Philips TV.

Look in Settings > Troubleshooting

(this version also contains auto refresh rate switching, which also has to be enabled by the user)

(link removed)

theothernt commented 1 year ago

Has anyone had a chance to try the v.1.4.1 beta 1? 😅

bdwixx commented 1 year ago

Has anyone had a chance to try the v.1.4.1 beta 1? 😅

I figured you might want someone else to confirm that this workaround works which i why i didnt respond, but for me everything works.

matfax commented 1 year ago

I confirm that Dolby is now recognized by OLED805. The only issue I notice is some aliasing (presumably) with the small text in particular. Might be shadow or border but the white content isn't coherent. It also happens without the Philips option and without HDR, so I'm not sure if it's related.

PXL_20230327_142748174 MP

theothernt commented 1 year ago

I confirm that Dolby is now recognized by OLED805. The only issue I notice is some aliasing (presumably) with the small text in particular. Might be shadow or border but the white content isn't coherent. It also happens without the Philips option and without HDR, so I'm not sure if it's related.

Thank you @bdwixx and @matfax for confirming. Do you both see this text aliasing issue?

EDIT: Any idea what year these TVs are? 2019, 2020?

This issue was reported in another thread so I don't funny understand the cause. In the meantime, I'll probably add options to change text size, thickness and the font.

bdwixx commented 1 year ago

I confirm that Dolby is now recognized by OLED805. The only issue I notice is some aliasing (presumably) with the small text in particular. Might be shadow or border but the white content isn't coherent. It also happens without the Philips option and without HDR, so I'm not sure if it's related.

Thank you @bdwixx and @matfax for confirming. Do you both see this text aliasing issue?

It looks a little weird for me too but only until the dolby vision logo disappears, then it looks normal, and it doesnt happen on sdr videos, however im running unreleased? (the comments say no one got it through ota) android 11 firmware.

20230328_031316 (The image here looks like its compressed or something but this is actually what it looks like.) 20230328_031318

EDIT: Any idea what year these TVs are? 2019, 2020?

I have a 2019 tv. The 2019 (model no. ends in 4), and 2020 (ends in 5) philips android tvs all use the same firmware(and the same soc too i believe).

EDIT: I took screenshots and the text looks fine there... (The colors are fine irl.)

screen1 screen2

matfax commented 1 year ago

2020 has the aliasing both on Android 9 and unreleased 11, like it's rendered on a low resolution. And it stays after the Dolby logo disappears. The only moment when it seems to be fine is when I press the back button to cancel the screensaver, for a very brief moment it changes the text view before the complete view is destroyed. Moreover, during initialization, the aliasing also seems to shift for a very brief moment, though not including any accurate text view.

It also happens when I disable the Dolby notification all together.

theothernt commented 1 year ago

2020 has the aliasing both on Android 9 and unreleased 11, like it's rendered on a low resolution. And it stays after the Dolby logo disappears. The only moment when it seems to be fine is when I press the back button to cancel the screensaver, for a very brief moment it changes the text view before the complete view is destroyed. Moreover, during initialization, the aliasing also seems to shift for a very brief moment, though not including any accurate text view.

Text can only be rendered up to 1080p, like the rest of the UI, but video can go a lot higher - 4K in your case.

I'm not sure there anything I can do about other than give the user the option to change the font, size, weight, etc - which should be available in a release or two.

matfax commented 1 year ago

I see. It's not important anyway. Thanks for the effort to make Dolby work.

theothernt commented 1 year ago

Aerial Views v1.4.1 is out with the fix so I'll close this issue.

Thanks again to @bdwixx for the fix - and @Plazzmex, @finnzz, @matfax for your help and suggestions over the past... checks notes... year and a half!

Plazzmex commented 1 year ago

Hey,

sorry I couldn't chime in to test when you asked, haven't been able to.

But now I've tried with the latest 1.4.2 version from the play store, and it works when playing from the online source BUT it still the same problem when using the SMB feature, shows loading and nothing happens. :/

theothernt commented 1 year ago

But now I've tried with the latest 1.4.2 version from the play store, and it works when playing from the online source BUT it still the same problem when using the SMB feature, shows loading and nothing happens. :/

Ah! there might be a fix for this, let me look into it.

theothernt commented 1 year ago

Ok, think I figured out the issue but I'll need confirmation... (link removed)

bdwixx commented 1 year ago

Ok, think I figured out the issue but I'll need confirmation... (link removed)

I was also clearing the mediaurl in the finally block, the one you commented out should be removed altogether

theothernt commented 1 year ago

I was also clearing the mediaurl in the finally block, the one you commented out should be removed altogether

When I tested clearing the mediaUrl in the finally block, playback fails - although I was testing in the simulator which can be a little flaky with SMB. Does it work when you remove it?

UPDATE: Same behaviour on the Google TV.

bdwixx commented 1 year ago

I was also clearing the mediaurl in the finally block, the one you commented out should be removed altogether

When I tested clearing the mediaUrl in the finally block, playback fails - although I was testing in the simulator which can be a little flaky with SMB. Does it work when you remove it?

UPDATE: Same behaviour on the Google TV. I think the fix is to not clear the mediaUrl in the finally block but playback fails if I remove it. Could there be a race condition with mediaUrl when using SMB playback?

Just so that i understand, playback fails if the mediaurl is not set to null anywhere or only in the finally block?

theothernt commented 1 year ago

Just so that i understand, playback fails if the mediaurl is not set to null anywhere or only in the finally block?

Playback fails when I remove mediaurl = null from the finally block.

UPDATE: I added more logging, things are a bit clearer...

  1. The Factory fails to create an instance due to an exception
  2. Finally block sets mediaUrl to null
  3. Factory is called again and creates default instance, which is why playback will work but DV playback will fail on a Philips TV.

UPDATE: Looks like it's an issue with the MediaExtractor, it will only handle local or HTTP streams. Looks like SmbDataSource will have to be adapted to work with it.

bdwixx commented 1 year ago

Looks like it's an issue with the MediaExtractor, it will only handle local or HTTP streams. Looks like SmbDataSource will have to be adapted to work with it.

Dang. That seems like a massive undertaking. It might be more realistic to append the extra bytes mediaextractor creates to the exoplayer ones, its probably not a great solution so if we can figure it out you should only use this for smb. Here is an example of the extra csd-0 bytes for a dv mov file: '00 00 00 01 7c 01 01 05 07 00 00 00' I think this is only dovi metadata. I know some are dv level, profile, compatibility level, but i dont know what 7c is for example. i have found this (page 19), but i dont know how i could figure out which byte is which.

EDIT: Honestly the 7c must be the 'descriptor_length', right? The rest i could figure out with trial and error on random dovi videos. I'll look more into it later.

theothernt commented 1 year ago

Dang. That seems like a massive undertaking. It might be more realistic to append the extra bytes mediaextractor creates to the exoplayer ones, its probably not a great solution so if we can figure it out you should only use this for smb. Here is an example of the extra csd-0 bytes for a dv mov file: '00 00 00 01 7c 01 01 05 07 00 00 00' I think this is only dovi metadata. I know some are dv level, profile, compatibility level, but i dont know what 7c is for example. i have found this (page 19), but i dont know how i could figure out which byte is which.

EDIT: Honestly the 7c must be the 'descriptor_length', right? The rest i could figure out with trial and error on random dovi videos. I'll look more into it later.

After some more research, and what you've said above, I see a couple of options (correct me if I'm wrong)...

  1. Write a MediaDataSource which only has a couple of methods to implement, plus I can use most of the code from SmbDataSource.

  2. In SmbDataSource when the Dolby fix is needed, alter the byte stream from there. Looking at the logs, the SmbDataSource is called 3 times during normal playback - one of those must be by the default MediaExtractor

bdwixx commented 1 year ago

I did some research into those bytes and this is what I found: Extra csd-0 from a Blu-ray remux:

00 - padding 00 - padding 00 - padding 01 - DV version (afaik there is only v1) 7c - not sure what this is but it was always this value 01 - BL flag (indicates whether track if base layer, only relevant for dual track dv(profile 7), for which i don't think this setup would work for anyway) 01 - RPU flag (indicates whether there is dv metadata, 1 unless first track of dual track dovi) 08 - DoVi profile (we already know this from ExoPlayer) 06 - DoVi level (we already know this from ExoPlayer) 00 - padding 00 - padding 00 - padding

Its possible the BL and RPU are swapped, but it shouldn't matter for this. I also did test for dv compatibility id and it doesn't show up in the csd0. The 'el_present_flag' is something I wasn't able to test for but I believe that is only present in profile 7 videos, and would likely play back correctly if the decoder ignores it. I tested many of the apple videos, Blu-rays and WebDLs, I feel fairly confident that these are correct. 'configuration.format' inside 'PhilipsMediaCodecAdapterFactory' has a 'codecs' field formatted like this that contains dv profile and level: hev1.08.06. If you feel comfortable building the bytes according to this, then I can make actual code for it if you'd like, although the custom MediaDataSource would definitely be better, but its also harder.

theothernt commented 1 year ago

If you feel comfortable building the bytes according to this, then I can make actual code for it if you'd like, although the custom MediaDataSource would definitely be better, but its also harder.

If you'd like to write some code based on the method above, I would be interested to try it!

In the meantime, I have done a little work on making a SambaMediaDataSource for the MediaExtractor. It's not working yet as I have to refactor the the SambaDataSource to use/re-use a single connection. From what I can see, the MediaExtractor creates more than one instance of the SambaMediaDataSource so the underlying SMBJ library throws concurrency errors.