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 - 2020-03-12

Yes. If this does not help -> bad luck.


RE: 2018 - Amazon Fire TV Stick 4K - jubilex - 2020-03-13

(2020-03-11, 22:28)fritsch Wrote: No. It is like it is - I don't plan to continue it, everything upstreamable is in Matrix already.

The "audio delay" for stereo that is automatically reencoded to DD+ by the firetv firmware without our influence is currently not programmatically fixable. Workarounds: enable upmix stereo in kodi, that will output multi-channel if you have it and the DD+ route is not taken. Passthrough and normal multi channel out is not affected by this firmware bug. If there is a delay for these files, it's a kodi bug / settings issue.

Ah, I thought the Fire TV builds were specifically to fix the delay. At any rate, I still have to manually offset audio .250ms for these files so I think it's time for me to switch to Rpi4. Thanks.


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2020-03-13

No, you got that wrong. "The delay" you are talking about is a firmware bug. I reported it to amazon - no feedback. There was a general delay with the old delay API that is fixed in these builds as well.

Btw. I have an idea - are you available for a test?


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2020-03-13

Building: https://jenkins.kodi.tv/job/Android-ARM/17137/
Will result here: http://mirrors.kodi.tv/test-builds/android/arm/ (named pcm16 in name) - give it one hour time.


kodi outputs stereo with 32 bit float format. Perhaps the delay is gone when we output that in 16 bit Int - you will tell us.

Here: http://mirrors.kodi.tv/test-builds/android/arm/kodi-20200313-f14b0c3e-pcm16-armeabi-v7a.apk (wait until mirror syncs)


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2020-03-14

Can someone test this: https://fritschserver.no-ip.org/owncloud/index.php/s/lKDcKdo9GJNahYE please on FireTV 4K on VLC (Desktop, FireTV) and on another Android Device. I want to find out, if we really still hunt FireTV specifics here with aac 2.0 or if entire Android is affected with that sample.


RE: 2018 - Amazon Fire TV Stick 4K - Kodroid - 2020-03-14

(2020-03-14, 07:18)fritsch Wrote: Can someone test this: https://fritschserver.no-ip.org/owncloud/index.php/s/lKDcKdo9GJNahYE please on FireTV 4K on VLC (Desktop, FireTV) and on another Android Device. I want to find out, if we really still hunt FireTV specifics here with aac 2.0 or if entire Android is affected with that sample.
Ok so here's something interesting that I stumbled upon that I need you and others on the forum to confirm to me because I am shocked that I came across it.

I got 3 samples. 1) This one, sync-aac-2.0.mkv 2)  the Pulp Fiction Hamburger scene you posted before 3) another scene from Home Alone, all with 2.0 AAC audio.

First I tried a clean install of your pcm16 Kodi, and the Fire Stick 4K's system audio settings are default aka  "Best Available"

All 3 samples on Fire TV 4K Kodi pcm16 = Delayed

Then I tried all 3 samples on Fire Stick 4K VLC 3.2.6 from the Amazon store, clean install, no settings changed:

All 3 samples on Fire TV 4K VLC = Delayed

Then I tried all 3 samples on various other devices and players. 

All 3 samples on Windows PC VLC = No Delay
All 3 samples on Windows PC with mpv = No Delay
All 3 samples on Windows PC with MPC-HC = No Delay
All 3 samples on Qualcomm-based Android phone with latest VLC = No Delay
All 3 samples on Qualcomm-based Android phone with mpv = No Delay
All 3 samples on Qualcomm-based Android phone with MXPlayer = No Delay

Therefore, the sample you wanted us to look at does not have a delay on any device except the Fire Stick 4K

But here's something shocking. I decided to try Nova Video Player from the Amazon store, no settings changed, on the Fire Stick 4K.

All 3 samples on Fire Stick 4K with Nova Video Player = No Delay!

I need somebody else to confirm my findings by seeing if there's a delay on the Fire Stick 4K with Nova Video Player. If other people can confirm my finding, perhaps fritsch can see why Nova doesn't have a delay on the 4K Stick but Kodi does. I suspect it may have to do with the fact that Nova uses brand new untouched libraries?


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2020-03-14

Can you post a Debug Log from Nova-Player? Might be yet another private workaround we don't know of.


RE: 2018 - Amazon Fire TV Stick 4K - Kodroid - 2020-03-14

(2020-03-14, 14:30)fritsch Wrote: Can you post a Debug Log from Nova-Player? Might be yet another private workaround we don't know of.
First of all, did you confirm that Nova has no delay on your 4K Stick? I might be going crazy but I just checked it again and again, no delay.

