generated from me/template-mit
Compare commits
6 Commits
e38e602d83
...
prod
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f7a1f5883 | |||
| 77300f3b82 | |||
| 8041037eda | |||
| 1ea50e600e | |||
| a1898c03b5 | |||
| 2564be90a4 |
+158
-5
@@ -9,6 +9,8 @@ export PATH="$PATH:~/bin-shared:~/.bin-shared"
|
|||||||
|
|
||||||
# PS1 Colors #
|
# PS1 Colors #
|
||||||
|
|
||||||
|
colors=`tput colors`
|
||||||
|
if (( colors >= 256 )); then
|
||||||
export PURPLE="`tput setaf 55`"
|
export PURPLE="`tput setaf 55`"
|
||||||
export ORANGE="`tput setaf 208`"
|
export ORANGE="`tput setaf 208`"
|
||||||
export GREEN="`tput setaf 34`"
|
export GREEN="`tput setaf 34`"
|
||||||
@@ -18,6 +20,28 @@ export SCARLET="`tput setaf 160`"
|
|||||||
export YELLOW="`tput setaf 226`"
|
export YELLOW="`tput setaf 226`"
|
||||||
|
|
||||||
export GRAY="`tput setaf 243`"
|
export GRAY="`tput setaf 243`"
|
||||||
|
elif (( colors == 16 )); then
|
||||||
|
export PURPLE="`tput setaf 13`"
|
||||||
|
export ORANGE="`tput setaf 11`"
|
||||||
|
export GREEN="`tput setaf 02`"
|
||||||
|
|
||||||
|
export RED="`tput setaf 09`"
|
||||||
|
export SCARLET="`tput setaf 01`"
|
||||||
|
export YELLOW="`tput setaf 11`"
|
||||||
|
|
||||||
|
export GRAY="`tput setaf 08`"
|
||||||
|
else
|
||||||
|
export PURPLE="`tput setaf 05`"
|
||||||
|
export ORANGE="`tput setaf 03`"
|
||||||
|
export GREEN="`tput setaf 02`"
|
||||||
|
|
||||||
|
export RED="`tput setaf 05`"
|
||||||
|
export SCARLET="`tput setaf 01`"
|
||||||
|
export YELLOW="`tput setaf 03`"
|
||||||
|
|
||||||
|
export GRAY="`tput setaf 07`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
export RESET="`tput sgr0`"
|
export RESET="`tput sgr0`"
|
||||||
export BOLD="`tput bold`"
|
export BOLD="`tput bold`"
|
||||||
@@ -37,14 +61,15 @@ alias l='ls '
|
|||||||
alias ll='ls -alh '
|
alias ll='ls -alh '
|
||||||
alias lh='ls -ash '
|
alias lh='ls -ash '
|
||||||
|
|
||||||
function cl {
|
function clones {
|
||||||
|
export CLONES_PATH="$HOME/Clones"
|
||||||
if [[ -d /sdcard ]]; then
|
if [[ -d /sdcard ]]; then
|
||||||
cd /sdcard/Library/Clones
|
export CLONES_PATH="/sdcard/Library/Clones"
|
||||||
else
|
|
||||||
cd $HOME/Clones
|
|
||||||
fi
|
fi
|
||||||
|
mkdir -pv "$CLONES_PATH"
|
||||||
|
cd "$CLONES_PATH"
|
||||||
}
|
}
|
||||||
alias clones="cl"
|
alias cl="clones"
|
||||||
alias cdl="cl"
|
alias cdl="cl"
|
||||||
alias cdc="cl"
|
alias cdc="cl"
|
||||||
|
|
||||||
@@ -545,6 +570,7 @@ alias set-pv-progress='set-var PV_PROGRESS "y" '
|
|||||||
alias set-pv-verbose='set-var PV_VERBOSE "y" '
|
alias set-pv-verbose='set-var PV_VERBOSE "y" '
|
||||||
alias set-pv-2pass='set-var PV_2PASS "y" '
|
alias set-pv-2pass='set-var PV_2PASS "y" '
|
||||||
alias set-pv-v2='set-var PV_V2 "y" '
|
alias set-pv-v2='set-var PV_V2 "y" '
|
||||||
|
alias set-pv-v2='set-var PV_YIFY "y" '
|
||||||
|
|
||||||
alias set-pv-vert='set-pv-vertical '
|
alias set-pv-vert='set-pv-vertical '
|
||||||
alias set-pv2='set-pv-v2; set-pv-2pass; set-pv-progress '
|
alias set-pv2='set-pv-v2; set-pv-2pass; set-pv-progress '
|
||||||
@@ -557,6 +583,75 @@ alias pvs2='pv2s '
|
|||||||
|
|
||||||
alias qpv2='set-pv2; qpv '
|
alias qpv2='set-pv2; qpv '
|
||||||
|
|
||||||
|
# 20260713 - Attempt at compressing videos as well as done for torrented movies.
|
||||||
|
function pv-yify {
|
||||||
|
# ffmpeg -i input.mkv -c:v libx264 -crf 27 -x264-params cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all -c:a aac -ar 44100 -b:a 128k -map 0 output.mp4
|
||||||
|
input="$1"
|
||||||
|
output="$2"
|
||||||
|
ratio="$3"
|
||||||
|
audio="$4"
|
||||||
|
|
||||||
|
if [[ -z "$input" ]]; then
|
||||||
|
cat <<- EOF
|
||||||
|
Usage: pv-yify INPUT_FILE [OUTPUT_FILE] [ASPECT_RATIO]
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
- Create file raw.mp4.pv-yify.mp4 without changing aspect ratio:
|
||||||
|
$ pv-yify raw.mp4
|
||||||
|
|
||||||
|
- Compress a video and ensures it is 720p:
|
||||||
|
$ pv-yify raw.mp4 compressed.mp4 1280:720
|
||||||
|
|
||||||
|
- Compress a video ensuring that it is 720 pixels tall:
|
||||||
|
$ pv-yify raw.mp4 vertical.mp4 720:-1
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$output" ]]; then
|
||||||
|
output="$input.pv-yify.mp4"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\n`date` - Converting '$input' with YIFY-like compression to '$output'."
|
||||||
|
|
||||||
|
if [[ -f "$output" ]]; then
|
||||||
|
echo -e "\n`date` - Moving '$output' to TRASH."
|
||||||
|
mv -v "$output" ~/TRASH/
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$ratio" ]]; then
|
||||||
|
if [[ "$ratio" != *":"* ]]; then
|
||||||
|
echo "ERROR: Optional ratio parameter needs to be like '-1:720' (horizontal) or '720:-1' (vertical)".
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
size="-filter:v scale=$ratio"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$audio" ]]; then
|
||||||
|
audio="128k"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\n`date` - Starting FFMPEG...\n"
|
||||||
|
set -x
|
||||||
|
ffmpeg -i "$input" \
|
||||||
|
-hide_banner -loglevel level+warning \
|
||||||
|
-c:v libx264 -crf 27 -c:a aac -ar 44100 -b:a "$audio" -map 0 \
|
||||||
|
-x264-params cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all \
|
||||||
|
$ratio \
|
||||||
|
"$output"
|
||||||
|
set +x
|
||||||
|
echo -e "\n`date` - Finished FFMPEG."
|
||||||
|
|
||||||
|
echo -e "\n`date` - Syncing and checking file sizes."
|
||||||
|
sync
|
||||||
|
sleep 5
|
||||||
|
ls -lh "$input" "$output"
|
||||||
|
|
||||||
|
echo -e "\n`date` - Done!"
|
||||||
|
}
|
||||||
|
alias yify="pv-yify "
|
||||||
|
alias yify-pv="pv-yify "
|
||||||
|
|
||||||
function set-pv-all {
|
function set-pv-all {
|
||||||
#set-var PV_VERTICAL_ASPECT_RATIO "y"
|
#set-var PV_VERTICAL_ASPECT_RATIO "y"
|
||||||
set-var PV_V2 "y"
|
set-var PV_V2 "y"
|
||||||
@@ -755,6 +850,64 @@ alias exec-html="run-site"
|
|||||||
alias site-host="run-site"
|
alias site-host="run-site"
|
||||||
alias host-site="run-site"
|
alias host-site="run-site"
|
||||||
|
|
||||||
|
# TBD: Move this to a different section?
|
||||||
|
function git-check {
|
||||||
|
dir="`pwd`"
|
||||||
|
if [[ -n "$1" ]]; then
|
||||||
|
dir="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Checking '$dir' for git changes."
|
||||||
|
ls -d "$dir"/* | while read project; do
|
||||||
|
if [[ ! -d $project ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo -e "\n*** `basename $project` ***"
|
||||||
|
cd $project
|
||||||
|
if [[ -d .git ]]; then
|
||||||
|
git ls-remote --exit-code --heads origin dev
|
||||||
|
dev_exists="$?"
|
||||||
|
if [[ "$dev_exists" == 0 ]]; then
|
||||||
|
git switch dev
|
||||||
|
elif [[ "$dev_exists" == 2 ]]; then
|
||||||
|
git switch main
|
||||||
|
else
|
||||||
|
echo "ERROR: Unknown status for dev_exists, '$dev_exists'."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
git pull
|
||||||
|
git push
|
||||||
|
else
|
||||||
|
echo "Not a Git project, skipping!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo -e "\nDone!"
|
||||||
|
}
|
||||||
|
|
||||||
|
# TBD: Move this to a different section?
|
||||||
|
function check-colors {
|
||||||
|
min=0
|
||||||
|
max=256
|
||||||
|
unset i
|
||||||
|
echo "Current terminal supports '`tput colors`' colors."
|
||||||
|
echo "Displaying examples..."
|
||||||
|
for (( i = min; i <= max; i++ )); do
|
||||||
|
tput setaf $i
|
||||||
|
printf "%03d" "$i"
|
||||||
|
tput sgr0
|
||||||
|
if (( i < max )); then
|
||||||
|
printf " "
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
printf "\n"
|
||||||
|
}
|
||||||
|
alias color-check="check-colors"
|
||||||
|
alias show-colors="check-colors"
|
||||||
|
alias test-colors="check-colors"
|
||||||
|
alias colors="check-colors"
|
||||||
|
alias term-colors="check-colors"
|
||||||
|
alias display-colors="check-colors"
|
||||||
|
|
||||||
|
|
||||||
## Finalize ##
|
## Finalize ##
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user