jellyfin-archive / jellyfin-android-original

Android Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
272 stars 65 forks source link

Audio delay when playing with bluetooth headphones. #215

Open majerus1223 opened 4 years ago

majerus1223 commented 4 years ago

When using the app and Bluetooth headphones there is a bit of an audio delay, which causes lips not to be synchronized. This seems similar to the problems seen in Emby

https://emby.media/community/index.php?/topic/61915-audio-sync-issues-with-3010/page-1

JustAMan commented 4 years ago

Are you sure you're seeing issue caused by Jellyfin, not by Bluetooth nature of the headphones? If you use some well-known player (like MX Player for instance) with said headphones and same video file, do you experience the delay as well?

majerus1223 commented 4 years ago

Yea I am sure, as other players do not have the problem. I can try other headphones as well, but given the thread on emby, and the recent emby app updates specifically calling this out I have a feeling its not the headphones.

JustAMan commented 4 years ago

Okay, thanks for confirming. I was just ruling out the obvious first :)

majerus1223 commented 4 years ago

Totally understand, all good let me know if you want me to test something specific. The headphones I have been using are Plantronics BackBeat Fit . I can test with sony wh-1000xm3 tonight.

Xalaxis commented 4 years ago

In theory ExoPlayer should be correcting for bluetooth audio latency using https://github.com/google/ExoPlayer/blob/b5beb32618ac99adc58b537031a6f7c3dd761b9a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTrackPositionTracker.java#L172

Xalaxis commented 4 years ago

getLatency() is kind of black magic though, it's not really documented. I think Exo has other ways of tracking latency going off this issue I found: https://github.com/google/ExoPlayer/issues/5769

arantes555 commented 4 years ago

From what I know, some android apps (at least youtube and netflix) do some "magic" to automatically compensate the inevitable delay caused when using bluetooth headphones (which can have up 200/250ms delay). Some headphones even include in their technical description a feature of reporting the delay so that in can be corrected.

My thinking is, doing this kind of black magic, as Xalaxis puts it, may be a bit complicated, as I don't know any open-source video player that does it correctly.

VLC's solution is very nice though : it allows to manually set an audio delay, and when it detects that the audio output is a bluetooth device, it allows to save this delay and make it default for this device. I think a similar solution would be great for jellyfin.