Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "--secondary-slang" option #4209

Open
sebma opened this issue Mar 7, 2017 · 6 comments
Open

Add a "--secondary-slang" option #4209

sebma opened this issue Mar 7, 2017 · 6 comments
Labels
core:option-param-conf config, parameters, properties, options, shortcuts core:subtitle meta:feature-request

Comments

@sebma
Copy link

sebma commented Mar 7, 2017

Hi,

I'm using mpv v0.24 on Ubuntu Linux and I would like two display a secondary subtitle knowing that the subtitles SIDs provided by youtube are not always in the same order.

Therefore the --secondary-sid option does not help because I do NOT know the SID number before actually playing the video with mpv :

Here is the example URL : https://www.youtube.com/watch?v=QS2mzHP1Cx4

Can you please consider my idea ?

@sCreami
Copy link
Contributor

sCreami commented Mar 10, 2017

As no one has answered your question yet I'm going to take the shot and tell you that your issue is
incoherent. It's not clear what you're asking for. Would you like to use a fallback behaviour when the preferred subtitle language is unavailable? You can already do that by separating the tag with comma like --slang=eng,en,fre,fra,fr. Also your video doesn't provide subtitle so I'm not really sure it's what you're looking for.

@sebma
Copy link
Author

sebma commented Mar 11, 2017

Thanks for your time.

The URL I provided has youtube auto-generated subtitles.

I would like to see two subtitle tracks on the video at the same time : one in French and the other in English.

But the problem is that the SIDs are for each language are not always the same (maybe because these subtitles are auto-generated by Youtube) :

