4

I am practicing Japanese, and as a practice tool, I sometimes want to watch anime without subtitles. I know I can turn off subtitles in mpv using hotkeys, and I am also aware of --sid=0; however, in both these situations, I am one hotkey away from re-enabling the subtitles.

This is bad because I often find myself tempted to re-enable the subs way too often, which seriously hinders language learning. So I was wondering if there is some way to tell mpv that the subtitles within a file don't exist, so that, even if I really wanted to see the subtitles, I'd have to completely restart mpv.

Vlastimil Burián
  • 27,586
  • 56
  • 179
  • 309
TT-392
  • 127
  • 6
  • 1
    Use `--sub-font-size=5` to make subtitles illegibly small. – Devon Jun 18 '23 at 10:11
  • @VlastimilBurián I do prefer mpv as a player, but I guess, anything open source that runs on linux would be fine. – TT-392 Jun 18 '23 at 10:20
  • @Devon Oh, that would work, though, for some reason `--sub-font-size` doesn't seem to have an effect, but: `--sub-scale=0.1`, works – TT-392 Jun 18 '23 at 10:21
  • [1] There are Video Editors which can remove the Subtitle tracks in a video file to generate a new video file. You can play the new video file in which-ever Player you want , without worrying about configurations , hotkeys , ETC. [2] You can even use the Video Editors to add a new Subtitle track the video file , where that Subtitle track will contain no text , & make that the Default subtitle track in the new video file. Which-ever Player you use , you will not have to worry about configurations , hotkeys , ETC. – Prem Jun 18 '23 at 19:40
  • @Prem I was just about to post something similar! (I know ffmpeg can do stuff like that — it's the Swiss Army knife of video tools — but there may well be others too.) Of course, that would mean keeping a second copy of the video, and since video files tend to be large, that could be a significant disadvantage. But, as you say, it would work with any video player. – gidds Jun 18 '23 at 22:17
  • Yes , it will work Universally , with no worry about accidentally viewing the Subtitles. Where Storage is a concern , @gidds , this **"Universal Alternative Solution"** will work : the Video Editor can extract the Subtitles to a text file & then make a New Video file without the Subtitles. The Original Video file can be Deleted. The Subtitle text file can be moved to a folder else-where. Now , when the New Video file is Played , there will be no Subtitles to view , accidentally or other-wise ! When OP DOES want Subtitles , the Subtitles text file can be manually added to the Video Player ! – Prem Jun 19 '23 at 05:16

1 Answers1

7

Let me bring one of the certainly many solutions involving mpv video player.


To solve your issue, please edit mpv.conf to contain:

sub-visibility=no # Disable display of subtitles, but still load them if available.

This shall work from command-line as:

mpv --sub-visibility=no ...

Second try:

Edit your personal mpv file:

~/.config/mpv/input.conf

to contain:

v disable

Helper script (example)

#!/bin/sh
#--            Copyright: 2023 Vlastimil Burian            --
#--              Script language: POSIX shell              --
#--             Bugs: [email protected]              --
#--                 License: The Unlicense                 --
#--                   Version 0.1 (beta)                   --

# Treat unset variables as errors.
set -o nounset
# Exit immediately when any command fails.
set -o errexit

# Function to show usage help.
# Requires one argument, the exit status.
usage ()
{
cat << EOF
MPV video player subtitles enable/disable toggling
--------------------------------------------------
    on  : Enable  subtitles toggling in MPV.
    off : Disable subtitles toggling in MPV.
    -h  : Show this help.
EOF
    exit "$1"
}

# Process switches. Only help switch (-h) defined right now.
# If some other switch is given, show help with exit status 1.
while getopts ':h' opt; do
    case "$opt" in
        (h) usage 0 ;;
        (*) usage 1 ;;
    esac
done

# Check for the number of arguments.
# One argument is expected (on/off).
# If not given, show help with exit status 1.
if [ "$#" -ne 1 ]; then
    usage 1
fi

# Here we know the user gave one argument.
# We accept (continue) only on/off values.
# If something else is given, show help with exit status 1.
case "$1" in
    (on|off)
    switch=$1 ;;
    (*)
    usage 1 ;;
esac

# Store MPV video player user config directory name.
# You must not quote the value for tilde to expand!
mpv_config_dir=~/.config/mpv

# Make sure the config directory exists,
# or create it with default permissions.
# shellcheck disable=SC2174
mkdir -p -m 0700 "$mpv_config_dir"

# Store MPV video player input config file name.
mpv_config_file=input.conf

# Store the whole path to config file.
mpv_config_file_path="$mpv_config_dir/$mpv_config_file"

# Check if the config file exists and if not, create it.
if [ ! -f "$mpv_config_file_path" ]; then
    touch "$mpv_config_file_path"
    chmod 664 "$mpv_config_file_path"
fi

# Linux tput color handling setup.
text_red=$(tput setaf 1)
text_green=$(tput setaf 2)
text_bold=$(tput bold)
text_reset=$(tput sgr0)

# Now we are ready to write to the MPV config file.
# We print success/error message according to what happens.
# Colors are optional of course. If you do not like them, remove their code.
case "$switch" in
    (on)
        if printf '\n' > "$mpv_config_file_path"; then
            printf '%s\n' "${text_green}Success. MPV subtitles toggling is now ${text_bold}enabled.${text_reset}"
        else
            printf >&2 '%s\n' "${text_red}${text_bold}Error. Did not manage to write to the config file.${text_reset}"
            exit 1
        fi
    ;;
    (off)
        if printf '%s\n' 'v disable' > "$mpv_config_file_path"; then
            printf '%s\n' "${text_green}Success. MPV subtitles toggling is now ${text_bold}disabled.${text_reset}"
        else
            printf >&2 '%s\n' "${text_red}${text_bold}Error. Did not manage to write to the config file.${text_reset}"
            exit 1
        fi
    ;;
esac
Vlastimil Burián
  • 27,586
  • 56
  • 179
  • 309