mpvに字幕がないように動作させることはできますか?

mpvに字幕がないように動作させることはできますか?

日本語を練習しているのに練習の道具で、たまに字幕なしでアニメを見たい時があります。ショートカットを使用して字幕をオフにできることを知っています。mpvただし--sid=0、どちらの場合も、ショートカットキーで字幕を再度有効にできます。

私はしばしばサブを頻繁に再活性化したいと思う誘惑を感じるので迷惑で、これは言語学習を深刻に妨げます。それで、mpvファイルに字幕がないからといって、必ず字幕を見たくても完全に再起動をさせる方法があるかどうか疑問に思いますmpv

答え1

確かに関連する多くのソリューションの1つを紹介します。mpvビデオプレーヤー


問題を解決するには、以下をmpv.conf含めるように編集します。

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

これは、次のようにコマンドラインで実行する必要があります。

mpv --sub-visibility=no ...

2回目の試み:

プロフィールを編集mpv:

~/.config/mpv/input.conf

以下が含まれます:

v disable

ヘルプスクリプト(例)

#!/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

関連情報