generated from me/template-mit
pv-test, another large refactor which allows typing custom tests in while keeping some loops as questions, enhanced output and the handling of loop indentation, use more -n checks to avoid whitespace issues.
This commit is contained in:
+108
-53
@@ -797,39 +797,6 @@ function pv-test {
|
||||
fi
|
||||
echo " size: '$size_in'"
|
||||
|
||||
# Loop Data #
|
||||
|
||||
echo "Setting some defaults..."
|
||||
vcodecs="libx264 libsvtav1 libx265" && echo " video codecs: '$vcodecs'"
|
||||
acodecs="aac libopus" && echo " audio codecs: '$acodecs'"
|
||||
exts="mkv" && echo " extensions: '$exts'" # mp4
|
||||
|
||||
declare -l {vpreset,crf,vbr,abr}s="skip"
|
||||
|
||||
read -p "Test presets? (y/N) " test_vpresets
|
||||
if [[ "$test_vpresets" == "y"* ]]; then
|
||||
vpresets="$vpresets slw med fst"
|
||||
fi
|
||||
echo " presets: '$vpresets'"
|
||||
|
||||
read -p "Test CRFs? (y/N) " test_crfs
|
||||
if [[ "$test_crfs" == "y"* ]]; then
|
||||
crfs="$crfs 24 26 28 30 32"
|
||||
fi
|
||||
echo " CRFs: '$crfs'"
|
||||
|
||||
read -p "Test video bitrates? (y/N) " test_vbrs
|
||||
if [[ "$test_vbrs" == "y"* ]]; then
|
||||
vbrs="$vbrs 1500k 2000k 2500k"
|
||||
fi
|
||||
echo " video bitrates: '$vbrs'"
|
||||
|
||||
read -p "Test audio bitrates? (y/N) " test_abrs
|
||||
if [[ "$test_abrs" == "y"* ]]; then
|
||||
abrs="$abrs 128k 192k"
|
||||
fi
|
||||
echo " audio bitrates: '$abrs'"
|
||||
|
||||
# Existing Functions #
|
||||
|
||||
declare -l pv{,2}="n"
|
||||
@@ -850,13 +817,87 @@ function pv-test {
|
||||
echo " skipping"
|
||||
fi
|
||||
|
||||
# Loop Data #
|
||||
|
||||
declare -l {vpreset,crf,vbr,abr,achannel,afreq}s="default"
|
||||
|
||||
echo -e "\n * * Loop Settings * * \n"
|
||||
|
||||
vcodecs="libx264"
|
||||
read -p "Video codec libx264 always enabled, add testing of libx265 and libsvtav1? (Y/n) " test_vcodecs
|
||||
if [[ -z "$test_vcodecs" || "$test_vcodecs" == "y"* ]]; then
|
||||
vcodecs="$vcodecs libsvtav1 libx265"
|
||||
fi
|
||||
read -p "Please provide any additional video codecs: " test_vcodecs
|
||||
if [[ -n "$test_vcodecs" ]]; then
|
||||
vcodecs="$vcodecs $test_vcodecs"
|
||||
fi
|
||||
echo " video codecs: '$vcodecs'"
|
||||
|
||||
read -p "Test the video codec's slowest, medium, fastest presets? (y/N) " test_vpresets
|
||||
if [[ "$test_vpresets" == "y"* ]]; then
|
||||
vpresets="slw med fst"
|
||||
fi
|
||||
echo " presets: '$vpresets'"
|
||||
|
||||
read -p "Please provide any CRFs to test: [default] " test_crfs
|
||||
if [[ -n "$test_vcodecs" ]]; then
|
||||
crfs="$test_crfs"
|
||||
fi
|
||||
echo " CRFs: '$crfs'"
|
||||
|
||||
read -p "Please provide any video bitrates to test: [default] " test_vbrs
|
||||
if [[ -n "$test_vbrs" ]]; then
|
||||
vbrs="$test_vbrs"
|
||||
fi
|
||||
echo " video bitrates: '$vbrs'"
|
||||
|
||||
echo " "
|
||||
|
||||
acodecs="aac"
|
||||
read -p "Audio codec aac always enabled, add testing of libopus? (Y/n) " test_acodecs
|
||||
if [[ -z "$test_acodecs" || "$test_acodecs" == "y"* ]]; then
|
||||
acodecs="$acodecs libopus"
|
||||
fi
|
||||
read -p "Please provide any additional audio codecs: " test_acodecs
|
||||
if [[ -n "$test_acodecs" ]]; then
|
||||
acodecs="$acodecs $test_acodecs"
|
||||
fi
|
||||
echo " audio codecs: '$acodecs'"
|
||||
|
||||
read -p "Please provide any audio bitrates to test: [default] " test_abrs
|
||||
if [[ -n "$test_abrs" ]]; then
|
||||
abrs="$test_abrs"
|
||||
fi
|
||||
echo " audio bitrates: '$abrs'"
|
||||
|
||||
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 " audio channels: '$achannels'"
|
||||
|
||||
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 " audio frequencies: '$afreqs'"
|
||||
|
||||
read -p "Please provide any containers to test with: [mkv] " test_exts
|
||||
if [[ -n "$test_exts" ]]; then
|
||||
exts="$test_exts"
|
||||
fi
|
||||
echo " extensions: '$exts'"
|
||||
|
||||
# Final Check #
|
||||
|
||||
echo -e "\n * * Confirmation * * \n"
|
||||
|
||||
typeset -u okay
|
||||
echo -e "\nTesting all these using '$filename_in'"
|
||||
echo "Testing all these using '$filename_in'"
|
||||
read -p "Does everything look okay? (Y/n) " okay
|
||||
if [[ "$okay" == "N" || "$okay" == "F"* ]]; then
|
||||
echo "* Not okay, aborting."
|
||||
echo " Not okay, aborting."
|
||||
return 1
|
||||
fi
|
||||
echo -e "Sounds good, here we go!\n"
|
||||
@@ -884,17 +925,16 @@ function pv-test {
|
||||
|
||||
echo -e "\nStarting the loop...\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 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" != "skip" ]]; then
|
||||
if [[ "$vpreset" != "default" ]]; then
|
||||
if [[ "$vcodec" == "libsvtav1" ]]; then
|
||||
case $vpreset in
|
||||
slw) preset="0" ;;
|
||||
@@ -916,10 +956,10 @@ function pv-test {
|
||||
fi
|
||||
|
||||
bitrate=""
|
||||
if [[ "$crf" != "skip" ]]; then
|
||||
if [[ "$crf" != "default" ]]; then
|
||||
bitrate="-crf $crf"
|
||||
fi
|
||||
if [[ "$vbr" != "skip" ]]; then
|
||||
if [[ "$vbr" != "default" ]]; then
|
||||
if [[ "$vcodec" == "libsvtav1" ]]; then
|
||||
bitrate="$bitrate -svtav1-params rc=1:tbr=$vbr:overshoot-pct=0:undershoot-pct=100"
|
||||
else
|
||||
@@ -928,11 +968,21 @@ function pv-test {
|
||||
fi
|
||||
|
||||
fidelity=""
|
||||
if [[ "$abr" != "skip" ]]; then
|
||||
if [[ "$abr" != "default" ]]; then
|
||||
fidelity="-b:a $abr"
|
||||
fi
|
||||
|
||||
newfile="_${size_in}p_${vcodec}-${vpreset}-${vbr}${crf}_${acodec}-${abr}.${ext}"
|
||||
channel=""
|
||||
if [[ "$achannel" != "default" ]]; then
|
||||
channel="-ac $achannel"
|
||||
fi
|
||||
|
||||
frequency=""
|
||||
if [[ "$afreq" != "default" ]]; then
|
||||
frequency="-ar $afreq"
|
||||
fi
|
||||
|
||||
newfile="_${size_in}p_${vcodec}-${vpreset}-${crf}-${vbr}_${acodec}-${abr}-${achannel}-${afreq}.${ext}"
|
||||
if [[ -e "$newfile" ]]; then
|
||||
mv -v "$newfile" ~/TRASH/
|
||||
fi
|
||||
@@ -950,6 +1000,8 @@ function pv-test {
|
||||
$bitrate \
|
||||
-c:a $acodec \
|
||||
$fidelity \
|
||||
$channel \
|
||||
$frequency \
|
||||
$normalize \
|
||||
-movflags +faststart \
|
||||
"$newfile"
|
||||
@@ -964,17 +1016,20 @@ function pv-test {
|
||||
mv -v "$newfile" "$(basename "${filename_in}_${padded_mins}m${padded_secs}s${newfile}")"
|
||||
|
||||
echo -e "\n* Finished in ${minutes}m${seconds}s!\n"
|
||||
count=$(( count++ ))
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
done done
|
||||
done done
|
||||
done done
|
||||
done done
|
||||
|
||||
## Finish ##
|
||||
|
||||
echo "Done! :)"
|
||||
plural=""
|
||||
if (( $count != 1 )); then
|
||||
plural="s"
|
||||
fi
|
||||
echo "Completed tests after ${count} loop${plural}! :)"
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user