Kodi Community Forum
2018 - Amazon Fire TV Stick 4K - Printable Version

Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Discussions (https://forum.kodi.tv/forumdisplay.php?fid=222)
+--- Forum: Hardware (https://forum.kodi.tv/forumdisplay.php?fid=112)
--- Thread: 2018 - Amazon Fire TV Stick 4K (/showthread.php?tid=336151)



RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2019-12-05

Hint: https://github.com/fritsch/xbmc/commit/a87ca43ab857e9eb28db7cf8839bc97be5d34789 - I will check if I can use a different Android API to get this specific value out there. Sadly amazon themselves tell to use a "private API" - I hope for the best.


RE: 2018 - Amazon Fire TV Stick 4K - Kodroid - 2019-12-05

(2019-12-05, 15:28)fritsch Wrote:
(2019-12-05, 04:00)Kodroid Wrote:
(2019-11-27, 07:58)wizziwig Wrote: Is there some way to automate that delay so it only applies to stereo and not other files?  I only noticed it on stereo aac so far. 
Looks like we will just have to wait for the firmware fix, it if ever happens.  

Yes. That's what I did in those firetv builds. But as this is a "special device hack", I won't push that into Kodi. Why device hacks are evil we currently see with the amlogic clibber workaround code, that breaks modern Cube, which is also amlogic driven, which btw. shows again: Chip vendor has the standard conform code, box sellers sadly have no interest at all to fix their firmware ... 
Does the stereo audio delay bug happen in Amazon's own VOD offerings or just Kodi? There's plenty of Amazon content with a stereo track. If so, there may still be hope.


RE: 2018 - Amazon Fire TV Stick 4K - Kodroid - 2019-12-05

(2019-12-05, 15:29)fritsch Wrote: Hint: https://github.com/fritsch/xbmc/commit/a87ca43ab857e9eb28db7cf8839bc97be5d34789 - I will check if I can use a different Android API to get this specific value out there. Sadly amazon themselves tell to use a "private API" - I hope for the best.
Has anybody tried contacting the Product Manager for FireTV about this issue? He's very chatty on reddit and Twitter.
https://old.reddit.com/user/esaba
https://twitter.com/Elias
esaba.com


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2019-12-05

(2019-12-05, 18:10)Kodroid Wrote:
(2019-12-05, 15:29)fritsch Wrote: Hint: https://github.com/fritsch/xbmc/commit/a87ca43ab857e9eb28db7cf8839bc97be5d34789 - I will check if I can use a different Android API to get this specific value out there. Sadly amazon themselves tell to use a "private API" - I hope for the best.
Has anybody tried contacting the Product Manager for FireTV about this issue? He's very chatty on reddit and Twitter.
https://old.reddit.com/user/esaba
https://twitter.com/Elias
esaba.com 
Try it, but don't feel sad afterwards :-)

You could ask something like: What's the standard Android method to query AudioTrack in order to find out the processing delay of their internal stereo to dd encoder? And why they did not expose it via the normal AudioTrack delay API.


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2019-12-05

(2019-12-05, 18:05)Kodroid Wrote:
(2019-12-05, 15:28)fritsch Wrote:
(2019-12-05, 04:00)Kodroid Wrote: Looks like we will just have to wait for the firmware fix, it if ever happens.  

Yes. That's what I did in those firetv builds. But as this is a "special device hack", I won't push that into Kodi. Why device hacks are evil we currently see with the amlogic clibber workaround code, that breaks modern Cube, which is also amlogic driven, which btw. shows again: Chip vendor has the standard conform code, box sellers sadly have no interest at all to fix their firmware ...    
Does the stereo audio delay bug happen in Amazon's own VOD offerings or just Kodi? There's plenty of Amazon content with a stereo track. If so, there may still be hope.   

It seems they use "custom workarounds" to measure this delay. 

The issue basically has zero to do with kodi. It's quite simple: Their AudioTrack implementation is wrong, it only tells the buffers written into the sink, but don't say anything about the delay of their pipeline ... the workarounds they describe are meant to be called only _once_ in 10 seconds ... imagine a video player that is up to 10 seconds off sync ...

Edit: amazon also maintains an own exoplayer fork - if you find time, check these sources.

See: https://developer.amazon.com/de/docs/fire-tv/audio-video-synchronization.html#22-getplaybackheadposition-api-level-3


RE: 2018 - Amazon Fire TV Stick 4K - noggin - 2019-12-06

(2019-12-05, 21:02)fritsch Wrote:
(2019-12-05, 18:10)Kodroid Wrote:
(2019-12-05, 15:29)fritsch Wrote: Hint: https://github.com/fritsch/xbmc/commit/a87ca43ab857e9eb28db7cf8839bc97be5d34789 - I will check if I can use a different Android API to get this specific value out there. Sadly amazon themselves tell to use a "private API" - I hope for the best.
Has anybody tried contacting the Product Manager for FireTV about this issue? He's very chatty on reddit and Twitter.
https://old.reddit.com/user/esaba
https://twitter.com/Elias
esaba.com   
Try it, but don't feel sad afterwards :-)

You could ask something like: What's the standard Android method to query AudioTrack in order to find out the processing delay of their internal stereo to dd encoder? And why they did not expose it via the normal AudioTrack delay API.  
<Off topic>
I may ask him why Amazon market Fire TV devices as being compatible with their HD Music service (which streams FLAC lossless compressed 44.1/16, 44.1/24 and 96/24 audio) when it's all encoded to DD+ with lossy compression on output in the Fire TV...

Amazon Fire TV audio output is not well implemented is it...


RE: 2018 - Amazon Fire TV Stick 4K - wizziwig - 2019-12-06

(2019-12-05, 15:29)fritsch Wrote: Hint: https://github.com/fritsch/xbmc/commit/a87ca43ab857e9eb28db7cf8839bc97be5d34789 - I will check if I can use a different Android API to get this specific value out there. Sadly amazon themselves tell to use a "private API" - I hope for the best.

Is the correct latency 300 ms?  I thought it was closer to 150-175?  Is there an apk available with your workaround commit that I can test on my Fire Stick 4K?  Thanks.


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2019-12-06

All ARM builds with name "fritschfiretv" have this integrated. (Btw. this build is anyways only relevant if you have turned on DolbyDigital+ or "Best" in _android's_ firetv settings), if this is forced to Stereo only, no issue.

I am currently trying to get this delay computed "dynamically" by using the timestamp API, let's see: https://github.com/fritsch/xbmc/commits/timestamp (have it nearly working) - if this method does also _not_ show us the additional delay, we will return our FireTV sticks ;-)


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2019-12-06

Quote:2019-12-06 20:49:30.474 T:29428  NOTICE: Head-Position 1479168 Timestamp Position 1470175 Delay-Offset: 187.354 ms
2019-12-06 20:49:30.475 T:29428  NOTICE: HW-Delay (1): 0.187354
2019-12-06 20:49:30.475 T:29428  NOTICE: Delay Current: 130.365278
2019-12-06 20:49:30.540 T:29428  NOTICE: Delay Current: 119.269444
2019-12-06 20:49:30.541 T:29428  NOTICE: Framecounter: 1473322 Time: 1048306589149711 Current-Time: 1048306590688019
2019-12-06 20:49:30.542 T:29428  NOTICE: Delay - Timestamp: 323.979 (ms) delta: 2.13515 (ms) playtime: 30696.3 (ms) Duration: 31020.3 ms
2019-12-06 20:49:30.543 T:29428  NOTICE: Head-Position 1482240 Timestamp Position 1473424 Delay-Offset: 183.667 ms
2019-12-06 20:49:30.543 T:29428  NOTICE: HW-Delay (1): 0.183667
2019-12-06 20:49:30.544 T:29428  NOTICE: Delay Current: 125.240278
2019-12-06 20:49:30.603 T:29428  NOTICE: Framecounter: 1473322 Time: 1048306589149711 Current-Time: 1048306652561942
2019-12-06 20:49:30.603 T:29428  NOTICE: Delay - Timestamp: 302.417 (ms) delta: 63.7991 (ms) playtime: 30758 (ms) Duration: 31060.4 ms
2019-12-06 20:49:30.603 T:29428  NOTICE: Head-Position 1485312 Timestamp Position 1476384 Delay-Offset: 186 ms
2019-12-06 20:49:30.603 T:29428  NOTICE: HW-Delay (1): 0.186
2019-12-06 20:49:30.604 T:29428  NOTICE: Delay Current: 122.677778
2019-12-06 20:49:30.605 T:29428  NOTICE: Framecounter: 1473322 Time: 1048306589149711 Current-Time: 1048306654948173
2019-12-06 20:49:30.607 T:29428  NOTICE: Delay - Timestamp: 338.917 (ms) delta: 67.3968 (ms) playtime: 30761.6 (ms) Duration: 31100.5 ms
2019-12-06 20:49:30.607 T:29428  NOTICE: Head-Position 1485312 Timestamp Position 1476557 Delay-Offset: 182.396 ms
2019-12-06 20:49:30.607 T:29428  NOTICE: HW-Delay (1): 0.182396
2019-12-06 20:49:30.608 T:29428  NOTICE: Delay Current: 132.915278

I think I have it:
The delay I compute ontop is around: 0.182396 seconds, e.g. 182 ms.

Now, if we check the same with DTS:
Quote:2019-12-06 20:52:48.001 T:29428  NOTICE: HW-Delay (1): 0.0581875
2019-12-06 20:52:48.002 T:29428  NOTICE: Delay Current: 575.288889
2019-12-06 20:52:48.008 T:29428  NOTICE: Framecounter: 432403 Time: 1048503259921492 Current-Time: 1048504057984184
2019-12-06 20:52:48.008 T:29428  NOTICE: Delay - Timestamp: 646.563 (ms) delta: 798.386 (ms) playtime: 9806.77 (ms) Duration: 10453.3 ms
2019-12-06 20:52:48.008 T:29428  NOTICE: Head-Position 473088 Timestamp Position 470725 Delay-Offset: 49.2292 ms
2019-12-06 20:52:48.009 T:29428  NOTICE: HW-Delay (1): 0.0492292
2019-12-06 20:52:48.009 T:29428  NOTICE: Delay Current: 583.111111
2019-12-06 20:52:48.015 T:29428  NOTICE: Framecounter: 432403 Time: 1048503259921492 Current-Time: 1048504064702108
2019-12-06 20:52:48.015 T:29428  NOTICE: Delay - Timestamp: 650.5 (ms) delta: 805.112 (ms) playtime: 9813.5 (ms) Duration: 10464 ms
2019-12-06 20:52:48.015 T:29428  NOTICE: Head-Position 473088 Timestamp Position 471048 Delay-Offset: 42.5 ms
2019-12-06 20:52:48.015 T:29428  NOTICE: HW-Delay (1): 0.0425
2019-12-06 20:52:48.015 T:29428  NOTICE: Delay Current: 593.777778
2019-12-06 20:52:48.022 T:29428  NOTICE: Framecounter: 432403 Time: 1048503259921492 Current-Time: 1048504071531338
2019-12-06 20:52:48.022 T:29428  NOTICE: Delay - Timestamp: 654.271 (ms) delta: 812.011 (ms) playtime: 9820.4 (ms) Duration: 10474.7 ms
2019-12-06 20:52:48.022 T:29428  NOTICE: Head-Position 475136 Timestamp Position 471379 Delay-Offset: 78.2708 ms
2019-12-06 20:52:48.022 T:29428  NOTICE: HW-Delay (1): 0.0782708
2019-12-06 20:52:48.022 T:29428  NOTICE: Delay Current: 590.222222

We see that the HW-delay is "neglegtable" around max 78 ms, but most of the time around 45 ms, which can be further tuned.

Nice. I will create a test image.


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2019-12-06

Testbuild is here: http://mirrors.kodi.tv/test-builds/android/arm/kodi-20191206-77028a88-timestamp-armeabi-v7a.apk (mirror will need to sync a bit)

If you have suggestions to this PR, two things are conditionally mandatory:
a) uncut Debug Log (always) - I don't run behind "me too" people
b) If you think delay is totally fucked up in comparison to normal Leia, turn on Component Logging for Audio (only the audio component) additionally to a), reproduce the issue, post the log. Component Logging will fill your logfile quite heavily, therefore take care to only reproduce and post.


