From owner-freebsd-questions@FreeBSD.ORG Sun Apr 16 19:17:47 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 7521C16A45A for ; Sun, 16 Apr 2006 19:17:47 +0000 (UTC) (envelope-from freebsd01@dgmm.net) Received: from lon-mail-4.gradwell.net (lon-mail-4.gradwell.net [193.111.201.130]) by mx1.FreeBSD.org (Postfix) with ESMTP id A7F8E43D46 for ; Sun, 16 Apr 2006 19:17:46 +0000 (GMT) (envelope-from freebsd01@dgmm.net) Received: from lon-mail-4.gradwell.net ([193.111.201.130] helo=webmaker ident=postmaster*pop3^dgmm#net) by lon-mail-4.gradwell.net with esmtpa (Gradwell gwh-smtpd 1.214) id 44429859.c18a.1552 for freebsd-questions@freebsd.org; Sun, 16 Apr 2006 20:17:45 +0100 (envelope-sender ) From: dgmm To: freebsd-questions@freebsd.org Date: Sun, 16 Apr 2006 20:17:31 +0100 User-Agent: KMail/1.9.1 References: <200604150908.24807@aldan> In-Reply-To: <200604150908.24807@aldan> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200604162017.32109.freebsd01@dgmm.net> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Subject: Re: Anything to recode mp3 files in the ports? 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, 16 Apr 2006 19:17:47 -0000 On Saturday 15 April 2006 14:08, Mikhail Teterin wrote: > Hi! > > I have a sizable collection of mp3 files (most of my CDs, actually) encoded > at high ratio for archiving. > > I'd like to put some of them on a low-capacity player. Is there a utility > (preferably -- a ported one), that can reencode an existing mp3 file at > lower quality settings (hence smaller size), or do I have to re-rip the CDs > from scratch? > > Thanks! > > -mi I used this last year to convert a collection of radio shows, audio books and music. I wanted different rates dependant on content and at the time thought this was the way to go. If you try it, beware that it does not cope well with "odd" filesnames, eg with spaces in the name etc. (watch out for line wrap) #!/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 @` nice -n 20 lame -h -b $bitrate --resample $samplerate -m $channels "$filename" "$destfile" # rm "$filename" done rm `echo ${basedir}/mp3lock` -- Dave