Skip to content

Instantly share code, notes, and snippets.

@NigelThorne
Created April 24, 2009 06:58
Show Gist options
  • Save NigelThorne/100996 to your computer and use it in GitHub Desktop.
Save NigelThorne/100996 to your computer and use it in GitHub Desktop.
mp3faster - listen to mp3s quicker
find *.mp3 | ruby -e 'while(x=gets) do `mp3faster \"#{x.chomp}\"`;end'
#!/bin/bash
# mp3faster - script for making mp3 playback faster with soundstretch
#
# debian/ubuntu package requirements
# apt-get install mpg321 soundstretch lame libid3-3.8.3-dev
#
# rhel/centos/fedora package requirements
# yum install mpg321 soundtouch lame id3lib
#
# sample usage for converting all mp3 files in a directory structure:
# find -name "*.mp3" -print0 | xargs -0 -i mp3faster {}
#
# decode mp3 to wav file
# mpg321 --wav "$1.wav" "$1"
# the above decoding technique doesn't always work, and can sometimes
# create a wav file that plays back too fast. Seems to happen with mp3 files that
# have a low bitrate (< 80kbps). Using the lame alternative below get's around this.
# alternative #1 to decoding an mp3 to wav
lame --decode "$1" "$1.wav"
# alternative #2 to decoding an mp3 to wav
# mpg321 -b 10000 -s -r 44100 $1 | sox -t raw -r 44100 -s -w -c2 - "$1.wav"
# process file with soundstretch
soundstretch "$1.wav" "$1.fast.wav" -tempo=+50
# encode mp3 file
lame --preset fast medium "$1.fast.wav" "$1.2.mp3"
# copy id3 tags from old file
id3cp "$1" "$1.2.mp3"
# remove temp files
rm "$1.wav" "$1.fast.wav"
# rename original mp3 file to .bak extension
mv "$1" "$1.bak"
# rename processed mp3 file to original name
mv "$1.2.mp3" "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment