I like to listen to audiobooks sometimes when I am walking and relaxing, and I like to listen to them on an iPod, but usually when I find them they are split up into a large number of mp3 files, and the iPod does not deal with them very well.
After getting sufficiently annoyed at the problem I decided it was time to find a way to join the files together into one, so it was easier to manage, also it would be nice to be able to reliably resume in the same place as I left off, it would keep resuming several minutes away from where I paused it.
The results of my tinkering was a small script to decode a directory of mp3 files, and then encode the resulting audio stream into a single constant bitrate mp3 file. I used a 64kbit rate since I was only dealing with speech.
#!/bin/bash [ "$1" ] || { echo use: $0 directory exit 0 } for file in "$1"/*; do ffmpeg -i "$file" -acodec pcm_s16be -f s16be -ar 44100 -ac 2 - done | lame -r -x -b 64 --cbr -s 44.1 --bitwidth 16 -m j - "$1".mp3The script takes a directory as a parameter, and outputs an mp3 file by the same name. Remember to leave the trailing slash off the directory name, unless you want to get a hidden mp3 file in that directory as a result.
No comments:
Post a Comment