How to re-encode a MP3 audiobook to fit on a MP3 player?

Say, you have a large MP3 audio book (or song file collection; in this case, the Bible) and want it to fit on a MP3 player, but it does not fit. Then you can re-encode it, using lame on Linux. While a 128kbps MP3 file (normal audio book quality) has approx. 1MiByte/min, a “lame -V9” variable birate maximum compression MP3 has just 0.4MiByte/min. When allplied to spoken language, the loss in quality is only a little.

To convert your audio book (stored in dirs and files below them), use the following:

for dir in *; do 
  for file in "$dir"/*; do 
    lame -V 9 "$file" "${file/.mp3/_V9.mp3}"; 
  done; 
done;

Then, to sort out the newly generated files, and rename them to short names, do the following:

mkdir AudioBookV9;
for dir in AudioBook/*; do 
  mkdir "${dir/AudioBook/AudioBookV9}"; 
  mv $dir/*_V9.mp3 "${dir/AudioBook/AudioBookV9}"; 
done;
for file in AudioBookV9/*/*; do 
  mv "$file" "${file/_V9.mp3/.mp3}"; 
done;

You now have all relevant files in directoy AudioBookV9, and if the size fits (check with “du -h AudioBookV9”), you want to transfer that to your MP3 player. So mount your MP3 player as a mass storage device (here, to /media/misc/), and do this:

for dir in AudioBookV9/*; do 
  sudo mkdir "/media/misc/${dir/AudioBookV9/}"; 
done;
for file in AudioBookV9/*/*; do 
  sudo cp "$file" "/media/misc/${file/AudioBookV9/}"; 
done;

Here, note that we don’t simply copy the whole AudioBookV9/* stuff recursively. This will work in most cases, but for the KINGZON MP3 Player M3ZH it did not. Here, the order in which files are written to the device is important, as “normal playing mode” means that the device plays files in this order, not in alphabetical order. Copying whole directories makes the files being written in the order they appear in the directory tables, so you’ll have all your chapters mixed up on the device. So use the workaround, or you’ll hear the end of your fascinating novel way too early 😉


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.