LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-04-2011, 03:28 AM   #1
tux008
LQ Newbie
 
Registered: Aug 2011
Posts: 3

Rep: Reputation: Disabled
transform mp3s


Hello, everybody!

I have a small collection of mp3 files that have a "huge" bit rate (320kbps). I would like to transform all the files so they would have a "normal" bit rate of, say, 128 kbps and simultaneously keep the ID3 tags. I think this can be done by a bash script, but I don't know exactly how.

Any help is very appreciated!

Thanks!
 
Old 08-04-2011, 04:08 AM   #2
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Rep: Reputation: 120Reputation: 120
I use "Lame" for this and have a shell script wrapper around it. One thing though, it doesn't preserve ID3 tags - need to sort that out when I get time or you can modify the below to do that.

Code:
#!/bin/bash

if [ $# -eq 1 ]
then
  dir=./
  br=$1
elif [ $# -eq 2 ]
then
  dir=$1

  if [ $2 == 'vbr' ]
  then
    br='standard'
  else
    br="cbr $2"
  fi
else
  echo "Usage: $0 [directory] New_Bitrate"
  exit -1
fi

if [ ! -d $dir ]
then
  echo "$dir is not a directory"
  exit -1
fi

echo "Converting files in $dir to bitrate: $br"

find "$dir" -name "*.mp3" | sort | while read i
do
  tmpfile=$(mktemp)
  lame --mp3input --preset $br -S --add-id3v2 "$i" "$tmpfile"
  mv "$tmpfile" "$i"
  chmod 644 "$i"
  echo "Sucessfully converted $i"
done

exit 0
 
Old 08-04-2011, 04:34 AM   #3
cascade9
Senior Member
 
Registered: Mar 2011
Location: Brisneyland
Distribution: Debian, aptosid
Posts: 3,753

Rep: Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935
320k isnt that big, in these days of 2TB+ HDDs and very cheap flash media.

I wouldnt convert them, if only because a lossy-> lossy transcode will sound worse than an original rip.

But if you really want to do it, you could write some script, or you could use a program with a GUI, like soundconverter (Gtk) or soundkonverter (Qt).
 
Old 08-04-2011, 07:10 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Search the site. Get on Google. The number of people who've wanted to do exactly the same thing must number in the tens of thousands by now. And I know at least a few of them found solutions and have posted them for others to use.

But overall I concur with cascade9. If you don't need to convert a lossy file, don't. It's better to go back to the original lossless source, assuming it exists, and simply rip it again.
 
Old 08-12-2011, 11:03 AM   #5
tux008
LQ Newbie
 
Registered: Aug 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thank you all very much!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Transform mm:ss:ff to mm:ss.ss ? stf92 Programming 12 07-08-2011 12:43 PM
transform a string to a float spinal2 Programming 10 10-30-2006 12:09 PM
how to transform ip -> name cristi1979 Linux - Networking 14 06-16-2003 01:43 AM
rippers, mp3s and mp3s.... (?) bxb32001 Linux - General 0 07-14-2001 12:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration