I'm writing a shell script for Linux, using Bash, to translate any video-file into a MP4. For that, I'm using avconv
with libvorbis
for audio.
Inside my script, I have a question for the user :
read -p "- Audio Quality [scale from -2 to 10] ? "
if [ -n "$REPLY" ] ; then
ABITRATE="-aq $REPLY"
fi
My "ABITRATE" string goes into the final avconv
command-line.
But I would like to give the user the opportunity to answer that question with a value in Kb (Kilobit), and translate it into the scale that libvorbis
uses.
The "scale from -2 to 10" is this :
Quality Kbit/s Normalization
-----------------------------
-2 ~32 y
-1 ~48 y
0 ~64 y
1 ~80 y
2 ~96 y
3 ~112 y
4 ~128 n
5 ~160 n
6 ~192 n
7 ~224 n
8 ~256 n
9 ~320 n
10 ~500 n
I would like to know how to check if my $REPLY is in a range of number. For example, I would like my script to do something like this :
if [ $REPLY is a number between 1 and 32 ] ; then
REPLY="-2"
elif [ $REPLY is a number between 33 and 48 ] ; then
REPLY="-1"
fi
Is this possible (I'm willing to say 'yes of course, shouldn't be hard' but I don't know the syntax to use) ?