mpv 0.29.0-372-g80552ab28e Copyright © 2000-2019 mpv/MPlayer/mplayer2 projects
built on UNKNOWN
ffmpeg library versions:
libavutil 56.33.100
libavcodec 58.55.100
libavformat 58.31.101
libswscale 5.6.100
libavfilter 7.58.100
libswresample 3.6.100
ffmpeg version: N-94597-g74e6800381
slang=chi
Choose Tradtional Chinese
Choose Simplified Chinese
https://www.loc.gov/standards/iso639-2/php/code_list.php
The ISO 639-2 character code for Traditional Chinese is zho.
Nobody uses the zho for Traditional Chinese, they use chi by adding a name "Traditional" behine it.

Sounds like Chinese pirates should conform to ISO standards then instead of abusing track titles for something they're not for.
It doesn't look like "Chinese" pirates at all.
There is no "Traditional" Chinese in the list, either.
It looks like I misinterpreted that table earlier, sorry. From a little more digging, there is no ISO 639-2 (or even 639-3, maybe?) code to differentiate between the writing forms of Chinese. What chi and zho actually are, are simply codes designating the ISO's internal English-based organizational system for the language codes (chi), and one that's based on the native name for the language (zho, at least I guess for some dialects).
This is actually a known issue with the language selection in the Matroska format itself:
https://gitlab.com/mbunkus/mkvtoolnix/wikis/Chinese-not-selectable-as-language
So yeah, putting 'Traditional' or 'Simplified' in the track titles looks like a necessary kludge until the Matroska specifications update to allow setting that distinction.
EDIT: The FAQ from the first link:
https://www.loc.gov/standards/iso639-2/faq.html#23
The suggestion there is that the script code gets appended to the 639-2 language code. Not sure if that style was ever floated for use in Matroska, although according to https://gitlab.com/mbunkus/mkvtoolnix/issues/2419, one likely option is that in MKVToolNix there might eventually be support for the recently-added LanguageIETF parameter. If the distinction between Traditional and Simplified is present there, that should ultimately fix it.
Probably you can write a script to detect the track title (through this property: https://mpv.io/manual/master/#command-interface-track-list/n/title) to auto-select the TC track. Otherwise if multiple chi tracks exist, mpv chooses the one with smaller track id (in your case the one who made the mkv file chose to put SC before TC).
Or just write a folder-specific/file-specific mpv.conf to manually set the sid.
@zc62 I don't understand, what does the N suppose to mean in track-list/N/lang
Is the syntax correct?
local utils = require 'mp.utils'
local msg = require 'mp.msg'
mp.get_property_native(track-list/N/chi)
No. You should first query the total number of tracks: track-list/count, then loop it.
Replace N with the 0-based track index.
See https://mpv.io/manual/master/#command-interface-track-list
In the loop of N from 0 to count-1, compare string property obtained from track-list/N/title with string Traditional, or other words you see that people use to mark TC tracks.
EDIT: of course you would want to make sure you first filter by type=="sub" and lang=="chi"
I just wrote one. @laichiaheng
mp.register_event("file-loaded", function()
local count = mp.get_property_native("track-list/count")
for N = 0,count-1,1 do
local type = mp.get_property_native("track-list/" .. tostring(N) .. "/type")
if type == "sub" then
local lang = mp.get_property_native("track-list/" .. tostring(N) .. "/lang")
if lang == "chi" then
local title = mp.get_property_native("track-list/" .. tostring(N) .. "/title")
if title == "Traditional" then
local id = mp.get_property_native("track-list/" .. tostring(N) .. "/id")
mp.commandv("set", "sid", id)
return
end
end
end
end
end)
Change the line
if title == "Traditional" then
to
if title == "Traditional" or title == "繁体中文" then
or even
if string.find(title, "Traditional") or string.find(title, "繁") then
if you want.
Perhaps it would be worth it to have a --stitle option which selects a more specific track if the --slang selection has no unambiguous one result, may be useful for more than just differentiating between traditional and simplified Chinese.
@zc62 How do you get these syntax: "track-list/" .. tostring(N) .. "/type"
The .. isn't mentioned in the manual.
Why are there space between .. and other strings?
How do you know the N should be string?
If there is no mp.register_event, will it work?
if title == "Traditional" or title == "繁体中文" then
By the way, it should be "繁體中文"
What .. does is it joins two strings, in other programming languages this is usually done with + but Lua uses .. for string concatenation.
@CounterPillow I actually had a similar feature request, see #5133.
I mentioned
Even for built-in PGS subtitles, slang alone can also have troubles. For example, Simplified Chinese and Traditional Chinese share the code chi.
@laichiaheng Just try if my script works or not. If you want to learn scripting for mpv, learn lua first.
@zc62 Yes, it works.
see #5133.
Most helpful comment
I just wrote one. @laichiaheng
Change the line
to
or even
if you want.