LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-09-2005, 12:10 AM   #1
SolidSnakeX28
Member
 
Registered: May 2005
Distribution: Gentoo Linux
Posts: 85

Rep: Reputation: 15
Encoding audio: Mp3 to Mp3


I need to find a good way to encode my audio (which is already in the mp3 format) to make it smaller; a sound compression tool. I've heard of Grip, but it seems that it only encodes from CD's, or am I wrong? And I've read about LAME, but I don't know how to use it. If it can do what I want, which is massively compress audio, then please outline what I need to do with LAME, and if Grip can do it, then please show me how to do so. Thanks!
 
Old 07-09-2005, 12:47 AM   #2
Electro
Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
The audio codec formats MP3, WMA, RAM, OGG are lossy compression. Lossy compression just takes out or losses the information. If you do re-encode the file, the quality of the sound will suck and I do mean it will suck. Use rar, tar.gz, tar.bz2, compress, zip to make it smaller.

All I can say the information on how to encode a sound file to MP3 is in the manual.
 
Old 07-09-2005, 12:59 AM   #3
SolidSnakeX28
Member
 
Registered: May 2005
Distribution: Gentoo Linux
Posts: 85

Original Poster
Rep: Reputation: 15
Maybe I didn't make myself clear here, sorry. I mean that I want to compress my audio to play on a portable MP3 player, and don't worry about the quality losses.
 
Old 07-09-2005, 02:37 AM   #4
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Ruhr Area, Germany
Distribution: Slackware64 14.0
Posts: 1,517

Rep: Reputation: 90
Have you looked at lame? If I remember right, newer versions take mp3 files as input, so that you will have a simple conversion of the files. I guess the mp3 tags will not be present in the new files ...
 
Old 07-09-2005, 03:12 AM   #5
kencaz
Senior Member
 
Registered: Mar 2005
Location: Las Vegas, NV
Distribution: Mandriva Slackware FreeBSD
Posts: 1,468

Rep: Reputation: 47
This should convert your 128 or any bitrate for that matter to 32, greatly reducing file size.

lame -b 32 -h sample_128.mp3 sample_32.mp3

note: be sure to change the output file name or it will overight the original...

KC
 
Old 07-09-2005, 05:47 PM   #6
SolidSnakeX28
Member
 
Registered: May 2005
Distribution: Gentoo Linux
Posts: 85

Original Poster
Rep: Reputation: 15
Thanks alot, it did the job. But now I have 2 other problems that need taking care of:

How about for massive encoding? ie, I just had to command |lame -b 64 -h /song/ /song/| about 30 times for 30 songs! Can I just use a single command for them, or am I stuck with 1-1 commands?

Also, I need an .mp4 encoder for video. Help, anyone? Instructions would also be appreciated.
 
Old 07-09-2005, 06:37 PM   #7
kencaz
Senior Member
 
Registered: Mar 2005
Location: Las Vegas, NV
Distribution: Mandriva Slackware FreeBSD
Posts: 1,468

Rep: Reputation: 47
I use this script file to convert multiple .wav captured audio streams to .mp3 format. It should work form mp3 to mp3 as well, but have not tried it.

./mlame -r -o "-v -V 0 -b 112" *.wav *.mp3

Here is the "mlame" script.

#!/bin/bash
#!/usr/local/bin/bash
############################################################################
#
# Run the LAME encoder on multiple files, with option to delete .wav files
# after encoding. "mlame -h" will give instructions.
#
# Robert Hegemann <Robert.Hegemann@gmx.de>
#
############################################################################

mp3coder="lame"
options="-h -d -m j -b 128"
rmsrc=false

helptext="\
\nThis script runs the LAME mp3 encoder on multiple files: \n\n\
$0 [options] <file 1> ... <file n>\n\
\n\
options:\n\
-h this help text\n\
-r remove files after encoding\n\
-o \"<lame options>\" overrides script default options \"${options}\"\n\
\n\
example:\n\
$0 -r -o \"-v -V 0 -b 112\" a*.wav z*.aif\n\
\n\
"

# process command-line options
# this could be extended to fake the
# commandline interface of the mp3encoder

