mpv-scripts icon indicating copy to clipboard operation
mpv-scripts copied to clipboard

chapter-make-read.lua accepts chapter filenames with 2 or 3 letter language codes

Open porg opened this issue 2 years ago • 2 comments

Imagine this file structure

video.mp4           # Video file
video.chp           # Chapter file, language neutral
video.mp4.chp       # Chapter file, language neutral, video suffix included
video.chi.chp       # Chinese chapter file, 3-letter code (ISO 639‑3), 
video.en.chp        # English chapter file, 2-letter code (ISO 639‑1)
video.spa.chp       # Spanish chapter file, 3-letter code (ISO 639‑3)
video FR.chp        # French chapter file, 2-letter code (ISO 639‑1) at the end of the file name without a dot

Detection

  • If we have #15 then the .chp file can also be associated to the video file without the video file suffix.
  • The language code can be identified if immediately before the .chp, in lowercase, uppercase, prefixed by a non-alphanumeric character, so dot, space or also hyphen, etc. See mpv option --options-sub-auto

Utilization

  • If there is only one chapter file, then use it right away, no questions asked.
  • If there are chapter files available in different languages then
    • in v1 the script chooses according to the mpv Track Selection preferences:
      • Already offers --alang (audio) , --vlang (video), --slang (subtitles), so you could introduce --clang (chapters)
      • If no --clang is present it uses --slang: If you can read the subtitles in that language, you can also read the chapters in that language.
      • For some obscure reasons you may want the original language chapter names (e.g. for reference) but nevertheless watch in your preferred subtitle language.
    • in v2 the script may allows to switch languages interactively (like subtitles already can)
    • in v3 the script may allows to switch language interactively in tandem with the subtitle files if you have exactly the same set of chapter languages and subtitles languages in total (from the video file stream and/or loaded from sidecar files)

porg avatar Jul 07 '23 13:07 porg

I roughly understand your idea, but since I personally do not have such a need and cannot think of a simple way to implement it at the moment, I am afraid I do not have the motivation to implement this feature.

If anyone is willing to implement it, welcome to open PR for this.

dyphire avatar Jul 09 '23 16:07 dyphire

  • Whomever may tackle this one day, please in accordance with #15

porg avatar Jul 10 '23 13:07 porg