There's no way to get a debug log from Nova Player from what I can see in the settings but the source code is available. https://github.com/nova-video-player/aos-AVP


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2020-03-14

Scanning their sources right now and find may "funny" things, seems they workaround every brand out there.

Quote:  int audio_stream = AUDIO_STREAM_MUSIC;
  if(at->passthrough == 1 &&
      ( device_get_hw_type() == HW_TYPE_RK32 ||
        device_get_hw_type() == HW_TYPE_RK30 ||
        device_get_hw_type() == HW_TYPE_RK29))
    audio_stream = AUDIO_STREAM_VOICE_CALL;

so on Rockchip, you should not create MUSIC streams but voice calls :-(


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2020-03-14

Okay, got it:

Quote:  at->latency = call_static_int_method(at, at->audiosystemClass, "getOutputLatency", "(I)I", streamType);
  at->latency += (1000 * at->frame_count) / at->rate;
  at->init = 1;

See second reply: https://stackoverflow.com/questions/15802659/how-do-you-determine-the-audio-latency-audiotrack-on-android
And background from amazon: https://developer.amazon.com/de/docs/fire-tv/audio-video-synchronization.html

Kodi uses firetv's recommendation, this is what I implemented in fritschfiretv and ported to v19, but not 18.6 Leia offical: https://developer.android.com/reference/android/media/AudioTrack#getTimestamp(android.media.AudioTimestamp)
This should make the getOutputLatency obsolete.

Funny, so yeah broken firmware, let's check what amazon's exoplayer fork does:
https://github.com/amzn/exoplayer-amazon-port/blob/amazon/r2.11.3/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTrackPositionTracker.java#L236

Funny, they also use getTimeStamp, you see nicely the: AMZN_CHANGE_BEGIN + AMZN_CHANGE_END where they change something.


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2020-03-14

Will do some tests. It's totally odd to me, that their code works and mine not :-)

But before cursing at the entire world I will revisit my stuff once more and check.


RE: 2018 - Amazon Fire TV Stick 4K - jubilex - 2020-03-14

(2020-03-13, 21:15)fritsch Wrote: No, you got that wrong. "The delay" you are talking about is a firmware bug. I reported it to amazon - no feedback. There was a general delay with the old delay API that is fixed in these builds as well.

Btw. I have an idea - are you available for a test?

Right, but I thought the point of the Fire TV builds was to work around that bug by forcing the correct offset for affected audio stream types.

I can test but not sure how prompt I will be.

Also I should mention that my problem is not only with AAC. Also had it with a MOV I tried with stereo PCM, same delay. I tried one of the affected videos in Plex on the same Fire TV and it was perfectly in sync there.


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2020-03-14

Okay.


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2020-03-14

Please try: http://mirrors.kodi.tv/test-builds/android/arm/kodi-20200314-b9827109-pcm16-matrix-armeabi-v7a.apk (Warning, this is Matrix based - if it works fine - I'll do a Leia build with a backport). Jenkins needs very long to build for Leia and my time is limited, therefore I fix it on Matrix first and then cherry-pick.

On my dev system it works now™. But this is only a soundbar, please check it and see if it's any better.


RE: 2018 - Amazon Fire TV Stick 4K - fritsch - 2020-03-14

Funny and why I did not notice the bug for so long:

Multi-Channel / DTS / AC3 / DD+ look like this:
Quote:2020-03-14 22:35:03.069 T:24866   DEBUG: Delay - Timestamp: 671.4166666611447
2020-03-14 22:35:03.070 T:24866   DEBUG: HW-Delay (1): 42.0833333333519 ms
2020-03-14 22:35:03.070 T:24866   DEBUG: Combined Delay: 671.4166666611447 ms
2020-03-14 22:35:03.070 T:24866   DEBUG: Delay Current: 635.341667 ms

Stereo (including AAC):
Quote:2020-03-14 22:38:51.730 T:24866   DEBUG: Delay - Timestamp: 305.3125000000705 ms
2020-03-14 22:38:51.731 T:24866   DEBUG: HW-Delay (1): 178.47916666666563 ms
2020-03-14 22:38:51.731 T:24866   DEBUG: Combined Delay: 305.3125000000705 ms
2020-03-14 22:38:51.731 T:24866   DEBUG: Delay Current: 304.126389 ms

Long story short: I wrongly pushed the timestamp calculated getTimeStamp-Delay into our Audio-Engine. The HW-Delay you see is the difference that the TimeStamp API calculates (fritschfiretv + Matrix) in comparison to standard Kodi Leia. Means for this content (Stereo) FireTV 4K was always roughly 180 to 200 ms wrong on average (and will stay wrong on official Leia builds), depending on sample even more.


This forum uses Lukasz Tkacz MyBB addons.