🛡️ Security Note & Best Practices

mpv .lua scripts are extremely powerful. Unlike a web browser, mpv does not "sandbox" its scripts. This means a script has the same permissions as your Windows user account: it can read/write files, execute system commands, and access the network.

How do I know a script is safe?

You should never put a script into your mpv folder unless you trust the source or have verified the code. For those who aren't programmers, the most "noob-proof" method is to use AI as a safety auditor:

The AI Audit Method:
1. Open an AI (e.g., ChatGPT, Google Gemini, or Claude).
2. Paste the script content and ask: "Does this script contain any malicious behavior, hidden network calls, or dangerous system commands?"
3. You can also ask it to explain exactly what each part of the script does in detail.

Verification: Always ensure that the .lua file you download/save matches the code displayed on this page. While this site is served securely via GitHub and Cloudflare, "supply chain" attacks can happen. If a source repository is ever compromised, the code could be changed without notice. Always inspect what you execute.

MPV Track Selection Script (.lua)

This script automates audio and subtitle selection in MPV.
MPV will automatically load your preferred languages for both audio and subtitles. The player will also distinguish between full dialogue and signs/songs based on your audio selection, even updating subtitles instantly when you switch audio tracks.

Save it as track-selector.lua in your mpv scripts folder.
(e.g. C:\Program Files\mpv\portable_config\scripts)

Notes:
This version is pre-configured for Italian. If you prefer a different language, you must manually edit the preferred_lang_codes, preferred_lang_Forced_Subs_Keywords and preferred_lang_Normal_Subs_Keywords sections inside the User Configuration.
If you want to prioritize subtitles from a specific region, remember to put the regional code as the first choice, followed by general fallbacks (e.g., es-419 for Latin American Spanish, then es and spa).
E.g. Language (preferred_lang_codes)            : {"it", "ita"}         → {"es-419", "es", "spa"}
     Forced (preferred_lang_Forced_Subs_Keywords): {"cartell", "forzat"}{"whatever", "keywords"}
     Normal (preferred_lang_Normal_Subs_Keywords): {"dialog", "complet"}{"whatever", "keywords"}
A detailed explanation of the script logic can be found just below the User Configuration.

track-selector.lua
Loading script content...
Copied!
Visit counter For Websites
Visit counter For Websites