changed jdautoenc.sh to source and Encoder check to Case for performance

This commit is contained in:
Pakobbix 2022-07-28 22:12:41 +02:00
parent 45d673079a
commit 2b467c43e9

View File

@ -3,35 +3,27 @@
config=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null) config=$(find ~ -type f -name "JDAutoConfig" 2>/dev/null)
log=$(grep "log=" "$config" | sed 's/.*=//g') log=$(grep "log=" "$config" | sed 's/.*=//g')
extracted=$(grep "extracted=" "$config" | sed 's/.*=//g') # shellcheck disable=SC1090
encodes=$(grep "encodes=" "$config" | sed 's/.*=//g') source "$config"
rename=$(grep "rename=" "$config" | sed 's/.*=//g')
discord=$(grep "discord=" "$config" | sed 's/.*=//g')
bitrate_anime=$(grep "bitrate_anime=" "$config" | sed 's/.*=//g') case "${Encoder,,}" in
preset_anime=$(grep "preset_anime=" "$config" | sed 's/.*=//g') nvidia)
bitrate_series=$(grep "bitrate_series=" "$config" | sed 's/.*=//g')
preset_series=$(grep "preset_series=" "$config" | sed 's/.*=//g')
bitrate_movie=$(grep "bitrate_movie=" "$config" | sed 's/.*=//g')
preset_movie=$(grep "preset_movie=" "$config" | sed 's/.*=//g')
encode=$(grep "encode=" "$config" | sed 's/.*=//g')
encoder=$(grep "Encoder=" "$config" | sed 's/.*=//g')
discord=$(grep "discord=" "$config" | sed 's/.*=//g')
if [[ ${encoder,,} == "nvidia" ]]; then
hw_accel="cuda" hw_accel="cuda"
codec="hevc_nvenc" codec="hevc_nvenc"
elif [[ ${encoder,,} == "amd" ]]; then ;;
amd)
hw_accel="auto" hw_accel="auto"
codec="hevc_amf" codec="hevc_amf"
elif [[ ${encoder,,} == "intel" ]]; then ;;
intel)
hw_accel="qsv" hw_accel="qsv"
codec="hevc_qsf" codec="hevc_qsf"
elif [[ ${encoder,,} == "software" ]]; then ;;
software)
hw_accel="qsv" hw_accel="qsv"
codec="hevc_qsf" codec="hevc_qsf"
fi ;;
esac
red='\033[0;31m' # ${red} red='\033[0;31m' # ${red}
white='\033[0;37m' # ${white} white='\033[0;37m' # ${white}
@ -42,10 +34,7 @@ lblue='\033[1;34m' # ${lblue}
cyan='\033[0;36m' # ${cyan} cyan='\033[0;36m' # ${cyan}
purple='\033[0;35m' # ${purple} purple='\033[0;35m' # ${purple}
language_Folder=$(grep "language_folder=" "$config" | sed 's/.*=//g') if [[ -z $language ]]; then
if [[ -n $(grep "language=" "$config" | sed 's/.*=//g') ]]; then
language=$(grep "language=" "$config" | sed 's/.*=//g')
else
language=$(locale | head -n 1 | sed 's/.*=\|\..*//g') language=$(locale | head -n 1 | sed 's/.*=\|\..*//g')
fi fi
@ -80,16 +69,10 @@ discord_msg() {
curl -s -H "Content-Type: application/json" -X POST -d "{\"content\": \"$1\"}" "$discord" &>/dev/null curl -s -H "Content-Type: application/json" -X POST -d "{\"content\": \"$1\"}" "$discord" &>/dev/null
} }
NextcloudDomain=$(grep "NextcloudDomain=" "$config" | sed 's/.*=//g')
NextcloudTalkToken=$(grep "NextcloudTalkToken=" "$config" | sed 's/.*=//g')
NextcloudUser=$(grep "NextcloudUser=" "$config" | sed 's/.*=//g')
NextcloudPassword=$(grep "NextcloudPassword=" "$config" | sed 's/.*=//g')
nextcloud_msg() { nextcloud_msg() {
curl -d '{"token":"'"$NextcloudTalkToken"'", "message":"'"$1"'"}' -H "Content-Type: application/json" -H "Accept:application/json" -H "OCS-APIRequest:true" -u "$NextcloudUser:$NextcloudPassword" "$NextcloudDomain"/ocs/v1.php/apps/spreed/api/v1/chat/tokenid &>/dev/null curl -d '{"token":"'"$NextcloudTalkToken"'", "message":"'"$1"'"}' -H "Content-Type: application/json" -H "Accept:application/json" -H "OCS-APIRequest:true" -u "$NextcloudUser:$NextcloudPassword" "$NextcloudDomain"/ocs/v1.php/apps/spreed/api/v1/chat/tokenid &>/dev/null
} }
appriseurl=$(grep "appriseurl=" "$config" | sed 's/.*=//g')
apprisetag=$(grep "apprisetag=" "$config" | sed 's/.*=//g')
apprise_msg() { apprise_msg() {
if [[ -n $apprisetag ]]; then if [[ -n $apprisetag ]]; then
curl -d '{"body":"'"$1"'", "title":"#### jdautoenc.sh ####","tag":"'"$apprisetag"'"}' -H "Content-Type: application/json" "$appriseurl" &>/dev/null curl -d '{"body":"'"$1"'", "title":"#### jdautoenc.sh ####","tag":"'"$apprisetag"'"}' -H "Content-Type: application/json" "$appriseurl" &>/dev/null
@ -101,7 +84,7 @@ apprise_msg() {
ff_encode() { ff_encode() {
if [[ ${encode,,} == "yes" ]]; then if [[ ${encode,,} == "yes" ]]; then
total_frames=$(ffprobe -v error -show_format -select_streams v:0 -show_streams "$i" | grep TAG:NUMBER_OF_FRAMES= | sed 's/.*=\|\..*//g') total_frames=$(ffprobe -v error -show_format -select_streams v:0 -show_streams "$i" | grep TAG:NUMBER_OF_FRAMES= | sed 's/.*=\|\..*//g')
fps=$(grep "fps=" /home/hhofmann/.local/logs/jdautoenc.log | tail -n 1 | sed 's/.*fps=\| q=.*\|\..*//g') fps=$(grep "fps=" "$log" | tail -n 1 | sed 's/.*fps=\| q=.*\|\..*//g')
eta_encoding=$((total_frames / fps)) eta_encoding=$((total_frames / fps))
if [[ $eta_encoding -gt "60" ]]; then if [[ $eta_encoding -gt "60" ]]; then
log_msg "Estimated Encoding Time: $((total_frames / fps / 60)) Minutes (based on last encoding speed)" log_msg "Estimated Encoding Time: $((total_frames / fps / 60)) Minutes (based on last encoding speed)"