xbmc / xbmc

Kodi is an award-winning free and open source home theater/media center software and entertainment hub for digital media. With its beautiful interface and powerful skinning engine, it's available for Android, BSD, Linux, macOS, iOS, tvOS and Windows.
https://kodi.tv/
Other
18.49k stars 6.3k forks source link

ASS Subtitles embedded in MKV files not being rendered correctly #21625

Open jmaeshawn opened 2 years ago

jmaeshawn commented 2 years ago

Bug report

Describe the bug

Here is a clear and concise description of what the problem is:

I have long had an issue with Kodi not properly playing mkv files that have .ass subtitles muxed into the file. My two problems with subtitles are as follows: Problem 1: When playing an episode of a series (it can be any episode) the dialogue font is displayed 2-3 times larger than it is supposed to be, and can sometimes cause the text to cover half the screen or more, depending on the length of the line. The problem does not occur when I play the same file in mpv or any other player that uses mpv as the renderer.

Problem 2: With a certain episode of a different series, the video plays and the subtitles render in the size they are expected to be. However, none of the lines of the subtitles disappear when they're supposed to and will stay on the screen the entire episode, causing the screen to become more and more crowded with text the longer the episode plays. However, the bug only seems to occur when the episode is first launched from the Kodi library. If I launch the episode and just let it play, the subtitles will not vanish when they are supposed to. But if I launch the episode, then use the 10 or 30 second skip back to the beginning of the episode, the subtitles will then appear and disappear when they are supposed to. As with the previous problem, this issue does not occur when playing the same episode in mpv or and other mpv-based player.

Expected Behavior

Here is a clear and concise description of what was expected to happen:

For the episode of the first series I described, the subtitles for the dialogue should be rendered and displayed in the proper size, just as they are when the episode is played in mpv here: First Series Played in mpv

For the episode of the second series I described, the lines of the subtitles should vanish when the line ends and not continue to remain on the screen for the entire episode. Example of how it is supposed to look from when I played it in mpv: Second Series Played in mpv

Actual Behavior

For the episode of the first series, it displays the dialogue font in an incorrect size, to the point where the single line can often cover up half the screen. Example of how it looks when played in Kodi: First Series Played in Kodi

For the episode of the second series, none of the subtitle lines disappear when they are supposed to, and subtitle lines that are commented off in the .ass file are also displayed when they should not be. Example of how it looks when played in Kodi: Second Series Played in Kodi

Possible Fix

