ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

FireTV Audio Sync Issue

Open fougere-mike opened this issue 10 years ago • 5 comments

Hi all,

Let me start by saying I realise the amazon Fire TV / Fire TV Stick are not supported by ExoPlayer -- this post is really just to pick the brains of some ExoExperts™ so that I have a better chance of fixing it myself.

The issue I'm seeing is that the Fire TV becomes out of sync by ~100ms after playing for around an hour. Initially, the audio sync is fine (~30-40ms), but it drifts as time goes on. The same stream, with the same version of ExoPlayer appears to work fine on a Nexus Player (and all other devices I've tested).

A few of my users have noticed this and become quite unhappy. I'd like to address the issue myself if possible, but I'm not sure exactly how the Fire TV differs from, say, a Nexus Player. I'm also not sure how ExoPlayer handles audio sync in general, or why it may fail over time on a Fire TV.

Any input / suggestions as to how I can begin debugging this would be greatly appreciated!

Note: I'm using a Syncheck 3 to verify the a/v sync at various playback intervals, so I'm able to get fairly precise readings.

fougere-mike avatar Jan 27 '16 23:01 fougere-mike

ExoPlayer synchronizes everything based on the platform's reported audio track position. This is retrieved through AudioTrack.getTimestamp, or (less good) AudioTrack.getPlaybackHeadPosition if AudioTrack.getTimestamp isn't available. If A/V sync is gradually lost, the most likely cause is that the device is reporting an audio track position that's slowly drifting relative to what's actually being played, so that eventually the reported positions are wrong enough for the user to notice the loss of sync.

One workaround you could try is to modify this method to always return false:

https://github.com/google/ExoPlayer/blob/master/library/src/main/java/com/google/android/exoplayer/audio/AudioTrack.java#L1175

That would disable the use of AudioTrack.getTimestamp and force ExoPlayer to go through the legacy path of using AudioTrack.getPlaybackHeadPosition instead, which might help if the first one drifts but the second one doesn't. If that doesn't work, it feels like something that would be hard to fix other than directly in the OS.

Please report back with any findings!

ojw28 avatar Jan 28 '16 15:01 ojw28

Thanks for the reply. This week's been busy for me, but I'm hoping to try this out early on Monday and report back.

fougere-mike avatar Jan 29 '16 21:01 fougere-mike

I've tried the suggested change; it seemed to have no effect. However, it appears the issue exists only on the fire tv set top boxes; the fire tv streaming stick stays in sync. Based on that, it really does seem like a hardware issue.

fougere-mike avatar Feb 02 '16 16:02 fougere-mike

You could try to use Fire TV's port of Exoplayer from here https://github.com/amzn/exoplayer-amazon-port . This may solve the issue.

srikieonline avatar Apr 19 '16 00:04 srikieonline

We do not recommend use of the Amazon port. At this stage pure ExoPlayer should work on the majority of FireOS devices, except for certain specific use cases (e.g. if you're using PlayReady). The Amazon port is likely to lag behind pure ExoPlayer, and we do not vouch for the quality of the changes made there (as an example, there's one change merged into the port that we explicitly rejected from ExoPlayer because it didn't look like a good idea).

ojw28 avatar May 22 '16 23:05 ojw28