while getopts ":r" optn; do
case $optn in
o ) options=$OPTARG # replace default options
;;
r ) rmsrc=true
;;
\? ) printf "$helptext"
exit 1
;;
esac
done
shift $(($OPTIND - 1))

# process input-files

for filename in "$@"; do
case $filename in
*[*?]* ) # means shell couldnīt extend *.wav, etc.
echo "warning: no $filename file(s) found"
;;
*[.][wW][aA][vV] )
name=${filename%[.][wW][aA][vV]}
if $mp3coder $options "$filename" "${name}.mp3"
then
if [ $rmsrc = true ]; then
rm -f "$filename"
fi
fi
;;
*[.][aA][iI][fF] )
name=${filename%[.][aA][iI][fF]}
if $mp3coder $options "$filename" "${name}.mp3"
then
if [ $rmsrc = true ]; then
rm -f "$filename"
fi
fi
;;
* )
if $mp3coder $options "$filename" "${filename}.mp3"
then
if [ $rmsrc = true ]; then
rm -f "$filename"
fi
fi
;;
esac
done

KC
 
Old 06-25-2006, 10:14 AM   #8
PlanetRetcon
LQ Newbie
 
Registered: Jun 2006
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by kencaz
I use this script file to convert multiple .wav captured audio streams to .mp3 format. It should work form mp3 to mp3 as well, but have not tried it.

./mlame -r -o "-v -V 0 -b 112" *.wav *.mp3

Here is the "mlame" script.
You didn't turn off smilies, which caused me no end of confusion when this didn't work

Here's the code sans smiley:

Code:
#!/bin/bash 
#!/usr/local/bin/bash
############################################################################
#   
#  Run the LAME encoder on multiple files, with option to delete .wav files
#  after encoding.  "mlame -h" will give instructions.
#
#  Robert Hegemann <Robert.Hegemann@gmx.de>
#
############################################################################

mp3coder="lame"
options="-h -d -m j -b 128"
rmsrc=false

helptext="\
\nThis script runs the LAME mp3 encoder on multiple files: \n\n\
$0 [options] <file 1> ... <file n>\n\
\n\
  options:\n\
    -h                  this help text\n\
    -r                  remove files after encoding\n\
    -o \"<lame options>\" overrides script default options \"${options}\"\n\
\n\
  example:\n\
    $0 -r -o \"-v -V 0 -b 112\" a*.wav z*.aif\n\
    \n\
"

#   process command-line options
#   this could be extended to fake the 
#   commandline interface of the mp3encoder

while getopts ":o:r" optn; do
    case $optn in
    o ) options=$OPTARG # replace default options
        ;; 
    r ) rmsrc=true
        ;;
    \? ) printf "$helptext"
        exit 1  
        ;;
    esac
done
shift $(($OPTIND - 1))

#   process input-files

for filename in "$@"; do
    case $filename in
    *[*?]*  )   # means shell couldnīt extend *.wav, etc.
        echo "warning: no $filename file(s) found"
        ;;
    *[.][wW][aA][vV]  )
        name=${filename%[.][wW][aA][vV]}
        if $mp3coder $options "$filename" "${name}.mp3" 
        then
            if [ $rmsrc = true ]; then
                rm -f "$filename"
            fi
        fi
        ;;
    *[.][aA][iI][fF]  )
        name=${filename%[.][aA][iI][fF]}
        if $mp3coder $options "$filename" "${name}.mp3" 
        then
            if [ $rmsrc = true ]; then
                rm -f "$filename"
            fi
        fi
        ;;
    *   )
        if $mp3coder $options "$filename" "${filename}.mp3" 
        then
            if [ $rmsrc = true ]; then
                rm -f "$filename"
            fi
        fi
        ;;
    esac
done
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Encoding mp3 with Suse 10 Jeffmrg Suse/Novell 3 10-09-2005 01:55 PM
Ripping and encoding to MP3 mark_booze Linux - Newbie 6 12-28-2003 09:52 AM
MP3 Encoding - Please Help biggsjm Linux - Software 9 10-06-2003 02:52 PM
MP3 Encoding wonderpun Linux - Software 9 09-13-2002 07:00 AM
mp3 encoding problems Stephanie Linux - General 9 11-16-2001 10:43 PM


All times are GMT -5. The time now is 01:45 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration