libass / JavascriptSubtitlesOctopus

Displays subtitles in .ass format from JavaScript. Supports most SSA/ASS features, easily integrates with HTML5 videos.
MIT License
417 stars 104 forks source link

Jellyfin uses this project but some subtitles don't display #80

Closed swhoro closed 3 years ago

swhoro commented 4 years ago

image For example, in this picture, from line 27 to 47, text starts with {\fad(200,300)\be1} or {\fad(500,500)\be1\an8} will not be loaded in the video. If I delete all the text in {...} and {}, those subtitles can be loaded correctly. However, line 48 can display.

I have another ass file: image These subtitles with {...} can be displayed correctly.

Here is the issue in jellyfin:https://github.com/jellyfin/jellyfin-web/issues/2081

Yay295 commented 4 years ago

What if you remove just \be1 from those lines?

swhoro commented 4 years ago

What if you remove just \be1 from those lines?

It doesn't work. But if a delete \fad(...) in first picture, it works.

ThaUnknown commented 4 years ago

this is an issue with the font file, subtitle octopus doesnt have a good font fallback and the file you played it back on probably didint include an embedded font file at all, it's an issue with the file and not jellyfin/S.O., most likely, it could also be an issue with the chars themselves, the file itself would be nice since i cant find the release anywhere

edit: managed to find the release, seems like the subtitles are embedded in a very weird way and neither vlc or any web player picks them up

dkanada commented 4 years ago

@swhoro also note that we have a fork at JustAMan/JavascriptSubtitlesOctopus due to some changes that never got merged here, so you'd have to make the change there. We technically have an "official" fork at jellyfin/JavascriptSubtitlesOctopus but I think the former is more recent, so we should probably migrate everything into one repository at some point.

ThaUnknown commented 4 years ago

@swhoro also note that we have a fork at JustAMan/SubtitlesOctopus due to some changes that never got merged here, so you'd have to make the change there. We technically have an "official" fork at jellyfin/SubtitlesOctopus but I think the former is more recent, so we should probably migrate everything into one repository at some point.

both of those repos are private?

dkanada commented 4 years ago

I fixed the links, I haven't looked at either in months. It looks like the official one is most recent, so any pull requests should be directed here first, and then to our fork if the maintainer decides they aren't within scope.

ThaUnknown commented 4 years ago

I fixed the links, I haven't looked at either in months. It looks like the official one is most recent, so any pull requests should be directed here first, and then to our fork if the maintainer decides they aren't within scope.

oh, my bad, but this is a file issue, not a S.O. issue, but yeah, this repo is more up to date because they introduced "an api" but seems like its broken anyways

heyhippari commented 4 years ago

I think the former is more recent

jellyfin/JavascriptSubtitlesOctopus is what we use as a dependency. It's basically this repository with some rendering speed improvements (A feature we never upstreamed because the person who made it is less active these days) and without the added API (We don't need it so we never bothered to bring in the changes)

swhoro commented 4 years ago

this is an issue with the font file, subtitle octopus doesn't have a good font fallback and the file you played it back on probably did'nt include an embedded font file at all, it's an issue with the file and not jellyfin/S.O., most likely, it could also be an issue with the chars themselves, the file itself would be nice since i cant find the release anywhere

edit: managed to find the release, seems like the subtitles are embedded in a very weird way and neither vlc or any web player picks them up

So are my font files broken? But if I change the font to 宋体, which is used in second picture, in [V4+ Styles] area, the subtitle will not display too. The video (first picture) does not have embedded subtitles, ass file and video files are separated. The second picture video has embedded subtitle but only English, no Chinese. I can upload font files, video files, and ass files to google drive. If possible, could you please help me check these files? (Sorry for my poor English)

swhoro commented 3 years ago

this is an issue with the font file, subtitle octopus doesnt have a good font fallback and the file you played it back on probably didint include an embedded font file at all, it's an issue with the file and not jellyfin/S.O., most likely, it could also be an issue with the chars themselves, the file itself would be nice since i cant find the release anywhere

edit: managed to find the release, seems like the subtitles are embedded in a very weird way and neither vlc or any web player picks them up

I have tried many videos and ass recently, it seems all subtitles with {/fad(...)} will not show up in jellyfin. Unfortunately, I have deleted videos and ass files in second picture...

TheOneric commented 3 years ago

{\fad()} does work in our example file with current JSO, see eg at aroung 57s in the demo. Can you try again with somethng similar to your original subtitles and current JSO? If your logged into GitHUb you can download a nightly build here (the js Artifact near the bottom of the page): https://github.com/libass/JavascriptSubtitlesOctopus/actions/runs/1108283199

swhoro commented 3 years ago

{\fad()} does work in our example file with current JSO, see eg at aroung 57s in the demo. Can you try again with somethng similar to your original subtitles and current JSO? If your logged into GitHUb you can download a nightly build here (the js Artifact near the bottom of the page): https://github.com/libass/JavascriptSubtitlesOctopus/actions/runs/1108283199

Thanks for your reply! Unfortunately, I have deleted animes and subtitles listed in the question. But recently, when I watch gundam z with jellyfin on browser, some Japanese character(in the ass file, the Japanese font is HGMaruGothicMPRO ) will only show a square. I think this is because I don't install this font in my computer(I am a Chinese user), so I download HGMaruGothicMPRO.ttf and convert it into .woff2 and put it into font folder that jellyfin will use. And now all the Japanses character will show up. Howerver there is another question. The animation of subtitles will not show up. For example, the subtitle should move and become smaller gradually, but actually the subtitle move from one place to another place and become smaller suddenly. The subtitle animation can work well on the jellyfin app on ipad, but cannot work well ont safari(ipad), chrome(android) and chrominum edge(win11). I think this may be the same reason that cause the question I said at first? At last, I don't know how to use the js file after download it...

