#!/bin/bash
# Hack to avoid using the Nokia Audiobooks application
# No hassle with Windoze plus conversion is faster too
# The script just takes one single compulsory parameter: book_title
# Execute it in a directory contaning the mp3s plus a single cover jpg
# Any file names are fine
# Output files are in the folder ./book_title
# This folder can be moved as-is to the Audiobooks directory in the phone
# Change the parameters to amrwb-encoder if you want more compression, etc
# Change the chapter values by hand in the index file if you're a perfectionist
# Note: some sections are optional in theory (chapters, content_info),
# but removing some of them breaks the program
# Required packages (Debian): mpg321, resample, amrwb, mplayer
# Courtesy of Fezouro (Ubuntu forums)
index="/tmp/index.inx"
tmp="/tmp/tmp.wav"
tmp2="/tmp/tmp2.wav"
rm -f $tmp $tmp2 $index
mkdir "$1";
echo "#BOOK" > $index
echo "$1;" >> $index
echo "#PIC" >> $index
echo "$1.jpg;" >> $index
echo "#TRACKS" >> $index
find . -maxdepth 1 -iname "*mp3" | sort | while read i; do
j=`basename "$i" .mp3`
base=`basename "$j" .MP3`
out="$base.awb"
mpg321 -q -w $tmp "$i"
resample -to 16000 -terse $tmp $tmp2 # resample to awb rate
lengthd=`mplayer -vo null -ao null -frames 0 -identify $tmp2 2>/dev/null | grep ID_LENGTH | awk -F= '{print $2}'` # length in seconds
length=`echo "scale=0;$lengthd/1" | bc` # remove decimals
amrwb-encoder -dtx 7 $tmp2 "$1/$out" # convert to awb
echo "$out:$length;" >> $index
rm -f $tmp $tmp2
done
echo "#CHAPTERS" >> $index
chapter=1;
find . -maxdepth 1 -iname "*mp3" | sort | while read i; do
j=`basename "$i" .mp3`
base=`basename "$j" .MP3`
out="$base.awb"
echo "$out:0s:$chapter:$base;" >> $index
chapter=$(($chapter+1))
done
echo "#VERSION" >> $index
echo "0.7;" >> $index
echo "#CONTENT_INFO" >> $index
echo "NokiaAudiobookManagerVersion=Hack by Fezouro;" >> $index
echo "CodecMode=7;" >> $index
echo "CodecBitRate=23050;" >> $index
echo "DTX=1;" >> $index
echo "SBRA=0;" >> $index
echo "SBRA_Rate=900;" >> $index
echo "InputFormat=2;" >> $index
# index must be in little endian UTF-16 unicode format
iconv -t UTF-16 $index > "$1/$1.inx"
# copy book cover with right name
cover=`find . -maxdepth 1 -iname \*.jpg`
cp "$cover" "$1/$1.jpg"
rm -f $tmp $tmp2 $index
нашол на на бетта лабс все пишут что рабатаетсам пока не проверил