From owner-freebsd-questions@FreeBSD.ORG Sun Aug 27 21:01:11 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 97F9C16A4DD for ; Sun, 27 Aug 2006 21:01:11 +0000 (UTC) (envelope-from freebsd01@dgmm.net) Received: from lon-mail-1.gradwell.net (lon-mail-1.gradwell.net [193.111.201.125]) by mx1.FreeBSD.org (Postfix) with ESMTP id C91BD43D46 for ; Sun, 27 Aug 2006 21:01:10 +0000 (GMT) (envelope-from freebsd01@dgmm.net) Received: from lon-mail-1.gradwell.net ([193.111.201.125] helo=webmaker country=GB ident=dave*pop3$dgmm#net) by lon-mail-1.gradwell.net with esmtpa (Gradwell gwh-smtpd 1.232) id 44f20815.cc13.253 for freebsd-questions@freebsd.org; Sun, 27 Aug 2006 22:01:09 +0100 (envelope-sender ) From: dgmm To: freebsd-questions@freebsd.org Date: Sun, 27 Aug 2006 22:01:07 +0100 User-Agent: KMail/1.9.1 References: <20060827053654.GA60292@thought.org> In-Reply-To: <20060827053654.GA60292@thought.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200608272201.07999.freebsd01@dgmm.net> Subject: Re: taking many 198k mp3 files and converting them to 16k mp3 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Aug 2006 21:01:11 -0000 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@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@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