mpv-player / mpv

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

Improve detection/filtering of predefined YouTube subtitles in particular cases #11675

Open JoseHidalgo opened 1 year ago

JoseHidalgo commented 1 year ago

Hi. This can be either a question or a feature request. Here's an example to illustrate things.

In this YT video for example, if you want to access the (apparently only) available english predefined subtitles, they are named en-en-nP7-2PuUI7o(see attached screenshot), and they are #45 on a list of more than 200 subtitles. I know other videos with similar naming issues.

Here's my current Windows command line: mpv https://www.youtube.com/watch?v=dfnCAmr569k --slang=en --ytdl-raw-options=ignore-config=,sub-lang=en,write-sub=,write-auto-sub=

I have tried to find a correct syntax for sub-lang. Unfortunately it seems that wildcards such as sub-lang=en* are not supported at this time. See this past issue: https://github.com/mpv-player/mpv/issues/8518

Hence my question: is there any way to improve such Windows command line and get the wanted english subtitles easily without cycling through more than 200 subtitles? Otherwise I'd like to make a feature request so that MPV can be improved accordingly.

Thanks in advance!

2023 05 05 - 00 12 08

garoto commented 1 year ago

mpv --ytdl-raw-options=ignore-config=,sub-lang="en\-en.*",write-sub=,write-auto-sub= https://www.youtube.com/watch?v=dfnCAmr569k

This will tell yt-dl to only generate json URLs for "en-en*" subs, both manually translated and not, so that at the very least, cycling thru subs should be much less painful.

Selecting this type of subs can be all automated somewhow via a simple lua script, but I'm too dumb and lazy and won't be able to help you with that.

garoto commented 1 year ago

But I agree that there's a use-case for dropping the hardcoded ISO language format standards for sub-loading in 2023 and let users decide via regexp or just simple wildcards.

JoseHidalgo commented 1 year ago

Thanks @garoto , much appreciated. Let's hope regexp/wildcards become more allowed in the future.

FYI I have put all my wanted parameters inside mpv.conf, so it looks like this:

[youtube]
ytdl-format="bestvideo[ext=mp4][height<=?1440]+bestaudio/best"
slang=en
sub-auto=fuzzy
ytdl-raw-options=ignore-config=,sub-lang="en\-en.*",write-sub=,write-auto-sub=

It works, but I'm not sure it's correct. For example I don't really know the difference beteween slang and sub-lang. Would there be a better way to write this in mpv.conf? Thanks again.

garoto commented 1 year ago

For example I don't really know the difference beteween slang and sub-lang.

slang is how the mpv option to define subtitle languages is named. sub-lang is the youtube-dl and derivatives equivalent option. Both are not mutually exclusive and work in tandem.

barolo commented 4 months ago

This seems to be no longer working, I cannot get auto-subs for this video for example: https://www.youtube.com/watch?v=T0CpOYZZZW4

tried with

mpv --no-config --ytdl-raw-options=ignore-config=,sub-lang="en\-en.*",write-sub=,write-auto-sub= https://www.youtube.com/watch?v=T0CpOYZZZW4
SeriousHoax commented 3 months ago

The video from the comment above works for me. But auto-generated subtitles for videos like these are not working https://www.youtube.com/watch?v=f-pE3oalzPw https://youtu.be/6PXyfdBOL28?si=SvlAZ1YzGjSN3pSI