generated from me/template-mit
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).
This commit is contained in:
+40
-6
@@ -810,14 +810,22 @@ function pv-test {
|
|||||||
|
|
||||||
echo -e " * * Loop Settings * * \n"
|
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
|
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
|
if (( $size_in == 0 )); then
|
||||||
size_in=720
|
size_in=720
|
||||||
fi
|
fi
|
||||||
echo -e " size: '$size_in'\n"
|
echo -e " size: '$size_in'\n"
|
||||||
|
|
||||||
vcodecs="libx264 libsvtav1"
|
vcodecs="libsvtav1"
|
||||||
read -p "Please provide the video codecs to test: [$vcodecs] " test_vcodecs
|
read -p "Please provide the video codecs to test: [$vcodecs] " test_vcodecs
|
||||||
if [[ -n "$test_vcodecs" ]]; then
|
if [[ -n "$test_vcodecs" ]]; then
|
||||||
vcodecs="$test_vcodecs"
|
vcodecs="$test_vcodecs"
|
||||||
@@ -886,7 +894,7 @@ function pv-test {
|
|||||||
normalize=""
|
normalize=""
|
||||||
typeset -u normalize_in
|
typeset -u normalize_in
|
||||||
read -p "Would you like to normalize the audio? (Y/n) " 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"
|
normalize="-filter:a dynaudnorm=f=33:g=65:p=0.66:m=33.3"
|
||||||
fi
|
fi
|
||||||
echo -e " normalize: '$normalize'\n"
|
echo -e " normalize: '$normalize'\n"
|
||||||
@@ -898,6 +906,14 @@ function pv-test {
|
|||||||
fi
|
fi
|
||||||
echo -e " extensions: '$exts'\n"
|
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 #
|
# Final Check #
|
||||||
|
|
||||||
echo -e " * * Confirmation * * \n"
|
echo -e " * * Confirmation * * \n"
|
||||||
@@ -1055,14 +1071,15 @@ function pv-test {
|
|||||||
frequency="-ar $afreq"
|
frequency="-ar $afreq"
|
||||||
fi
|
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"
|
echo -e " * [Loop $count/$guess] Parameters for this test: $newfile * \n"
|
||||||
|
|
||||||
if [[ -e "$newfile" ]]; then
|
if [[ -e "$newfile" ]]; then
|
||||||
mv -v "$newfile" ~/TRASH/
|
mv -v "$newfile" ~/TRASH/
|
||||||
echo -e "Removed unfinished version of this file.\n"
|
echo -e "Removed unfinished version of this file.\n"
|
||||||
fi
|
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"
|
echo -e "Completed version of this file already exists, skipping.\n"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -1093,8 +1110,25 @@ function pv-test {
|
|||||||
printf -v padded_mins "%03d" "$minutes"
|
printf -v padded_mins "%03d" "$minutes"
|
||||||
printf -v padded_secs "%02d" "$seconds"
|
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
|
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
|
else
|
||||||
echo "ERROR: ffmpeg exited with status $status, not renaming file."
|
echo "ERROR: ffmpeg exited with status $status, not renaming file."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user