jellyfin / jellyfin-webos

WebOS Client for Jellyfin
https://jellyfin.org
Mozilla Public License 2.0
638 stars 66 forks source link

Selected subtitle is not played/shown #31

Closed 1024mb closed 3 years ago

1024mb commented 4 years ago

When a video is played and a subtitle is selected the player doesn't show it (or load it? Idk), one has to choose another subtitle and then choose back the preferred subtitle again. I have only tested this with SRT subs.

Jellyfin server is 10.6.2.

naku commented 3 years ago

Same issue here. I usually choose "no subtitles", then start the video, then select the subtitle.

Also for some reason the subtitles don't show up after about 10 seconds

oddstr13 commented 3 years ago

I see I have this in my notes from testing against 10.6, but I had subs when testing with 10.7.

Are you able to test and verify this against 10.7?

anthonylavado commented 3 years ago

Closing for now. Please reopen if this still persists in 10.7, with details about the subtitle format used :-)

lorentzkim commented 2 years ago

Same issue here. I usually choose "no subtitles", then start the video, then select the subtitle.

Also for some reason the subtitles don't show up after about 10 seconds

Issue still persists for me (jellyfin server is on 10.8 alpha5, jellyfin-webos is on whatever's in homebrew channel).

What I think is happening is the stream always requests for subtitle to be extracted from the media from the server, rather than stream the subs from the file directly as you watch it. It's especially true for me because my file server is particularly slow (basically cloud storage), and extraction of subtitle always fails for me because it takes as long as it takes to download the whole video. My understanding is that subtitles are scattered all over the file, not just in the header or footer, thus takes time.

I can prove it's slow doing the subtitle extraction when I run something like /usr/lib/jellyfin-ffmpeg/ffmpeg -i /movies/some-long-bluray-vid.mkv subtitle.srt. Takes forever. I also get log entries in server log telling me:

jellyfin    | [11:28:27] [WRN] [75] MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder: Killing ffmpeg subtitle extraction process
jellyfin    | [11:28:27] [WRN] [75] MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder: Deleting extracted subtitle due to failure: /config/data/subtitles/9/9d5b9c33-17f7-2ad7-a2b5-efbcb3390608.srt
jellyfin    | [11:28:27] [ERR] [75] MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder: ffmpeg subtitle extraction failed for file:"/movies/some-long-bluray-vid.mkv" to /config/data/subtitles/9/9d5b9c33-17f7-2ad7-a2b5-efbcb3390608.srt

It probably wouldn't be a big deal if the files were truly local and the subs can be extracted in <30s, but it's not possible for me as is.

Is it not possible to tell the server to just send the subtitles directly during watching, rather than extract it first?

Informatic commented 2 years ago

Update: After investigating it a little bit further, I noticed subtitles are rendered in the app itself, and subtitles rendering was just failing to load:

Unhandled promise rejection
TypeError: Identifier 'e' has already been declared
    at new e.exports.e.exports (http://some-local-host:8096/web/3032.e0c83af25281bd04eb37.bundle.js:1:269)
    at http://some-local-host:8096/web/htmlVideoPlayer-plugin.14fba514243ce1a1ac3a.bundle.js:1:17880
    at http://some-local-host:8096/web/main.0f183787a2f78055e856.bundle.js:2:451761
    at MutationObserver.r (http://some-local-host:8096/web/main.0f183787a2f78055e856.bundle.js:2:406550)

(running on https://repo.jellyfin.org/releases/server/linux/versions/stable/web/10.7.7/jellyfin-web_10.7.7_portable.tar.gz)

...where character 1:269 would point roughly at this part:

e.exports=function(e){var t=!1;try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0))
//                                                                                                               ^

...which looks suspiciously like: https://github.com/libass/JavascriptSubtitlesOctopus/blob/d1072f35d58be1aad5acaa53373e2f651882118f/src/subtitles-octopus.js#L6

I think that part should be passed through babel as well to properly strip/rewrite const statements for use on such an old Chrome version here: https://github.com/jellyfin/jellyfin-web/blob/64fb71ee1e8440b63483c2a3bf182b19ae15c5cf/webpack.common.js#L99

This sounds like a completely different issue to the one mentioned by previous commenter.


I noticed this as well when "Direct playing" on Jellyfin 10.7.7 on webOS 3.8. (latest jellyfin-webos app from webosbrew repo)

On webOS (at least 3.8) subtitles in mkv files are not rendered, unless a call to an undocumented com.webos.media Luna (public) service is made.

HTMLVideoElement contains a non-standard/undocumented mediaId string attribute which contains internal media pipeline identifier. It then needs to be passed to luna://com.webos.media/setEnableSubtitles {"mediaId": "...","enable": true} call. Some extra methods are exposed for switching active track and customizing subtitles font/color/sizing.

Following snippet executed in Developer Toolbar console of a TV running Jellyfin shows subtitles properly with direct streaming:

webOS.service.request("luna://com.webos.media", { method: "setSubtitleEnable", parameters: { mediaId: document.querySelector('iframe').contentWindow.document.querySelector('video').mediaId, enable: true }})

Subtitles are rendered properly afterwards: capture

None of these APIs are documented publicly yet, but I can try writing up some docs about this on https://webosbrew.org and try integrating this into jellyfin-web, if this is actually considered useful. (I have no idea how subtitles extraction/rendering works in jellyfin/jellyfin-web itself, and if this is actually necessary)

Note - even though this is not documented publicly anywhere, certain third party apps on LG Content Store are already using these calls.

Informatic commented 2 years ago

So... Adding another exception (libass-wasm) in https://github.com/jellyfin/jellyfin-web/blob/64fb71ee1e8440b63483c2a3bf182b19ae15c5cf/webpack.common.js#L99 (and rebuilding) fixes the error I mentioned above - tested on jellyfin-web 1.8.0-beta1 with jellyfin server itself still running on 1.7.7 - not sure what's the official version support policy, but that combination seems to work fine.

The issue with SSA/ASS subtitles rendered by libass-wasm:

"TextTrack" subtitles (plain .srt, if i understand correctly) render fine.

ZeaKyX commented 1 year ago

@Informatic Hi, have you tested the latest version of jf? This still persists in 10.8.8 with direct playing .ass sub. When using Windows Chrome, subtitles are rendered properly. But in webos-jf, it never show up.

I want to confirm it with logs, can you show me how to get these?

After investigating it a little bit further, I noticed subtitles are rendered in the app itself, and subtitles rendering was just failing to load:

Unhandled promise rejection TypeError: Identifier 'e' has already been declared at new e.exports.e.exports (http://some-local-host:8096/web/3032.e0c83af25281bd04eb37.bundle.js:1:269) at http://some-local-host:8096/web/htmlVideoPlayer-plugin.14fba514243ce1a1ac3a.bundle.js:1:17880 at http://some-local-host:8096/web/main.0f183787a2f78055e856.bundle.js:2:451761 at MutationObserver.r (http://some-local-host:8096/web/main.0f183787a2f78055e856.bundle.js:2:406550)

dmitrylyzo commented 1 year ago

I know about that const, but subtitles-octopus.js was transpiled before, iirc, and was embedded to other module (main or htmlVideoPlayer). Maybe that was a bug of webpack (run babel on it) or I just wasn't looking hard enough.

It works as is in the webOS 1.2 emulator because the WebKit engine probably doesn't parse code at once, and that block is wrapped with try/catch.

webOS 3 is the first to use the Chrome engine, and it has a glitchy emulator, so I rarely test on it. It looks like the Chrome engine parses whole code, so it requires libass to be transpiled.

letshin commented 1 year ago

I installed Jellyfin on WebOS 3.5, and have the same issue with ASS subtitles not showing up. If I set the subtitles to be hardcoded to "Always" the video no longer runs as it says the format isn't supported.

ZeaKyX commented 1 year ago

Update: After updating jellyfin-web to the latest with commit https://github.com/jellyfin/jellyfin-web/pull/4356 , the subtitles are displayed properly. Note that the backup fonts should not be too big or too many, otherwise it will cause the problem above.