Saint Sava (saint_sava) wrote,
Saint Sava
saint_sava

  • Music:
I picked up the habit of ripping my MP3s at maximum quality (320kbps, the preset for which is pointedly called insane by the /usr/bin/lame mp3 encoder) from crossvector, who clearly has much better hearing and stereo equipment than I ever will. When it comes to listening to music on the go (i.e., route 358, where, on a good day, you won't be sharing your seat with livestock), I find that listening to 128kbps a little louder than necessary is a workable alternative. For those of you that run Linux and have a mobile music player, you might be interested in this little batch script to batch downsample your mp3s. (Note: it's not fast -- on my computer it executes at only 15x playback speed, so you'll probably want to run it overnight. YMMV.)

Also ... where have I been for the last three years ? Honestly, I have no idea where the time went. I just sat down in front of the computer and when I got up to make another pot of coffee it was 2009. Weird. If you're so inclined, I post to twitter as @eleuthero these days. My commentary is just as fatuous and puerile as it has traditionally been here, but at least there it's mercifully constrained to 140 incoherent characters.



#!/bin/bash

# Script to downsample all mp3s downstream in the file system.
# 2009.17.V. R. Jones <raven.jones@gmail.com>
# Requires /usr/bin/lame.
# A new folder will be created in the current directory and as the downsampling happens,
# a copy of the downstream file system structure will be created in the new folder.

# Usage.
if [ $# -ne 1 ]; then
	echo "usage: $0 <bitrate in kbps>"
	exit 1
fi	
	
# Grab the requested bit rate off the command line.
BITRATE="$1"

# Create a folder to contain a copy of the file system containing the downsampled mp3s.
/bin/mkdir -p ./${BITRATE}

# Iterate over every downstream mp3, downsampling it and copying the result into the new folder.
find . -name "*.mp3" -printf "%f:%h\n" | while IFS=":" read NAME PATH
do
	# Create a folder for the album if it doesn't already exist.
	/bin/mkdir -p "./${BITRATE}/${PATH}"

	# Downsample the mp3 using /usr/bin/lame.
	/usr/bin/lame --preset ${BITRATE} "./${PATH}/${NAME}" "./${BITRATE}/${PATH}/${NAME}"
done
Tags: bash, linux, mp3, script, ubuntu
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic
  • 2 comments