Convert mp3 to ogg (to fix bitrate)

I was having troubles with an album a friend gave to me in mp3 format. Amarok wasn’t figuring out the lenght of the tracks so it wasn’t scrobbling them! It was like i wasn’t listening them at all! :P

The solution was simple: convert it to ogg. This is how i did it:

First i had to figure out what was wrong and with the help of mp3check i found out that the bitrate was changing constantly.

Like this:
(snip)
frame 9249/ 4:01: bitrate switching (192 -> 160)
frame 9250/ 4:01: bitrate switching (160 -> 192)
frame 9251/ 4:01: bitrate switching (192 -> 224)
frame 9252/ 4:01: bitrate switching (224 -> 128)
frame 9253/ 4:01: bitrate switching (128 -> 32)
frame 9328/ 4:03: bitrate switching (32 -> 160)
frame 9329/ 4:03: bitrate switching (160 -> 128)
(snip)

I’m still not sure it was the cause of the problem but i went forward with the re-encoding.

i did:
$ mpg321 06\ -\ We\'ll\ Meet\ In\ The\ End.mp3 -w - | oggenc -o 06\ -\ We\'ll\ Meet\ In\ The\ End.ogg -q 10 -a Ef - for track number 6.
The basic command is:
$ mpg321 [original file.mp3] -w - | oggenc -o [output file.ogg] -q 10 -a [artist name] - for each track changing the input and output track.

Here’s the meaning of the flags:
for mpg321

-w N, --wav N
Write to wav file N instead of using the audio device. Specifying '-' for N will cause the file to be written to standard output.

It means it outputs in a wav format.

for oggenc

-q n, --quality=n
Sets encoding quality to n, between -1 (very low) and 10 (very high). This is the default mode of operation, with a default quality level of 3. Fractional quality levels such as 2.5 are permitted.

-a artist, --artist artist
Set the artist comment field in the comments to artist.

You can also set the other tags with:

-G genre, --genre genre
-d date, --date date
-N n, --tracknum n
-t title, --title title
-l album, --album album

But i used Amarok (which is almost prefect) to correct the tags.

In gentoo, oggenc is part of vorbis-tools

$ equery belongs oggenc
[ Searching for file(s) oggenc in *... ]
media-sound/vorbis-tools-1.1.1-r5 (/usr/bin/oggenc)

Maybe in the next time i may do a little bash script to re-encode all the files in a directory.

If you want to encode several files at once you can use :
dirogg

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s