taking many 198k mp3 files and converting them to 16k mp3
dgmm
freebsd01 at dgmm.net
Sun Aug 27 21:01:11 UTC 2006
On Sunday 27 August 2006 06:36, Gary Kline wrote:
> files.
> Reply-To:
> X-Organization: Thought Unlimited. Public service Unix since 1986.
> X-Of_Interest: Observing twenty years of service to the Unix community
>
>
> Is there a way of using sox (or another translator) to turn HUGE
> audio mp3 files into much much smaller files? Say taking man mp3
> files that are stored at 198k high fidelity and outputting these to
> 16k or 32k mp3 (or *.ogg or other format) audio files?
>
> thanks for any insights, sugggestions, or pointers,
>
> gary
I wrote this a while back. You might find it useful or be able to update it
to do what you need.
#!/bin/sh
basedir=/home1/convert
touch ${basedir}/mp3lock
# Convert all mp3 files in $basedir to $bitrate, $samplerate, $channels
# where $bitrate, $samplerate and $channels are derived from the pathname.
#
# $basedir - "top" of the tree to convert. Below $basedir should be two
# directories named "todo" and "done".
# Below "todo" you must create directories named using this
# convention:
# @bb at ss@cc@ - where bb is the desired bitrate, ss is the desired
# samplerate and cc is the channels or mode. The mode
# may be one of s, stereo, j, joint-stereo, m, mono,
# f, forced joint-stereo or d, duel channel.
# The mp3 files will be stored below "todo/@bb at ss@cc@" and will be
# converted using the parameters extracted from the directory name
and
# then saved into an identical dir structure below "done".
#
# Note: Spaces in the filenames will be replaced with underscores.
# Spaces in directory names will remain as is
#
# The original file will be deleted after it has been converted.
# Comment out the rm "$filename" near the end to keep the original.
#
# $ffile - just the filename (in case we need this at a future date)
#
# $destfile - full, modified, path to the "done" dir tree
find "$basedir"/todo -name "*.mp3" -type f |
while read filename
do
destfile=`echo -n "$filename" | sed 's/\/todo\//\/done\//' |
sed 's/ /_/g'`
ffile=${destfile##*/}
fpath=${destfile%/*}
# Check if dest. path exists, create if req.
if [ ! -d "$fpath" ]
then
mkdir -p "$fpath"
fi
# Get conversion parameters from pathname
bitrate=`echo $destfile | cut -f 2 -d @`
samplerate=`echo $destfile | cut -f 3 -d @`
channels=`echo $destfile | cut -f 4 -d @`
echo nice -n 20 lame -h -b $bitrate --resample $samplerate -m
$channels "$filename" "$destfile"
# rm "$filename"
done
rm `echo ${basedir}/mp3lock`
--
Dave
More information about the freebsd-questions
mailing list