Log in

No account? Create an account
Metrics on how you upsample an mp3 - The tissue of the Tears of Zorro [entries|archive|friends|userinfo]

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Metrics on how you upsample an mp3 [Sep. 8th, 2008|04:59 pm]
[Tags|, , , , ]

A little thought on mp3s, upsampling, ubuntu (gutsy) and ffmpeg.

So, any techy will see the word "upsample" and think "Oh, why do you want to do that? Really? Why? You'll not get any extra quality that way". To be honest, I'm not looking to get quality out of thin air, but I AM looking to get some stuff working on my mp3 player, and it only likes particular sample rates (otherwise everything sounds like anyone involved are severely hypothyroid patients are on barbiturates). So I did a bit of Googling, and the results were difficult to sift out, so I decided to share it with the blagosphere at large.

So, if the Ubuntu forums were to be believed, you install some packages from medibuntu, decode your mp3, resample with sox, and recode with lame. This is actually a bad plan. For some reason I can't place, this mega-inflates the new mp3. You go from about a 7.5meg file to a 30meg file. Not impressive. True, it was from 11kHz to 44kHz, and maybe a 4-time increase is to be expected, but mp3s should be able to compress it better than that, especially as you fill in junk in the middle. Even on best encoding/compression quality, it wasn't a great save.

It was later that I came across the fact that lame has a "--resample" option. It's not as bad, space-wise but still pretty bad. But not as bad as getting sox involved.

Turns out the big winner is ffmpeg. If you're going from a sample rate of 11kHz to 44kHz with it takes just over twice the space. In my mind, that's really not as bad. I'd like to see better, but at least it means I can get all of the files I wanted to upsample onto my player without using incredible amounts of space.

For those who are interested, the command used was:
ffmpeg -i infile.mp3 -ar 44100 outfile.mp3

[User Picture]From: ebel
2008-09-09 09:17 am (UTC)
ah the black art of ffmpeg/mencoder/lame/gstreamer arcana.

One thing I liked about Rhythmbox, the Gnome Music Management player is that using HAL it was able to recognise what formats certain media players were able to play and would automagically convert files to that format if you tried to copy files on to them. e.g. when adding Oggs to my iPod, it automagically converted them to MP3s. Perhaps rhythmbox / HAL knows about your media player and can auto convert them? If not file a bug. :P
(Reply) (Thread)
[User Picture]From: tearsofzorro
2008-09-09 10:03 am (UTC)
Rhythmbox doesn't seem to know how to talk to my Zen Micro. It's old enough that it uses an obscure protocol - see libnjb for details. The thing is, if you try and put on an mp3 with a weird sampling rate that your iPod can't play properly, will the software pick up on that or does it just make sure that you don't put oggs onto something that can't play them?
(Reply) (Parent) (Thread)
[User Picture]From: ebel
2008-09-09 12:20 pm (UTC)
will the software pick up on that or does it just make sure that you don't put oggs onto something that can't play them?

I don't know. But I assume that it can look at sample rates and not just media format.

The advantage of having a media player that everyone else has is that all MP3s you download work for it. :)
(Reply) (Parent) (Thread)