Sunday, May 20, 2007

MP3 to AMR Nokia phones in Linux

Here is a small script I wrote. It allows you to convert MP3 call signals into AMR Nokia format. Put MP3's into directory and run this script from there. Copy and paste this code into amrnokia.sh
chmod 755 ./amrnokia.sh && ./amrnokia.sh

Code itself:
#!/bin/bash
# Audio Bitrate 32 for Nokia
# 64, 80, 128 is ok too
#
for MP3 in *.mp3; do
if [[ -e $MP3 ]]; then
  echo "Converting $MP3 into amr Nokia file"
  ffmpeg -i "$MP3" -acodec amr_nb -ar 8000 \
    -ac 1 -ab 128 "${MP3%.mp3}.amr"
  echo -e "\r"
  echo "- - - 8< - - - - CUT HERE - - - -"
  echo -e "\r"
  sleep 1
 else
  echo "Found no source for $MP3 -- \
    leaving it untouched!"
fi
done
echo -e "\rThat's it ... ;-)"

No comments: