Skip to content

Instantly share code, notes, and snippets.

@cole
Created July 25, 2010 18:38
Show Gist options
  • Select an option

  • Save cole/489763 to your computer and use it in GitHub Desktop.

Select an option

Save cole/489763 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Convert anything mplayer can play to low quality MP3
IFS="
"
for file in $*; do
if [[ -f "$file" ]];
then
filename=$(basename "$file")
extension=${filename##*.}
filename=${filename%.*}
filenoext=${file%.*}
wav="$filenoext.wav"
mp3="$filenoext.mp3"
echo "Converting ${filename}.${extension} to MP3"
mplayer -vo null -vc null -af resample=44100 -ao pcm:waveheader "$file"
lame -V6 -h audiodump.wav "$mp3"
rm audiodump.wav
else
echo "File $file doesn't appear to exist."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment