mpv-player/mpv

Subtitles are shown vertically reversed

Closed this issue · 14 comments

mpv version and platform

0.29.1 - arch linux

Reproduction steps

Make an SRT file where 2 lines have the same timestamp, e.g.:

1
00:00:05,213 --> 00:00:10,552
♪ SO NO ONE TOLD YOU

2
00:00:05,213 --> 00:00:10,552
LIFE WAS GONNA BE THIS WAY ♪

Expected behavior

MPV to display:
"♪ SO NO ONE TOLD YOU
LIFE WAS GONNA BE THIS WAY ♪"

Actual behavior

MPV displays:
"LIFE WAS GONNA BE THIS WAY ♪
♪ SO NO ONE TOLD YOU"
Screenshot:
image

Log file

N/A, it isn't really a logged issue.

Sample files

https://0x0.st/zxFi.srt

srt isn't supposed to have overlapping lines.

@wm4 This is the raw output from converting a vtt to srt via pycaption, so I assume this would be correct. At the very least, it should be possible to reverse the order they are shown for cases like this

There's no specification for srt, and its original use never had overlapping lines, so you get varying behavoir with different players.
mpv picks this particular behavior, because it uses libass for rendering, and ASS puts subsequents lines on top of the existing lines (or to be precise, it takes in the lines sequentially, and tries to keep the position of already existing subtitles, even if that happens at the same time stamp).

There's no specification for srt, and its original use never had overlapping lines, so you get varying behavoir with different players.
mpv picks this particular behavior, because it uses libass for rendering, and ASS puts subsequents lines on top of the existing lines (or to be precise, it takes in the lines sequentially, and tries to keep the position of already existing subtitles, even if that happens at the same time stamp).

Thanks for the information, so this would be a bug with pycaption then I suppose

Akemi commented

yeah.

Not directly, just an unfortunate choice.

You could maybe ask libass to add another displaying strategy for srt. As wm4 said, the current approach tries to not move a line that's already on screen as to maximize readability.

Hello,
I'm currently experiencing this very annoying issue, what can I do to fix it ?
Thanks

Hello, I'm currently experiencing this very annoying issue, what can I do to fix it ? Thanks

same here

Hello, I'm currently experiencing this very annoying issue, what can I do to fix it ? Thanks

same here

Hello, I'm currently experiencing this very annoying issue, what can I do to fix it ? Thanks

I was having the same issue with some "youtube-dl"ed HiDive content. I looked at the supposed fix pycaptions implemented and the subfile youtubedl was giving and realized the issue. The pycaption script was checking to fix only captions that have exactly the same start and end but HiDive's subs were slightly offset on their start times by like a millisecond, but the end times were the same.
I changed the line (in my local download of the package) in pycaption/srt.py from
if (caption.start, caption.end) == ( merged_captions[-1].start, merged_captions[-1].end):
to
if (((caption.start) == (merged_captions[-1].start)) or ((caption.end) == (merged_captions[-1].end))):
then running an ad-hoc script:

https://pastebin.com/XWuVzp8E

Produced a srt subfile that worked right. I probably won't commit my change of srt.py since I imagine it causes more issues than it fixes (I can easily imagine a scenario where it could cause it to cover the screen with subs), so you'll need to fix it yourself as well.

Hope this helped.

I've had chatgpt write the following, seems to work ok for me:
https://gist.github.com/sigio/0f8fa1a933a8afcf67b9290c1c96cd04

I've had chatgpt write the following, seems to work ok for me: https://gist.github.com/sigio/0f8fa1a933a8afcf67b9290c1c96cd04

Just wanted to let anyone searching know. I use smplayer with the mpv player and it is displaying multi-line subtitles out of order. running this python script on the subtitle file gives me a subtitle file that works correctly.

I'm having this same issue with .ass subtitles. For example, the following lines display in the wrong order:

Dialogue: 0,0:07:15.17,0:07:19.50,Default,,0,0,0,,Every person has their own unique skills,
Dialogue: 0,0:07:15.17,0:07:19.50,Default,,0,0,0,,and we can't let yours go to waste!

How to deal with MP4 and MKV without separate SRT files ? Thanks