From a5e1dd6a3690490f651b60a18fe0fcb0ca285a2e Mon Sep 17 00:00:00 2001 From: Hyperling Date: Wed, 16 Sep 2026 11:29:47 -0700 Subject: [PATCH] pv-test, add ability to specift the basename and automatically have the bitrate appended to the filename (without harming ability to detect completion of previous test). --- rc_shared.sh | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/rc_shared.sh b/rc_shared.sh index a76c20b..d54a5d0 100644 --- a/rc_shared.sh +++ b/rc_shared.sh @@ -810,14 +810,22 @@ function pv-test { echo -e " * * Loop Settings * * \n" + basename="`basename "$filename_in"`" + basename_in="" + read -p "Would you like to specify a basename? [$basename] " basename_in + if [[ -n "$basename_in" ]]; then + basename="$basename_in" + fi + echo -e " basename: '$basename'\n" + typeset -i size_in - read -p "What display ratio would you like to use? (720) " 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" - vcodecs="libx264 libsvtav1" + vcodecs="libsvtav1" read -p "Please provide the video codecs to test: [$vcodecs] " test_vcodecs if [[ -n "$test_vcodecs" ]]; then vcodecs="$test_vcodecs" @@ -886,7 +894,7 @@ function pv-test { 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 + 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" @@ -898,6 +906,14 @@ function pv-test { fi echo -e " extensions: '$exts'\n" + bitrate_check="" + typeset -u bitrate_in + read -p "Would you like to append the bitrate to the filename? (Y/n) " bitrate_in + if [[ "$bitrate_in" != "N"* && $bitrate_in != "F"* ]]; then + bitrate_check="Y" + fi + echo -e " bitrate_check: '$bitrate_check'\n" + # Final Check # echo -e " * * Confirmation * * \n" @@ -1055,14 +1071,15 @@ function pv-test { frequency="-ar $afreq" fi - newfile="_${size_in}p_${vcodec}-${vpreset}-${crf}-${vbr}${ofn}${ufn}_${acodec}-${abr}-${achannel}-${afreq}.${ext}" + ext=".$ext" + newfile="_${size_in}p_${vcodec}-${vpreset}-${crf}-${vbr}${ofn}${ufn}_${acodec}-${abr}-${achannel}-${afreq}${ext}" echo -e " * [Loop $count/$guess] 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 + if [[ `ls *"${newfile//$ext/}"*"$ext"* 2>/dev/null` ]]; then echo -e "Completed version of this file already exists, skipping.\n" continue fi @@ -1093,8 +1110,25 @@ function pv-test { printf -v padded_mins "%03d" "$minutes" printf -v padded_secs "%02d" "$seconds" + bitrate=""; bitrate_padded=""; + if [[ "$bitrate_check" == "Y" ]]; then + j="" + for i in `ffprobe "$newfile" 2>&1 | grep bitrate`; do + # Previous loop was the 'bitrate' label, so get bitrate now. + if [[ "$j" == 'bitrate:' ]]; then + bitrate="$i" + printf -v bitrate_padded "%05d" "$bitrate" + fi + # Previous loop was the bitrate, so get the units now. + if [[ "$j" == "$bitrate" ]]; then + bitrate="_""$bitrate_padded${i//\//p}" + fi + j="$i" + done + fi + if [[ "$status" == 0 && -s "$newfile" ]]; then - mv -v "$newfile" "$(basename "${filename_in}_${padded_mins}m${padded_secs}s${newfile}")" + mv -v "$newfile" "${basename}_${padded_mins}m${padded_secs}s${newfile//$ext/$bitrate$ext}" else echo "ERROR: ffmpeg exited with status $status, not renaming file." fi