RE: 2018 - Amazon Fire TV Stick 4K - wizziwig - 2019-12-07

(2019-12-06, 23:07)fritsch Wrote: Testbuild is here: http://mirrors.kodi.tv/test-builds/android/arm/kodi-20191206-77028a88-timestamp-armeabi-v7a.apk (mirror will need to sync a bit)

If you have suggestions to this PR, two things are conditionally mandatory:
a) uncut Debug Log (always) - I don't run behind "me too" people
b) If you think delay is totally fucked up in comparison to normal Leia, turn on Component Logging for Audio (only the audio component) additionally to a), reproduce the issue, post the log. Component Logging will fill your logfile quite heavily, therefore take care to only reproduce and post.

Crashes and exits while loading kodi home screen on a clean install on Fire Stick 4K. Will post logs once I figure out how to enable them without Kodi GUI access.


RE: 2018 - Amazon Fire TV Stick 4K - A600 - 2019-12-07

@fritsch. I compiled your branch for Leia: https://github.com/fritsch/xbmc/tree/timestamp and, so far, it seems that audio sync issues are fixed for me.
Previously, I always had the issue no matter what audio settings I chose on Kodi or the FireTV with the all audio formats and I had to rely on the latency advanced setting.


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2019-12-07

Funny - curious. A fully clean install with entire kodi userdata files whiped?

Works on my spare stick - I whiped it completely and installed the build.


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2019-12-07

(2019-12-07, 12:48)A600 Wrote: @fritsch. I compiled your branch for Leia: https://github.com/fritsch/xbmc/tree/timestamp and, so far, it seems that audio sync issues are fixed for me.
Previously, I always had the issue no matter what audio settings I chose on Kodi or the FireTV with the all audio formats and I had to rely on the latency advanced setting.

Cool - please reply on my pull request on github. Btw. timestamp branch is Leia based - I don't want to bother users with testing master if it's not needed.


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2019-12-07

@wizziwig  I found the issue. The Audiotrack Pause call is not yet exception safe. I pinged @peak3d to get this missing exception into libandroidjni. I will create you a build that uses stop instead of pause for probing. Stay tuned.

For the record: https://github.com/xbmc/libandroidjni/pull/18

Next upcoming timestamp build will work for you, too.


This forum uses Lukasz Tkacz MyBB addons.