mpv icon indicating copy to clipboard operation
mpv copied to clipboard

Some lines are missing in LRC lyrics/subtitles during playback

Open oldherl opened this issue 1 year ago • 5 comments

Important Information

Provide following Information:

  • mpv version
mpv v0.37.0 Copyright © 2000-2023 mpv/MPlayer/mplayer2 projects
 built on Jan 19 2024 09:09:45
libplacebo version: v6.338.2
FFmpeg version: n6.1.1
FFmpeg library versions:
   libavutil       58.29.100
   libavcodec      60.31.102
   libavformat     60.16.100
   libswscale      7.5.100
   libavfilter     9.12.100
   libswresample   4.12.100
  • Platform and Version: see above
  • Source of the mpv binary: Arch Linux
  • If known which version of mpv introduced the problem: no
  • GPU model, driver and version: not relevant
  • Possible screenshot or video of visual glitches mpv_lrc_bug

Reproduction steps

mpv 宁夏.mp3

with 宁夏.lrc (the LRC lyrics) attached below. (renamed to txt due to github requirement) 宁夏.lrc.txt

Wait the playback to reach 00:01:41, or use keys to locate to that timestamp.

Expected behavior

In the LRC file:

[02:51.14][02:40.09][01:41.17][01:29.59]知了也睡了
[02:54.31][02:42.79][01:44.12][01:32.66]安心的睡了

Those two lines should be displayed at 01:41.17 minus 500ms (offset) and 01:44:12 minus 500ms.

Actual behavior

Those two lines are missing. In fact, all the lyrics between 01:41 and 02:28 are missing. Lyrics before 01:41 and after 02:28 are working properly.

Log file

output.txt

Sample files

LRC file is attached above. MP3 file is irrelevant to this issue as it could be reproduced with any audio file, given renamed to the same basename as the LRC file.

oldherl avatar Feb 17 '24 12:02 oldherl

I always assumed this was unimplemented in ffmpeg. What I do with those files is regenerate them with ffmpeg, and it splits lines with multiple timestamps. If you use https://github.com/guidocella/mpv-lrc you can just press alt+o.

guidocella avatar Feb 17 '24 12:02 guidocella

I always assumed this was unimplemented in ffmpeg. What I do with those files is regenerate them with ffmpeg, and it splits lines with multiple timestamps. If you use https://github.com/guidocella/mpv-lrc you can just press alt+o.

I was thinking about the same, but I realised that in the LRC file, there are other lines with multiple timestamps which are working properly. Also, if I use ffmpeg -i 宁夏.lrc 宁夏.srt to convert the LRC to SRT, the resulting SRT shows all the multiple timestamps are recognised without issue.

oldherl avatar Feb 17 '24 12:02 oldherl

Yeah I thought it only displayed the first line until now but it seems random. Of [03:05.79][02:45.74][01:48.67][01:35.53]在我心里面宁静的夏天 it shows the one at 1:48.

Edit: Now I can no longer reproduce this and it shows it at 1:35.

Edit 2: You should only see the line you decode first which changes based on where you seeked.

guidocella avatar Feb 17 '24 13:02 guidocella

ffplay -vf subtitles=foo.lrc shows these correctly so it's an mpv bug.

guidocella avatar Feb 17 '24 13:02 guidocella

So this is caused by https://github.com/mpv-player/mpv/blob/98005003da2d644f9f58f4e51df8bdd03b5e26e5/sub/sd_ass.c#L369-L393 using packet->pos to check if a packet was already seen, but we need to compare a different field to treat these packets as not seen once for every timestamp they appear at. From 2c7db48195: "Fix this by not clearing the list, and instead explicitly rejecting duplicate packets. We use the packet file position as a unique ID for subtitles; this is confirmed working for most file formats (although it is slightly risky - new demuxers may not necessarily set the file position to something unique, or at all)." We can probably use packet->pts.

guidocella avatar Feb 17 '24 15:02 guidocella