일본어를 연습하고 있는데 연습의 도구로 가끔 자막 없이 애니메이션을 보고 싶을 때가 있어요. 단축키를 사용하여 자막을 끌 수 있다는 것을 알고 있습니다. mpv
하지만 --sid=0
두 경우 모두 단축키만으로 자막을 다시 활성화할 수 있습니다.
나는 종종 서브를 자주 다시 활성화하고 싶은 유혹을 느끼기 때문에 짜증나는데, 이는 언어 학습을 심각하게 방해합니다. 그래서 mpv 파일에 자막이 없다고 해서 꼭 자막을 보고 싶어도 완전히 재부팅을 하게 만드는 방법이 있는지 궁금합니다 mpv
.
답변1
확실히 관련된 많은 솔루션 중 하나를 소개하겠습니다.mpv
비디오 플레이어.
문제를 해결하려면 다음을 mpv.conf
포함하도록 편집하십시오.
sub-visibility=no # Disable display of subtitles, but still load them if available.
이는 다음과 같이 명령줄에서 실행해야 합니다.
mpv --sub-visibility=no ...
두 번째 시도:
프로필 수정 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