Compare commits

..
1 Commits
Author SHA1 Message Date
me 1f7a1f5883 Merge pull request 'Promote Stable Version' (#1) from prod into main
Reviewed-on: #1
2026-08-05 15:44:03 -07:00
+14 -361
View File
@@ -771,353 +771,6 @@ alias vta="v2a"
alias pull-audio="v2a"
alias pa="v2a"
# Run all the different codecs, wrappers, bitrates, etc on a file.
function pv-test {
echo -e "Welcome! Let's get your tests set up...\n"
## Input ##
filename_in="$1"
while [[ -z "$filename_in" ]]; do
read -p "Please provide the filename: " filename_in
done
# Persistent Data #
normalize=""
typeset -u normalize_in
read -p "Would you like to normalize the audio? (Y/n) " normalize_in
if [[ $normalize_in != "N"* && $normalize_in != "F"* ]]; then
normalize="-filter:a dynaudnorm=f=33:g=65:p=0.66:m=33.3"
fi
echo -e " normalize: '$normalize'\n"
typeset -i size_in
read -p "What display ratio would you like to use? (720) " size_in
if (( $size_in == 0 )); then
size_in=720
fi
echo -e " size: '$size_in'\n"
# Existing Functions #
declare -l pv{,2}="n"
typeset -l test_pv{,2}
read -p "Create a test with current 'pv' function? (Y/n) " test_pv
if [[ -z "$test_pv" || "$test_pv" == "y"* ]]; then
pv="y"
echo " great, will run pv"
else
echo " skipping"
fi
echo " "
read -p "Create a test with current 'pv2' function? (Y/n) " test_pv2
if [[ -z "$test_pv2" || "$test_pv2" == "y"* ]]; then
pv2="y"
echo " great, will run pv2"
else
echo " skipping"
fi
echo " "
# Loop Data #
declare -l {vpreset,crf,vbr,abr,achannel,afreq}s="default"
echo -e " * * Loop Settings * * \n"
vcodecs="libx264 libsvtav1 libx265"
read -p "Please provide the video codecs to test: [$vcodecs] " test_vcodecs
if [[ -n "$test_vcodecs" ]]; then
vcodecs="$test_vcodecs"
fi
echo -e " video codecs: '$vcodecs'\n"
read -p "Test the video codec's slowest, medium, and fastest presets? (y/N) " test_vpresets
if [[ "$test_vpresets" == "y"* ]]; then
vpresets="slw med fst"
fi
echo -e " presets: '$vpresets'\n"
read -p "Please provide any CRFs to test: [default] " test_crfs
if [[ -n "$test_crfs" ]]; then
crfs="$test_crfs"
fi
echo -e " CRFs: '$crfs'\n"
read -p "Please provide any video bitrates to test: [default] " test_vbrs
if [[ -n "$test_vbrs" ]]; then
vbrs="$test_vbrs"
fi
echo -e " video bitrates: '$vbrs'\n"
acodecs="aac libopus"
read -p "Please provide the audio codecs to test: [$acodecs] " test_acodecs
if [[ -n "$test_acodecs" ]]; then
acodecs="$test_acodecs"
fi
echo -e " audio codecs: '$acodecs'\n"
read -p "Please provide any audio bitrates to test: [default] " test_abrs
if [[ -n "$test_abrs" ]]; then
abrs="$test_abrs"
fi
echo -e " audio bitrates: '$abrs'\n"
read -p "Test both mono and stereo audio channels? (y/N) " test_achannels
if [[ "$test_achannels" == "y"* ]]; then
achannels="1 2" # 1 is mono, 2 is stereo
fi
echo -e " audio channels: '$achannels'\n"
read -p "Test both 48 and 44.1 kHz audio frequencies? (y/N) " test_afreqs
if [[ "$test_afreqs" == "y"* ]]; then
afreqs="48000 44100" # 48 typically found in videos, 44.1 in audio.
fi
echo -e " audio frequencies: '$afreqs'\n"
exts="mkv"
read -p "Please provide the containers to test with: [$exts] " test_exts
if [[ -n "$test_exts" ]]; then
exts="$test_exts"
fi
echo -e " extensions: '$exts'\n"
# Final Check #
echo -e " * * Confirmation * * \n"
ffprobe -i "$filename_in"
echo -e "\n * Testing against '$filename_in' above. * \n"
typeset -u okay
read -p "Does everything look okay? (Y/n) " okay
if [[ "$okay" == "N" || "$okay" == "F"* ]]; then
echo " Not okay, aborting."
return 1
fi
echo -e "Sounds good, here we go!\n"
## Main ##
if [[ "$pv" == "y" ]]; then
echo " * Starting pv... * "
filename_pv="$(basename "${filename_in}-pv.mkv")"
if [[ -e "$filename_pv" ]]; then
mv -v "$filename_pv" ~/TRASH
fi
pv "$filename_in" "$filename_pv"
echo -e " * Testing with 'pv' complete! * \n"
fi
if [[ "$pv2" == "y" ]]; then
echo " * Starting pv2... * "
filename_pv2="$(basename "${filename_in}-pv2.mkv")"
if [[ -e "$filename_pv2" ]]; then
mv -v "$filename_pv2" ~/TRASH
fi
pv "$filename_in" "$filename_pv2"
echo -e " * Testing with 'pv2' complete! * \n"
fi
count=0
for vcodec in $vcodecs; do for vpreset in $vpresets; do
for crf in $crfs; do for vbr in $vbrs; do
for acodec in $acodecs; do for abr in $abrs;
do for achannel in $achannels; do for afreq in $afreqs; do
for ext in $exts; do
(( count++ ))
done
done done
done done
done done
done done
plural=""
if (( $count != 1 )); then
plural="s"
fi
echo -e "Expecting ${count} loop${plural}, please be patient.\n"
count=0
unset vcodec vpreset crf vbr acodec abr ext
for vcodec in $vcodecs; do for vpreset in $vpresets; do
for crf in $crfs; do for vbr in $vbrs; do
for acodec in $acodecs; do for abr in $abrs;
do for achannel in $achannels; do for afreq in $afreqs; do
for ext in $exts; do
preset=""
if [[ "$vpreset" != "default" ]]; then
if [[ "$vcodec" == "libsvtav1" ]]; then
case $vpreset in
slw) preset="0" ;;
med) preset="6" ;;
fst) preset="13" ;;
*) preset="$vpreset" ;;
esac
else
case $vpreset in
slw) preset="veryslow" ;;
med) preset="medium" ;;
fst) preset="ultrafast" ;;
*) preset="$vpreset" ;;
esac
fi
if [[ -n "$preset" ]]; then
preset="-preset $preset"
fi
fi
bitrate=""
if [[ "$crf" != "default" ]]; then
bitrate="-crf $crf"
fi
if [[ "$vbr" != "default" ]]; then
if [[ "$vcodec" == "libsvtav1" ]]; then
bitrate="$bitrate -svtav1-params rc=1:tbr=$vbr:overshoot-pct=0:undershoot-pct=100"
else
bitrate="$bitrate -b:v $vbr -minrate 0 -maxrate $vbr -bufsize $vbr"
fi
fi
fidelity=""
if [[ "$abr" != "default" ]]; then
fidelity="-b:a $abr"
fi
channel=""
if [[ "$achannel" != "default" ]]; then
channel="-ac $achannel"
fi
frequency=""
if [[ "$afreq" != "default" ]]; then
if [[ "$acodec" == "libopus" ]]; then
case $afreq in
48000) ;; 24000) ;; 16000) ;; 12000) ;; 8000) ;;
*) echo -e "ERROR: libopus cannot do this, skipping frequency ${afreq}."
continue
;;
esac
fi
frequency="-ar $afreq"
fi
newfile="_${size_in}p_${vcodec}-${vpreset}-${crf}-${vbr}_${acodec}-${abr}-${achannel}-${afreq}.${ext}"
echo -e " * Parameters for this test: $newfile * \n"
if [[ -e "$newfile" ]]; then
mv -v "$newfile" ~/TRASH/
echo -e "Removed unfinished version of this file.\n"
fi
if [[ `ls *"$newfile" 2>/dev/null` ]]; then
echo -e "Completed version of this file already exists, skipping.\n"
continue
fi
echo "$(date) - Starting run..."
start=$SECONDS
set -x
ffmpeg -nostdin -hide_banner -loglevel level+warning \
-i "$filename_in" \
-filter:v scale=-1:$size_in \
-c:v $vcodec \
$preset \
$bitrate \
-c:a $acodec \
$fidelity \
$channel \
$frequency \
$normalize \
-movflags +faststart \
"$newfile"
status="$?"
set +x
finish=$SECONDS
minutes=$(( (finish - start) / 60 ))
seconds=$(( (finish - start) % 60 ))
printf -v padded_mins "%03d" "$minutes"
printf -v padded_secs "%02d" "$seconds"
if [[ "$status" == 0 && -s "$newfile" ]]; then
mv -v "$newfile" "$(basename "${filename_in}_${padded_mins}m${padded_secs}s${newfile}")"
else
echo "ERROR: ffmpeg exited with status $status, not renaming file."
fi
echo -e "\n * Finished in ${minutes}m${seconds}s! * \n"
(( count++ ))
done
done done
done done
done done
done done
## Finish ##
plural=""
if (( $count != 1 )); then
plural="s"
fi
echo "Completed tests after ${count} loop${plural}! :)"
}
# 20260914 - After playing with pv-test for a while.
function pv3 {
org="$1"
out="$2"
echo "Processing '$org' to '$out' using AV1 and OPUS."
## Versions ##
# v0
preset=0 # took 20 minutes where preset 2 was under 2 minutes
crf=18
vbr=2000k # this is creating 2Mbps files, not maxxing at 2.
overshoot=0
undershoot=100
# v1
preset=2 # WAY faster and still great.
crf=28 # much smaller filesize
# v2
vbr=1000k
overshoot=100
## Main ##
echo -e "\n * Original File * \n"
ffprobe -i "$org"
echo -e "\n * Starting Processing *\n"
date
set -x
ffmpeg -nostdin -hide_banner -loglevel level+warning \
-i "$org" \
-c:v libsvtav1 \
-preset $preset \
-filter:v scale=-1:720 \
-crf $crf \
-svtav1-params rc=1:tbr=${vbr}:overshoot-pct=${overshoot}:undershoot-pct=${undershoot} \
-c:a libopus \
-filter:a dynaudnorm=f=33:g=65:p=0.66:m=33.3 \
-movflags +faststart \
"$out"
status="$?"
set +x
if [[ "$status" != 0 || ! -s "$out" ]]; then
echo "Failed, deleting output."
mv -v "$out" ~/TRASH/
return $status
fi
echo -e "\n * Success! *"
}
### Web ###
@@ -1207,25 +860,25 @@ function git-check {
echo "Checking '$dir' for git changes."
ls -d "$dir"/* | while read project; do
if [[ ! -d $project ]]; then
continue
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 && "$dir" != *".wiki" ]]; then
git switch dev
elif [[ "$dev_exists" == 2 || "$dir" == *".wiki" ]]; then
git switch main
else
echo "ERROR: Unknown status for dev_exists, '$dev_exists'."
continue
fi
git pull
git push
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 "Not a Git project, skipping!"
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!"