Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

MP3 encoding

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
Rolling Stone
Posts: 366
Joined: 2009-02-15 18:55
Location: Turku, Finland

MP3 encoding

#1 Post by Rolling Stone »

Since the MPEG-1 layer 3 (aka MP3) encoding is patent encumbered in some countries, most distros don't include an encoder. (A software for making MP3 files.) This is problematic because some stupid portable players only support MP3 format.

So you either have to acquire a MP3 encoder by hand (E.g. LAME) or then in some cases you could use a MPEG-1 layer 2 (MP2) encoder (E.g. TooLame, which is included in many distros) as a drop in replacement and then just rename the .mp2 files to .mp3 to fool the portable player. Using MP2 will result in somewhat bigger files.

And of course, if you're not encoding for a portable player (where disk space is very limited) you might want to use lossless compression instead for superior (original) quality (and larger file sizes). (E.g. FLAC, encoder included in most distros)

User avatar
julian67
Posts: 4633
Joined: 2007-04-06 14:39
Location: Just hanging around
Been thanked: 7 times

Re: MP3 encoding

#2 Post by julian67 »

The easiest way in Debian to get an mp3 encoder is to add the debian-multimedia repos and install lame (or whatever you like) from there. It's still free software.

My method for converting any audio file to mp3:

Install gstreamer-tools, good bad and ugly plug-ins, and gstreamer0.10-lame

Script:

Code: Select all

#! /bin/bash
# mp3gst.sh converts to mp3 any audio file supported by gstreamer

for TRACK in "$@" ; do

MP3OUT=$(ls "$TRACK" |sed 's/\(.*\)\..*/\1/')

gst-launch filesrc location="$TRACK" ! decodebin! audioconvert ! \
lame name=enc vbr=4 vbr-quality=4 ! xingmux ! id3mux ! \
filesink location="$MP3OUT.mp3"
done
# mode=4  means joint-stereo (default)
# vbr=4 means use new lame settings
# vbr-quality means 0 best to 9 worst - you can change this as you like.
# id3mux means use default id3v2.3
# use gst-inspect-0.10 lame for lame options
# use gst-inspect-0.10 id3mux for id3mux options
So just run `mp3gst.sh <file>` or `mp3gst.sh <file> <file> <file>` for multiple files.

For a better batch audio conversion try pacpl or try another gstreamer based script http://forums.debian.net/viewtopic.php?p=290942#p290942 which can
convert directories of almost any music files to oggvorbis
or mp3. It uses gstreamer so it can decode any file that gstreamer
can decode, including aac,flac,wv,ape,mp3,ogg,oga,wma,mpc,m4a etc
The new files are created in a new directory of the same name as the
original, in a destination of your choice. If no destination is chosen
then the new directory is nested within the original. All metadata is
retained. This includes the usual tags and also cover art and
replaygain tags. If the source files do not have replaygain tags then
it can run replaygain on the new files.
Any images (jpg,tif,bmp,png etc) in the source directory are also
copied over. Finally a simple playlist is written.
Wisdom from my inbox: "do not mock at your pottenocy"

Post Reply