cogentredtester / mpv-sub-select Goto Github PK
View Code? Open in Web Editor NEWAn advanced conditional subtitle track selector for mpv player
License: MIT License
An advanced conditional subtitle track selector for mpv player
License: MIT License
Mplug is like a package manager but for mpv scripts.
Please add your script there (if already not there) and also installation instructions in manifest - https://github.com/Nudin/mpv-script-directory/blob/master/HOWTO_ADD_INSTALL_INSTRUCTIONS.md
Example:
-- Folder name: Movie
--- Movie.mkv
--- Movie_eng.ass
--- Movie_chi.ass
--- Movie_spa.ass
Is it possible to auto-select subs with "eng" as their file name?
In some cases those are the only indications to which language the subs are.
MPV has useful option for overriding certain options per-folder by creating mpv.conf in it with option you need (for example sid=2
to always select subtitle number two), but, sub-select overrides mpv's subtitle selecting logic and "sid" value from this file is not used, so, it would be nice to have an option to use "sid" value if mpv.conf has it.
It just stopped working seemingly at random. I was using an older version that was running without issue, I thought a recent mpv version might've broken it, yet the issue persisted after I downloaded the .lua file. FOr some reason, it produces no error code on the console, it just says it's selecting a subtitle when it isn't (at least not correctly). I'm pretty sure it's just falling back to native mpv selection. I checked my .json as well and there's nothing wrong with the syntax (it follows the example).
I was wondering if it would be possible to compare the subtitles with the video name so that the correct sub for the episode could be used automatically. For example, E02 in the track title could be matched with the E02 subtitle if all the subs are loaded.
Consider this example of a file with mislabeled tracks:
(+) Video --vid=1 'H.264/AVC Video' (h264 720x480 29.970fps)
(+) Audio --aid=1 --alang=eng (*) 'English: Stereo' (aac 2ch 44100Hz)
Audio --aid=2 --alang=eng 'Japanese: Stereo' (aac 2ch 48000Hz)
(+) Subs --sid=1 --slang=eng (*) 'Titles & Signs' (ass)
Subs --sid=2 --slang=eng 'English Subtitles (Anime-Keep)' (ass)
It'd be great if I could say, select the audio track which has "japanese" in its title, before going for eng
audio.
Having trouble doing a specific blacklisting "s&s" from a force subtitle condition. Not sure how to properly escape this, I would assume that within the double quotations it would read everything as is.
Currently this is how I setup the blacklist in the json:
{
"alang": ["jpn", "ja"],
"slang": "eng?",
"blacklist": [ "sign", "s&s" ],
"condition": "sub.forced"
}
A track that should be blacklisted is selected for some reason. Here is the .json:
[
{
"alang": "jpn",
"slang": ["jpn", "enm", "eng"],
"blacklist": ["signs", "songs", "translation only"],
"whitelist": ["commie", "honorifics"]
},
{
"alang": "gre",
"slang": "no"
},
{
"alang": "eng",
"slang": ["forced", "no"]
},
{
"alang": "*",
"slang": "eng"
}
]
A track with the title "Signs and Songs" is selected on my test file, even though both "signs" and "songs" are in the blacklist.
did I put the setup file correctly? I didn't know exactly where
"C:\Program Files\MPV\mpv\script-opts\sub-select.json"
I watch anime, so here's how to make it so that the Japanese audio track selects the titles of the subtitles that I entered?
and can I make it so that an audio track with a specific name is selected, regardless of the title of the subtitles?
for example, I have an audio track from wakanim and crunchyroll in the video, how do I get the script to select crunchyroll? if it is 2 in the list?
I copied the settings file to different folders but the script doesn't work,
[
{
"alang": "*",
"slang": ["*"],
"blacklist": [ "Надписи" ]
},
{
"alang": "*",
"slang": "*",
"whitelist": ["Полные"]
}
]
How do I filter by subtitle format (ass
, pgs
, srt
, vtt
, etc...)?
In some files, there are more than one subtitle of the same language, and the subtitle with all the dialogues has a suffix (full)
. Is it possible to add it as an optional preferred term? Adding it as a whitelist term will select nothing when only one subtitle of that language is present.
Naming the configuration file sub_select.conf
breaks with the other two filenames and is confusing at first.
I would suggest changing it to opt.read_options(o, "sub-select")
in the main script to keep the naming consistent or change the two other files to sub_select
too.
First of all, thank you for the great script.
It seems like, since your latest commits this setting is not working for me:
[
{
"alang": "hun?",
"slang": [
"forced",
"no"
]
}
]
The script cannot find the subtitle track with "forced" flag. I also tried it with "default" option and without the "no" option, but it doen't work either.
It works fine with other settings.
Can you help me?
I've got a video with two subtitles. One has the name "English" and the other has the name "English (Translation Only)". The default sub is the latter which is akin to signs/songs in terms of actually being useful when watching something with an audio track in another language.
I have this in my sub-select.json
{
"alang": [ "j[ap]n?" ],
"slang": [ "eng?", "und", "jpn?" ],
"blacklist": [ "Sings/Songs", "signs", "songs", "sign", "song", "English (Translation Only)" ]
},
Despite that I can't seem to blacklist this sub for some reason. I tried escaping the parentheses with one and two backslashes but to no avail.
Any idea what might be going on?
Here is the output from mkvinfo in case I missed something.
+ EBML head
|+ EBML version: 1
|+ EBML read version: 1
|+ Maximum EBML ID length: 4
|+ Maximum EBML size length: 8
|+ Document type: matroska
|+ Document type version: 2
|+ Document type read version: 2
+ Segment: size 3114128818
|+ Seek head (subentries will be skipped)
|+ EBML void: size 4029
|+ Segment information
| + Timestamp scale: 1000000
| + Multiplexing application: libebml v1.2.1 + libmatroska v1.1.1
| + Writing application: mkvmerge v4.9.1 ('Ich will') built on Jul 11 2011 23:53:15
| + Duration: 00:24:10.474000000
| + Date: 2021-01-23 07:57:15 UTC
| + Segment UID: 0xbb 0x81 0xbd 0x1c 0x01 0x0d 0x3a 0xad 0x91 0x8b 0x20 0xe6 0x02 0x54 0x1c 0x24
|+ Tracks
| + Track
| + Track number: 1 (track ID for mkvmerge & mkvextract: 0)
| + Track UID: 1209811604
| + Track type: video
| + "Lacing" flag: 0
| + Minimum cache: 1
| + Codec ID: V_MPEG4/ISO/AVC
| + Codec's private data: size 41 (H.264 profile: High @L4.1)
| + Default duration: 00:00:00.041708333 (23.976 frames/fields per second for a video track)
| + Language: und
| + Name: ENCODED BY DARKDREAM
| + Video track
| + Pixel width: 1920
| + Pixel height: 1080
| + Display width: 1920
| + Display height: 1080
| + Track
| + Track number: 2 (track ID for mkvmerge & mkvextract: 1)
| + Track UID: 1103072181
| + Track type: audio
| + Codec ID: A_AAC
| + Codec's private data: size 5
| + Default duration: 00:00:00.021333333 (46.875 frames/fields per second for a video track)
| + Name: English
| + Audio track
| + Sampling frequency: 48000
| + Channels: 6
| + Track
| + Track number: 3 (track ID for mkvmerge & mkvextract: 2)
| + Track UID: 1610248080
| + Track type: audio
| + "Default track" flag: 0
| + Codec ID: A_AAC
| + Codec's private data: size 5
| + Default duration: 00:00:00.021333333 (46.875 frames/fields per second for a video track)
| + Language: jpn
| + Name: Japanese
| + Audio track
| + Sampling frequency: 48000
| + Channels: 6
| + Track
| + Track number: 4 (track ID for mkvmerge & mkvextract: 3)
| + Track UID: 1675229328
| + Track type: subtitles
| + "Lacing" flag: 0
| + Codec ID: S_TEXT/ASS
| + Codec's private data: size 823
| + Name: English (Translation Only)
| + Track
| + Track number: 5 (track ID for mkvmerge & mkvextract: 4)
| + Track UID: 1537904289
| + Track type: subtitles
| + "Default track" flag: 0
| + "Lacing" flag: 0
| + Codec ID: S_TEXT/ASS
| + Codec's private data: size 823
| + Name: English
|+ EBML void: size 1189
|+ Attachments
| + Attached
| + File name: OpenSans-Semibold_0.ttf
| + MIME type: application/x-truetype-font
| + File data: size 221328
| + File UID: 123114646
|+ Cluster
Hi,
Firstly, I thank you for your great work, sir.
Your script seems to also work for plex, but for plex, the script won't select sub.external even though it works for mpv?
I would appreciate it if you could please help me?
For some reason I am unable to properly install the script. I put the sub-select.lua file in the scripts folder and the sub-select.json file in the script-opts folder. I have not used the sub-select.conf file as I don't know where to put it.
My .json file is as follows
[
{
"alang": "jpn"
"slang": ["jpn", "enm", "eng"]
"blacklist": ["sign", "signs", "translation only"]
"whitelist": ["commie", "honorifics"]
},
{
"alang": "eng"
"slang": ["forced", "no"]
},
{
"alang": "el"
"slang": "no"
},
{
"alang": "*"
"slang": "eng"
}
]
So, if an audio track has the language English it should try a forced track and if there isn't one, subtitles should be turned off. Yet, when I tested this with a video with English audio and an English non-forced subtitle track, the english subtitles were selected, as if mpv did the selection and not the script. Maybe I have to copy sub-select.conf somewhere for it to work? Please help.
At present, the following config are required to achieve accurate priority:
[
{
"alang": "j[ap]n?",
"slang": ["chi", "und"],
"whitelist": ["chs&j[ap]n?"]
},
{
"inherit": "^",
"whitelist": ["sc&j[ap]n?"]
},
{
"inherit": "^",
"whitelist": ["cht&j[ap]n?"]
},
{
"inherit": "^",
"whitelist": ["ch&j[ap]n?"]
},
{
"inherit": "^",
"whitelist": ["tc&j[ap]n?"]
},
{
"inherit": "^",
"whitelist": ["zh&j[ap]n?"]
}
]
I hope it can be optimized to the following concise content:
[
{
"alang": "j[ap]n?",
"slang": ["chi", "und"],
"whitelist": ["chs&j[ap]n?", "sc&j[ap]n?", "cht&j[ap]n?", "ch&j[ap]n?", "tc&j[ap]n?", "zh&j[ap]n?"]
}
]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.