TheOneric commented 3 years ago

I think this is because I don't install this font in my computer

Yes, you need fonts for all glyphs. For complex typeset ASS you even need to have the exact same font available as the subtitle-author to get the intended result.

Howerver there is another question. The animation of subtitles will not show up. For example, the subtitle should move and become smaller gradually, but actually the subtitle move from one place to another place and become smaller suddenly. The subtitle animation can work well on the jellyfin app on ipad, but cannot work well ont safari(ipad), chrome(android) and chrominum edge(win11). I think this may be the same reason that cause the question I said at first?

Jellyfin uses a fork of JSO with custom patches (but and older libass). Perhaps they use different versions for the web and iOS-Frontends, or maybe the iOS-App is using libass directly without JSO as a middle layer? Can you share the subtitle file (or the relevant excerpt including headers and styles) and required fonts? Then I could test with upstream JSO and libass.

heyhippari commented 3 years ago

Jellyfin uses a fork of JSO with custom patches

We'd like to upstream these at some point, but the team member who made them went MIA about a year ago and I'm not personally sure what is and what wasn't upstreamed (And I'm not well-versed in web assembly development).

Iirc, our patches were mostly around making rendering faster for more complex animations.

I do want to use the upstream version as-is in our Vue client at some point though, so I might look into bringing them over, if #106 doesn't do so before.

ThaUnknown commented 3 years ago

this is 100% a jellyfin/font issue, I tested this aggressively when making my own version of JSO, and all glyphs worked no problem as long as the font supported them, all animations I've encountered from fansubs also seem to work

ThaUnknown commented 3 years ago

Jellyfin uses a fork of JSO with custom patches

We'd like to upstream these at some point, but the team member who made them went MIA about a year ago and I'm not personally sure what is and what wasn't upstreamed (And I'm not well-versed in web assembly development).

Iirc, our patches were mostly around making rendering faster for more complex animations.

I do want to use the upstream version as-is in our Vue client at some point though, so I might look into bringing them over, if #106 doesn't do so before.

about those changes of yours, they only seemed to benefit very low-end devices without hardware acceleration, and pre-rendering didn't work that well for files with >1k subtitles

TheOneric commented 3 years ago

We'd like to upstream these at some point, but the team member who made them went MIA about a year ago and I'm not personally sure what is and what wasn't upstreamed […]

I do want to use the upstream version as-is in our Vue client at some point though, so I might look into bringing them over, if #106 doesn't do so before.

Good to hear there's interest in (helping to) upstream the patches, not so good to hear about the MIA-part; I hope the missing member is doing well. Having the affected subs+fonts, will allow to identify whether it is an issue with the patches, and if so hopefully enable us to fix them before they get upstreamed. Or perhaps it's an old, already fixed libass bug, or something specific to jellyfin's use of JSO (I did see some code about detecting and stripping tags for some options+circumstances as part of the patches). Does the Swift iOS-app also use jellyfin's JSO or does it use (up-to-date) libass directly?

swhoro commented 3 years ago

I think this is because I don't install this font in my computer

Yes, you need fonts for all glyphs. For complex typeset ASS you even need to have the exact same font available as the subtitle-author to get the intended result.

Howerver there is another question. The animation of subtitles will not show up. For example, the subtitle should move and become smaller gradually, but actually the subtitle move from one place to another place and become smaller suddenly. The subtitle animation can work well on the jellyfin app on ipad, but cannot work well ont safari(ipad), chrome(android) and chrominum edge(win11). I think this may be the same reason that cause the question I said at first?

Jellyfin uses a fork of JSO with custom patches (but and older libass). Perhaps they use different versions for the web and iOS-Frontends, or maybe the iOS-App is using libass directly without JSO as a middle layer? Can you share the subtitle file (or the relevant excerpt including headers and styles) and required fonts? Then I could test with upstream JSO and libass.

https://1drv.ms/f/s!AmlVPwgDqKkuvjvPlDyskaUkZkOG The ttf file is the font I downloaded from Internet, and the woff2 is the file converted from ttf with a tool (https://products.aspose.app/font/zh/conversion/ttf-to-woff2). Thanks for your help.

TheOneric commented 3 years ago

@swhoro At which line or time does the issue occur for you?

swhoro commented 3 years ago

@swhoro At which line or time does the issue occur for you?

At line 362, when Japanese character in op show up

TheOneric commented 3 years ago

I can reproduce the issue with some glyphs remaining tofu, but only with the WOFF2-font; using the TTF version everything renders correctly (in both upstream and jellyfin JSO). It appears something went wrong when you converted the TTF to WOFF2; you can use the orignal TTF instead.

I cannot reproduce any animation issues in neither upstream nor jellyfin's JSO-builds using the default renderer. It may be that you're CPU (single-thread) just isn't fast enough to execute the WASM in time inside the browser, but it (barely?) works out with the iOS-app. If you/jellyfin is using the lossyRenderer which drops subtitle-frames on heavy CPU load this may be amplified.

If you think there's more to it we can reopen the issue. For now it appears to me like this is no issue with JSO or jellyfin.