$ mpv https://www.youtube.com/watch?v=QS2mzHP1Cx4
Playing: https://www.youtube.com/watch?v=QS2mzHP1Cx4
[ffmpeg] tls: A TLS packet with unexpected length was received.
[ffmpeg] tls: A TLS packet with unexpected length was received.
......
 (+) Video --vid=1 (*) (h264)
 (+) Audio --aid=1 --alang=eng (*) 'DASH audio' (opus) (external)
     Subs  --sid=1 --slang=ca 'vtt' (webvtt) (external)
     Subs  --sid=2 --slang=da 'vtt' (webvtt) (external)
     Subs  --sid=3 --slang=hi 'vtt' (webvtt) (external)
     Subs  --sid=4 --slang=de 'vtt' (webvtt) (external)
     Subs  --sid=5 --slang=fi 'vtt' (webvtt) (external)
     Subs  --sid=6 --slang=be 'vtt' (webvtt) (external)
     Subs  --sid=7 --slang=eu 'vtt' (webvtt) (external)
     Subs  --sid=8 --slang=mi 'vtt' (webvtt) (external)
     Subs  --sid=9 --slang=sm 'vtt' (webvtt) (external)
     Subs  --sid=10 --slang=gu 'vtt' (webvtt) (external)
     Subs  --sid=11 --slang=xh 'vtt' (webvtt) (external)
     Subs  --sid=12 --slang=ta 'vtt' (webvtt) (external)
     Subs  --sid=13 --slang=ne 'vtt' (webvtt) (external)
     Subs  --sid=14 --slang=te 'vtt' (webvtt) (external)
     Subs  --sid=15 --slang=pa 'vtt' (webvtt) (external)
     Subs  --sid=16 --slang=ka 'vtt' (webvtt) (external)
     Subs  --sid=17 --slang=la 'vtt' (webvtt) (external)
     Subs  --sid=18 --slang=ja 'vtt' (webvtt) (external)
     Subs  --sid=19 --slang=ga 'vtt' (webvtt) (external)
     Subs  --sid=20 --slang=ha 'vtt' (webvtt) (external)
     Subs  --sid=21 --slang=am 'vtt' (webvtt) (external)
     Subs  --sid=22 --slang=el 'vtt' (webvtt) (external)
     Subs  --sid=23 --slang=fy 'vtt' (webvtt) (external)
     Subs  --sid=24 --slang=cy 'vtt' (webvtt) (external)
     Subs  --sid=25 --slang=lt 'vtt' (webvtt) (external)
     Subs  --sid=26 --slang=pt 'vtt' (webvtt) (external)
     Subs  --sid=27 --slang=ml 'vtt' (webvtt) (external)
     Subs  --sid=28 --slang=ny 'vtt' (webvtt) (external)
     Subs  --sid=29 --slang=ceb 'vtt' (webvtt) (external)
     Subs  --sid=30 --slang=nl 'vtt' (webvtt) (external)
     Subs  --sid=31 --slang=pl 'vtt' (webvtt) (external)
     Subs  --sid=32 --slang=it 'vtt' (webvtt) (external)
     Subs  --sid=33 --slang=hy 'vtt' (webvtt) (external)
     Subs  --sid=34 --slang=uk 'vtt' (webvtt) (external)
     Subs  --sid=35 --slang=yo 'vtt' (webvtt) (external)
     Subs  --sid=36 --slang=tg 'vtt' (webvtt) (external)
     Subs  --sid=37 --slang=gd 'vtt' (webvtt) (external)
     Subs  --sid=38 --slang=id 'vtt' (webvtt) (external)
     Subs  --sid=39 --slang=ro 'vtt' (webvtt) (external)
     Subs  --sid=40 --slang=so 'vtt' (webvtt) (external)
     Subs  --sid=41 --slang=sd 'vtt' (webvtt) (external)
     Subs  --sid=42 --slang=no 'vtt' (webvtt) (external)
     Subs  --sid=43 --slang=ig 'vtt' (webvtt) (external)
     Subs  --sid=44 --slang=ms 'vtt' (webvtt) (external)
     Subs  --sid=45 --slang=sw 'vtt' (webvtt) (external)
     Subs  --sid=46 --slang=az 'vtt' (webvtt) (external)
     Subs  --sid=47 --slang=ps 'vtt' (webvtt) (external)
     Subs  --sid=48 --slang=lo 'vtt' (webvtt) (external)
     Subs  --sid=49 --slang=bs 'vtt' (webvtt) (external)
     Subs  --sid=50 --slang=cs 'vtt' (webvtt) (external)
     Subs  --sid=51 --slang=ky 'vtt' (webvtt) (external)
     Subs  --sid=52 --slang=es 'vtt' (webvtt) (external)
     Subs  --sid=53 --slang=sl 'vtt' (webvtt) (external)
     Subs  --sid=54 --slang=my 'vtt' (webvtt) (external)
     Subs  --sid=55 --slang=mg 'vtt' (webvtt) (external)
     Subs  --sid=56 --slang=is 'vtt' (webvtt) (external)
     Subs  --sid=57 --slang=mk 'vtt' (webvtt) (external)
     Subs  --sid=58 --slang=uz 'vtt' (webvtt) (external)
     Subs  --sid=59 --slang=sk 'vtt' (webvtt) (external)
     Subs  --sid=60 --slang=st 'vtt' (webvtt) (external)
     Subs  --sid=61 --slang=km 'vtt' (webvtt) (external)
     Subs  --sid=62 --slang=mt 'vtt' (webvtt) (external)
     Subs  --sid=63 --slang=ko 'vtt' (webvtt) (external)
     Subs  --sid=64 --slang=et 'vtt' (webvtt) (external)
     Subs  --sid=65 --slang=fa 'vtt' (webvtt) (external)
     Subs  --sid=66 --slang=kk 'vtt' (webvtt) (external)
     Subs  --sid=67 --slang=sv 'vtt' (webvtt) (external)
     Subs  --sid=68 --slang=bg 'vtt' (webvtt) (external)
     Subs  --sid=69 --slang=tr 'vtt' (webvtt) (external)
     Subs  --sid=70 --slang=sr 'vtt' (webvtt) (external)
     Subs  --sid=71 --slang=ku 'vtt' (webvtt) (external)
 (+) Subs  --sid=72 --slang=fr 'vtt' (webvtt) (external)
     Subs  --sid=73 --slang=zh-Hans 'vtt' (webvtt) (external)
     Subs  --sid=74 --slang=lv 'vtt' (webvtt) (external)
     Subs  --sid=75 --slang=en 'vtt' (webvtt) (external)
     Subs  --sid=76 --slang=jv 'vtt' (webvtt) (external)
     Subs  --sid=77 --slang=kn 'vtt' (webvtt) (external)
     Subs  --sid=78 --slang=ht 'vtt' (webvtt) (external)
     Subs  --sid=79 --slang=eo 'vtt' (webvtt) (external)
     Subs  --sid=80 --slang=iw 'vtt' (webvtt) (external)
     Subs  --sid=81 --slang=hr 'vtt' (webvtt) (external)
     Subs  --sid=82 --slang=ur 'vtt' (webvtt) (external)
     Subs  --sid=83 --slang=mn 'vtt' (webvtt) (external)
     Subs  --sid=84 --slang=af 'vtt' (webvtt) (external)
     Subs  --sid=85 --slang=sn 'vtt' (webvtt) (external)
     Subs  --sid=86 --slang=mr 'vtt' (webvtt) (external)
     Subs  --sid=87 --slang=zh-Hant 'vtt' (webvtt) (external)
     Subs  --sid=88 --slang=ar 'vtt' (webvtt) (external)
     Subs  --sid=89 --slang=yi 'vtt' (webvtt) (external)
     Subs  --sid=90 --slang=hu 'vtt' (webvtt) (external)
     Subs  --sid=91 --slang=zu 'vtt' (webvtt) (external)
     Subs  --sid=92 --slang=hmn 'vtt' (webvtt) (external)
     Subs  --sid=93 --slang=co 'vtt' (webvtt) (external)
     Subs  --sid=94 --slang=vi 'vtt' (webvtt) (external)
     Subs  --sid=95 --slang=si 'vtt' (webvtt) (external)
     Subs  --sid=96 --slang=th 'vtt' (webvtt) (external)
     Subs  --sid=97 --slang=haw 'vtt' (webvtt) (external)
     Subs  --sid=98 --slang=gl 'vtt' (webvtt) (external)
     Subs  --sid=99 --slang=ru 'vtt' (webvtt) (external)
     Subs  --sid=100 --slang=su 'vtt' (webvtt) (external)
     Subs  --sid=101 --slang=sq 'vtt' (webvtt) (external)
     Subs  --sid=102 --slang=bn 'vtt' (webvtt) (external)
     Subs  --sid=103 --slang=lb 'vtt' (webvtt) (external)
     Subs  --sid=104 --slang=fil 'vtt' (webvtt) (external)
