handbrake_for_plex.sh

-support subtitle track
This commit is contained in:
2023-04-13 11:42:28 +02:00
parent c2ece3fefc
commit ef91f1a68e

View File

@@ -106,13 +106,15 @@ DEST_EXT=mp4
# Handbrake preset
[[ "$profile" == "" ]] && PRESET="Apple 720p30 Surround" || PRESET="$profile"
# Only files larger than $MAXSIZE will be processed
# Only files larger than $MAXSIZE will be processed (> 30Mo)
MAXSIZE=30000000
#MAXSIZE=300
# Open converted video file in an application
APP="Subler"
SUBTITLE_LIST="eng,fre"
# log
# this reduce handbrake verbosity
logfile=/tmp/HandBrake.log
@@ -298,7 +300,7 @@ END_COMMENT
printf " %-20s %-35s \n" "Language:" "${language_audio}"
printf " %-20s %-35s \n" "Defaut:" "${default_audio}"
if [[ "$nb_text" != 0 ]]; then
if [ "$nb_text" -ge 1 ]; then
echo -e "\n${bold}Text:${reset}"
printf " %-20s %-35s \n" "Format text:" "${format_text}"
printf " %-20s %-35s \n" "Codec:" "${codec_text}"
@@ -306,7 +308,7 @@ END_COMMENT
printf " %-20s %-35s \n" "Defaut:" "${default_text}"
fi
if [[ "$nb_menu" != 0 ]]; then
if [ "$nb_menu" -ge 1 ]; then
echo -e "\n${bold}Menu:${reset}"
echo -e "$m"
fi
@@ -317,8 +319,17 @@ END_COMMENT
file_export="$DEST"/"$new_name"
if [ ! -f "$file_export" ]; then
echo -e "\n${yellow}Convert $FILE${reset} ${bold}->${reset} ${green}$file_export${reset}\n"
$HANDBRAKE_CLI -i "$FILE" -o "$file_export" "$PRESET" 2> $logfile
#echo -e "\n${yellow}Convert $FILE${reset} ${bold}->${reset} ${green}$file_export${reset}"
z="\n${yellow}Convert $FILE${reset} ${bold}->${reset} ${green}$file_export${reset}"
if [ "$nb_text" -ge 1 ] && [[ $SUBTITLE_LIST =~ ${language_text} ]]; then
echo -e "$z (with ${bold}${language_text}${reset} subtitle track)"
$HANDBRAKE_CLI -i "$FILE" -o "$file_export" "$PRESET" --subtitle-lang-list "$SUBTITLE_LIST" --all-subtitles 2> $logfile
else
echo -e "$z"
$HANDBRAKE_CLI -i "$FILE" -o "$file_export" "$PRESET" 2> $logfile
fi
echo
result=$?
if [ "$result" = 0 ]; then