mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.69k stars 2.93k forks source link

External .vtt file subtitles are not displayed when selected #13120

Open Nicryc opened 11 months ago

Nicryc commented 11 months ago

Important Information

Reproduction steps

  1. Play a video file with mpv
  2. Add (or auto load) external subtitles in the .vtt format
  3. Subtitles aren't displayed when selected

Expected behavior

External .vtt subtitles should be displayed.

Actual behavior

External subtitles (in the .vtt format only) are not displayed when playing a video.

Note:

Log file

I detected no error message in the log file but I put it here anyway:

output.txt

llyyr commented 11 months ago

Can you provide a sample? According to the logs everything is working properly.

Nicryc commented 11 months ago

Here it is. It contains a video file and the .vtt subtitle file corresponding.

llyyr commented 11 months ago

ffmpeg doesn't support webvtt styling or tags. Open a feature request for ffmpeg.

Remuxing the video file by embedding the same .vtt file works.

Whatever program you used to remux it probably converts the vtt file into srt or ass, or just a regular webvtt without styling or tags.

Nicryc commented 11 months ago

Hmm, I used mkvtoolnix to remux it. But after what you said I reopened my remuxed video file in it and it is still detected as webvtt file, also checked in the mpv log, still detected as a webvtt. So I used mkvextract to extract the subtitle track, there is no difference between the extracted subtitle file and the original .vtt file (code diff here).

llyyr commented 11 months ago

I don't know what mkvtoolnix is doing but you can fix the file by deleting line 3 to line 81 in the sample you provided. ffmpeg isn't smart enough to ignore it

po5 commented 11 months ago

mpv does not support vtt styles. There are a lot of edge cases to deal with to allow parsers of all browsers and players to understand the files, and styling support is very hit or miss. Sections can only be styled with cue classes, despite there being a myriad of ways to target them in the spec. Styles themselves are often limited to only the color and background, despite there being more in the spec. https://www.w3.org/TR/webvtt1/

The most compatible way that I could come up with to do styling on supported systems and have others ignore it, is to make the entire STYLE section part of a NOTE. This has unsupported parsers treat "STYLE" and everything else as just part of the note text, while good parsers will notice the start of a STYLE block. To keep all data within the NOTE, there must be no empty lines.

WEBVTT

NOTE
STYLE
::cue(.signs) {
  color: black;
  background: white;
}
::cue(.title) {
  color: black;
  background: white;
}
::cue(.thoughts) {
  color: cyan;
}
::cue(.radio) {
  color: yellow;
}
::cue(.narration) {
  color: magenta;
}
::cue(.narration_off) {
  color: magenta;
}
::cue(.flashback) {
  color: yellow;
}
::cue(.character_card) {
  color: white;
  background: blue;
}

1
00:00:00.630 --> 00:00:02.300
<c.narration_off>Perceiving in a flash,</c>

2
00:00:02.630 --> 00:00:03.630
<c.narration_off>Once it starts, it won't stop!</c>

Good luck.

hydrargyrum commented 10 months ago

Is there a way to display the subtitles and just ignore the styles? --sub-ass-override=strip doesn't seem to do the trick.

neingeist commented 3 months ago

The most compatible way that I could come up with to do styling on supported systems and have others ignore it, is to make the entire STYLE section part of a NOTE. This has unsupported parsers treat "STYLE" and everything else as just part of the note text, while good parsers will notice the start of a STYLE block. To keep all data within the NOTE, there must be no empty lines.

This workaround worked for me, too. I just replaced all STYLE with NOTE\nSTYLE.