jellyfin-kodi icon indicating copy to clipboard operation
jellyfin-kodi copied to clipboard

Video starts playing right away, but subtitles take a few seconds to load

Open oddstr13 opened this issue 4 years ago • 12 comments

Seeking back to the start of the file once subtitles does load gives subtitles for the initial section also.

This may be an issue with how Jellyfin feeds us the data.

oddstr13 avatar Jul 06 '19 01:07 oddstr13

I have this same issue, and it only happens when using Kodi + Jellyfin as a client. Web and Android app work fine. Video starts playing immediately but subs take ~5-10 seconds to load on a direct stream. If I pause the video and wait the 10 seconds, the subs appear after resuming.

Jellyfin 10.3.7 (Official Docker Container) Kodi 18.3 and 18.4 Jellyfin Kodi Addon 0.2.1 Tested on: ASS and PGS subtitle filestypes in MKV containers. Both experience the delay.

Not sure what else I can share to help,

mothe avatar Sep 02 '19 05:09 mothe

I don't think this is a bug, more like how we expected it to behave... at least in web ui. So that playback starts as fast as it can, and subtitles show when they're ready after extraction.

JustAMan avatar Oct 08 '19 15:10 JustAMan

That can't be expected behaviour. That's like audio starting to play a few seconds before the video is ready.

I would rather wait an extra couple of seconds for subtitles to load properly, or at least have a config switch for it, if this is indeed a intentional choice

oddstr13 avatar Oct 09 '19 18:10 oddstr13

I am also having this issue, but only when using Kodi as a client. Web player and Android app work fine, as does direct playing the mkv container in Kodi via SMB. The loading delay only seems to happen with Jellyfin + Jellyfin-Kodi. This would have to be an issue with the Jellyfin server though, right? Isn't this addon just building a local database of media served by Jellyfin, and Kodi is handling all of the streaming/decoding?

EDIT: After digging through the logs a bit, I think I found something that might point in the right direction. Media was started at 22:00:00

2019-12-07 22:00:00.587 T:6240  NOTICE: JELLYFIN.entrypoint.default -> INFO::resources\lib\entrypoint\default.py:52 path: ?[REDACTED].mkv params: {
                                                "dbid": "290", 
                                                "filename": "[REDACTED].mkv", 
                                                "mode": "play", 
                                                "id": "[REDACTED]"
                                            }

but the subtitle stream didn't start until almost 5 seconds later

2019-12-07 22:00:04.488 T:5504  NOTICE: JELLYFIN.player -> INFO::resources\lib\player.py:161 Setting audio: 1 subs: 2
2019-12-07 22:00:04.495 T:8124  NOTICE: Closing stream player 3
2019-12-07 22:00:04.497 T:8124  NOTICE: Opening stream: 2 source: 256

Looks like there was some major restructuring of the Emby plugin for possibly the same issue: https://github.com/MediaBrowser/plugin.video.emby/commit/ae3ac121ce57fb81c6c49459c197889570cd3376

leftl avatar Dec 08 '19 04:12 leftl

Also having such issue, with latest version of everything. Furthermore unburned, srt subtitles will desync at some point when transcoding [ unsure if it's related to hw accelerated transcoding, as I'm not using unaccelerated one at all ]

barolo avatar Mar 20 '20 12:03 barolo

Can confirm the problem still exists. Subtitle is delayed for about 5 seconds after video and audio already started playing.

Tested using a 1080p mkv with H264 (Bitrate: 2700 kb/s) and AAC, Subtitle format: SRT Also tested using ASS/SSA: same behavior as with SRT. Mode used: Direct play Connection is a dedicated LAN connection (1 Gbits).

Problem does not occur when playing the file directly from a Samba share. Problem does not occur on native Jellyfin-Android app and Webplayer. (Mode: Direct play)

OS: LibreELEC 9.2.5 (Kodi 18.8) HW: Rasberry Pi 4 (2GB) Jellyfin Addon version: 0.5.9+py2 Jellyfin Server: 10.6.4

flashkiller999 avatar Sep 12 '20 21:09 flashkiller999

Think I've tracked this delay down to set_audio_subs() in player.py. Looks like subtitles actually start on video playback as expected, then effectively get reloaded, thus the visible delay.

All my subtitles are embedded, so I don't know how external subs work here, but commenting out the call to set_audio_subs() seems to fix this for me.

snortwolf avatar Jan 08 '21 19:01 snortwolf

I still haven't experience this personally, but from what you've said it seems as though it's (yet another) race condition. I wonder if there would be a way to sync the external subs locally instead of needing to request them from the server.

mcarlton00 avatar Jan 09 '21 17:01 mcarlton00

So, the issue here seems to be a combination of a few things;

  • Kodi is not skipping back in a mkv to find the relevant chunk of subtitle data, nor keeping all subtitles in memory.
  • Neither we nor Kodi are checking if the requested track is the one already selected, thus discarding the subtitle data already loaded in memory. (I'm unsure if we have access to the information required to check this on our end)
  • The subtitle track is changed after the video has started playing. (even if it is to the one we where already playing)

Subtitle data is tiny compared to audio and video data. When you change the audio track, the video will skip forward a little bit (a few frames it looks like), until Kodi finds another block of audio from the wanted track. This is not done for subtitles, and it isn't desirable to do so either, as subtitles aren't there all the time.

Depending on whether the Jellyfin server actually provides any useful information on which track to use or not (it's possible it could potentially be storing the selected track between plays, or between episodes), the solution could indeed be to just remove that call to set_audio_subs().

oddstr13 avatar Feb 01 '21 08:02 oddstr13

Just wanted to mention that Im also experiencing this issue. Its most noticeable in anime, (Jap Audio, Eng Subtitles) For about 10-20 seconds after a video loads up subtitles are not visible. If I pause and wait till they show up it seems to be fine. I haven't noticed any other issues but it would be nice to get this fixed.

jasonmbrown avatar Aug 09 '21 07:08 jasonmbrown

Still experiencing this as well, in the exact same way as previously described.

Weevild avatar Jun 15 '22 11:06 Weevild

Really annoying, and definitely still happening.

NCLI avatar Jan 04 '23 12:01 NCLI