generated from me/template-mit
pv-test, continuing the usability and output enhancements. Now recognizes if an unfinished version needs re-done, if the finished test already exists, and checks ffmpeg status before committing the file.
This commit is contained in:
+73
-45
@@ -788,14 +788,14 @@ function pv-test {
|
||||
if [[ $normalize_in != "N"* && $normalize_in != "F"* ]]; then
|
||||
normalize="-filter:a dynaudnorm=f=33:g=65:p=0.66:m=33.3"
|
||||
fi
|
||||
echo " normalize: '$normalize'"
|
||||
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 " size: '$size_in'"
|
||||
echo -e " size: '$size_in'\n"
|
||||
|
||||
# Existing Functions #
|
||||
|
||||
@@ -809,6 +809,7 @@ function pv-test {
|
||||
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"
|
||||
@@ -816,82 +817,74 @@ function pv-test {
|
||||
else
|
||||
echo " skipping"
|
||||
fi
|
||||
echo " "
|
||||
|
||||
# Loop Data #
|
||||
|
||||
declare -l {vpreset,crf,vbr,abr,achannel,afreq}s="default"
|
||||
|
||||
echo -e "\n * * Loop Settings * * \n"
|
||||
echo -e " * * 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
|
||||
vcodecs="libx264 libsvtav1 libx265"
|
||||
read -p "Please provide the video codecs to test: [$vcodecs] " test_vcodecs
|
||||
if [[ -n "$test_vcodecs" ]]; then
|
||||
vcodecs="$vcodecs $test_vcodecs"
|
||||
vcodecs="$test_vcodecs"
|
||||
fi
|
||||
echo " video codecs: '$vcodecs'"
|
||||
echo -e " video codecs: '$vcodecs'\n"
|
||||
|
||||
read -p "Test the video codec's slowest, medium, fastest presets? (y/N) " test_vpresets
|
||||
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 " presets: '$vpresets'"
|
||||
echo -e " presets: '$vpresets'\n"
|
||||
|
||||
read -p "Please provide any CRFs to test: [default] " test_crfs
|
||||
if [[ -n "$test_vcodecs" ]]; then
|
||||
if [[ -n "$test_crfs" ]]; then
|
||||
crfs="$test_crfs"
|
||||
fi
|
||||
echo " CRFs: '$crfs'"
|
||||
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 " video bitrates: '$vbrs'"
|
||||
echo -e " video bitrates: '$vbrs'\n"
|
||||
|
||||
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
|
||||
acodecs="aac libopus"
|
||||
read -p "Please provide the audio codecs to test: [$acodecs] " test_acodecs
|
||||
if [[ -n "$test_acodecs" ]]; then
|
||||
acodecs="$acodecs $test_acodecs"
|
||||
acodecs="$test_acodecs"
|
||||
fi
|
||||
echo " audio codecs: '$acodecs'"
|
||||
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 " audio bitrates: '$abrs'"
|
||||
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 " audio channels: '$achannels'"
|
||||
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 " audio frequencies: '$afreqs'"
|
||||
echo -e " audio frequencies: '$afreqs'\n"
|
||||
|
||||
read -p "Please provide any containers to test with: [mkv] " test_exts
|
||||
exts="mkv"
|
||||
read -p "Please provide the containers to test with: [$exts] " test_exts
|
||||
if [[ -n "$test_exts" ]]; then
|
||||
exts="$test_exts"
|
||||
fi
|
||||
echo " extensions: '$exts'"
|
||||
echo -e " extensions: '$exts'\n"
|
||||
|
||||
# Final Check #
|
||||
|
||||
echo -e "\n * * Confirmation * * \n"
|
||||
echo -e " * * Confirmation * * \n"
|
||||
|
||||
typeset -u okay
|
||||
echo "Testing all these using '$filename_in'"
|
||||
@@ -905,25 +898,41 @@ function pv-test {
|
||||
## Main ##
|
||||
|
||||
if [[ "$pv" == "y" ]]; then
|
||||
echo "Starting pv..."
|
||||
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"
|
||||
echo -e " * Testing with 'pv' complete! * \n"
|
||||
fi
|
||||
if [[ "$pv2" == "y" ]]; then
|
||||
echo "Starting pv2..."
|
||||
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"
|
||||
echo -e " * Testing with 'pv2' complete! * \n"
|
||||
fi
|
||||
|
||||
echo -e "\nStarting the loop...\n"
|
||||
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
|
||||
@@ -940,14 +949,14 @@ function pv-test {
|
||||
slw) preset="0" ;;
|
||||
med) preset="6" ;;
|
||||
fst) preset="13" ;;
|
||||
*) echo "ERROR: Unhandled vpreset '${vpreset}', exiting." && return 1
|
||||
*) preset="$vpreset" ;;
|
||||
esac
|
||||
else
|
||||
case $vpreset in
|
||||
slw) preset="veryslow" ;;
|
||||
med) preset="medium" ;;
|
||||
fst) preset="ultrafast" ;;
|
||||
*) echo "ERROR: Unhandled vpreset '${vpreset}', exiting" && return 1
|
||||
*) preset="$vpreset" ;;
|
||||
esac
|
||||
fi
|
||||
if [[ -n "$preset" ]]; then
|
||||
@@ -979,16 +988,30 @@ function pv-test {
|
||||
|
||||
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 "Unfinished version of this file already exists, removing."
|
||||
rm -v "$newfile" ~/TRASH/
|
||||
fi
|
||||
if [[ -e *"$newfile" ]]; then
|
||||
echo "Completed version of this file already exists, skipping."
|
||||
continue
|
||||
fi
|
||||
|
||||
echo -e "\n* Starting new run...\n"
|
||||
echo -e "Parameters for this run: $newfile\n"
|
||||
echo "Starting run..."
|
||||
|
||||
start=$SECONDS
|
||||
set -x
|
||||
@@ -1005,6 +1028,7 @@ function pv-test {
|
||||
$normalize \
|
||||
-movflags +faststart \
|
||||
"$newfile"
|
||||
status="$?"
|
||||
set +x
|
||||
finish=$SECONDS
|
||||
|
||||
@@ -1013,10 +1037,14 @@ function pv-test {
|
||||
printf -v padded_mins "%03d" "$minutes"
|
||||
printf -v padded_secs "%02d" "$seconds"
|
||||
|
||||
mv -v "$newfile" "$(basename "${filename_in}_${padded_mins}m${padded_secs}s${newfile}")"
|
||||
if [[ "$status" == 0 ]]; 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=$(( count++ ))
|
||||
echo -e "\n * Finished in ${minutes}m${seconds}s! * \n"
|
||||
(( count++ ))
|
||||
done
|
||||
done done
|
||||
done done
|
||||
|
||||
Reference in New Issue
Block a user