AO: [pulse] 48000Hz stereo 2ch float
VO: [opengl] 1920x1080 yuv420p
AV: 00:00:03 / 00:34:02 (0%) A-V:  0.000 Dropped: 2 Cache:  8s+15KB

@sCreami
Copy link
Contributor

sCreami commented Mar 11, 2017

I see. There's currently no way of doing so. Let's see what the higher ups will do about it.

@bugdone
Copy link
Contributor

bugdone commented Apr 2, 2018

You can do this with a script

@Akemi Akemi added the core:option-param-conf config, parameters, properties, options, shortcuts label Sep 21, 2019
@Akemi Akemi changed the title Feature : Add a "--secondary-slang" option Add a "--secondary-slang" option Sep 21, 2019
@lalomartins
Copy link

I should add that if possible, the secondary sub should not be loaded if it's the same as the primary.

One major use case for this is language learning/practice. I'd like to specify --slang jpn,ja,eng,en --secondary-slang eng,en; then, whenever there are both Japanese and English subs available, I'd get Japanese as primary and English as secondary, but if there are only English, I'd get that as primary and nothing as secondary.

@paulmiddelkoop
Copy link

I created this script until this feature is implemented. You can change the secondarySubtitleLanguages to your likings.

secondarySubtitleLanguages = {"dut", "eng"}

function setSecondarySubtitle()
  local languagePriorities = {}
  for index,language in ipairs(secondarySubtitleLanguages) do
     languagePriorities[language]=index
  end

  local secondaryTrackNumber
  for trackNumber = 0, mp.get_property_number("track-list/count") do
    if getTrackListProperty("type", trackNumber) == "sub" then
      local trackLang = getTrackListProperty("lang", trackNumber)

      if languagePriorities[trackLang] and
          (not secondaryTrackNumber or languagePriorities[trackLang] < languagePriorities[getTrackListProperty("lang", secondaryTrackNumber)])  then
        secondaryTrackNumber = trackNumber
      end
    end
  end

  if secondaryTrackNumber then
    mp.set_property_number("secondary-sid", getTrackListProperty("id", secondaryTrackNumber))
  else
    print("No suitable secondary subtitle found.")
  end
end

function getTrackListProperty(subProperty, trackNumber)
  return mp.get_property("track-list/" .. trackNumber .. "/" .. subProperty)
end

mp.register_event("file-loaded", setSecondarySubtitle)

@lalomartins if you choose the same secondary sub as the primary it is already ignored by mpv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core:option-param-conf config, parameters, properties, options, shortcuts core:subtitle meta:feature-request
Projects
None yet
Development

No branches or pull requests

7 participants