I once had to report a similar bug to another project called smplayer (the bug report from which is located here https://github.com/smplayer-dev/smplayer/issues/234 ) The issue ended up being a Windows-specific problem with the version of mpv the author was using having the subtitle bug, while a newer version of mpv did not have that bug. The problem was solved by the author updating the program to be based on the newer version of mpv.

To Reproduce

Steps to reproduce the behavior:

Play this file in Kodi for the first problem: File with Example of Problem 1

And play this file in Kodi for the second problem: File with Example of Problem 2

Debuglog

The debuglog can be found here: debuglog

Screenshots

Here are some links or screenshots to help explain the problem:

I posted screenshots in the above example of the issue.

Additional context or screenshots (if appropriate)

Here is some additional context or explanation that might help:

Your Environment

Used Operating system:

note: Once the issue is made we require you to update it with new information or Kodi versions should that be required. Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.

fuzzard commented 2 years ago

You would be best to retry with one of the nexus nightlies (or Alpha 1 potentially).

The subtitle system had a massive rework in v20, and i dont believe castagna has much desire to look at v19 sub issues.

jmaeshawn commented 2 years ago

You would be best to retry with one of the nexus nightlies (or Alpha 1 potentially).

The subtitle system had a massive rework in v20, and i dont believe castagna has much desire to look at v19 sub issues.

At fuzzard's suggestion, I tried testing the same two videos with v20 Alpha 1. The font size issue I had in the first video seems to have been fixed. :)

However, the second video still had subtitle problems (albeit to a lesser degree than in v19). Example: This screeenshot

The lines that are supposed to display now appear and disappear when they are supposed to. But there are still 4 lines that show up, even though they don't when played in mpv.

When I looked more closely at the .ass subtitle file contained in the mkv, it appears the problem is that the lines in question are set to display from 0:00:00 to 0:00:00. mpv doesn't display these lines, but Kodi v20 seems to display them for random lengths of time instead.

For reference, here are the four lines of the subtitle file that display for random lengths of time instead of displaying for 0 seconds. Dialogue: 0,0:00:00.00,0:00:00.00,DCMain,CONAN,0000,0000,0000,,[ed] Dialogue: 0,0:00:00.00,0:00:00.00,DCMain,KOGORO,0000,0000,0000,,[eyecatch] Dialogue: 0,0:00:00.00,0:00:00.00,DCMain,,0000,0000,0000,,Detective Conan Episode 1047 "The \NRed Sheep's Eerie Game (Part One)" Dialogue: 0,0:00:00.00,0:00:00.00,DCMain,CONAN,0000,0000,0000,,[op]

(And I understand that the subtitle lines should be commented out rather than set to display for 0 seconds, but I didn't make these, and Kodi should still be able to take these types of goofy situations into account so it can be able to render these types of lines properly, the way mpv does.)

jmaeshawn commented 2 years ago

As a followup, I just tried it in the latest nightly build (KodiSetup-20220629-30fb576e), and the subtitle lines that are set to display for 0 seconds no longer show up, the same way mpv does.

I guess that means this bug has already been fixed. Thanks! :)

enen92 commented 2 years ago

Yes unfortunately as the changes are too drastic we won't be able to backport to matrix, so you'll have to wait until v20 is final. If you don't mind sticking with alphas, current nightlies are pretty stable.

jmaeshawn commented 2 years ago

Sorry for reopening this issue so soon after closing it, but it seems I jumped the gun a bit. When I installed the latest nightly of v20 on my pc as a portable to test, those four 0-second lines didn't show up, so I thought the issue was already solved.

However, when I went and installed the same v20 nightly build on my living room HTPC, I discovered that those lines still show up. So I think it's probably still a good idea to look into this.

CastagnaIT commented 2 years ago

i tried both sample files but to me on Kodi 20 Windows build are both displayed correctly

jmaeshawn commented 2 years ago

i tried both sample files but to me on Kodi 20 Windows build are both displayed correctly

Here's an updated debuglog from the latest v20 nightly build: debuglog And some new screenshots of the issue when played on that build: 1 - ed line 2 - eyecatch line 3 - episode info line 4 - op line

The 4 lines I copied above seem to show up progressively over the first 10 or so seconds of the episode, when they should not show up at all because they are set to display for 0 seconds.

In the case of the 3rd and 4th screenshots, you can also see how the line with the episode information is causing the "Beppu Ryota" character card to be positioned too high, because it should look like this (played in mpv): Properly displayed line

CastagnaIT commented 2 years ago

ah now understand if i load the sub externally this problem not occours if i use the embedded one the problem occours

CastagnaIT commented 2 years ago

The decoder for some reason return always the duration of the first event that have a duration

https://github.com/xbmc/xbmc/blob/20.0a1-Nexus/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecSSA.cpp#L106

in this case 2350000 of (Mori Detective Agency) event line @enen92 if im not wrong this is decoded by ffmpeg library i dont know if we can do something

enen92 commented 2 years ago

Hum Yeap, likely fixed by https://github.com/FFmpeg/FFmpeg/commit/29412821241050c846dbceaad4b9752857659977 but we are stuck on an older version

CastagnaIT commented 1 year ago

tested again "case 2" unfurnately there are no big improvements on ffmpeg5

nothing we can fix here, the problem should be reported to ffmpeg library

enen92 commented 1 year ago

Do we have a sample for this?

CastagnaIT commented 1 year ago

@enen92 the sample is is the Issue above download the "problem 2" (case 2)

enen92 commented 1 year ago

I've submitted http://ffmpeg.org/pipermail/ffmpeg-devel/2023-January/305512.html as a possible fix (companion ffmpeg trac issue: https://trac.ffmpeg.org/ticket/10135). Thanks @tmm1 for the help with the submission process. Let's see

github-actions[bot] commented 3 months ago

This issue is now marked stale because it has been open over a year without activity. Remove the stale label or add a comment to reset the stale state.