Wednesday, April 18, 2012

Mass Music Conversion and Compression


Scenario:
You have 9GB free storage on your Android smart phone (or 2GB storage on your iPhone), and you have 14GB of music that you want to put on it. What do you do? You have probably like 3 options:
  1. Buy a micro SD card (Android only) - ~$10-20 depending on storage size
  2. Only load some of your music onto your device - The cost of only having some of your music (not to mention the agony of picking the right music)
  3. Compressing music, reducing sound quality but allowing you to keep all your music - The cost of running a script
Now for some, option 3 sounds absolutely ridiculous, because who want's to listen to poor-quality music? My argument  is that it's actually not that bad, and you can barely tell the difference depending on the compression level.

Lets see some before and after stats:
Before:
14.8GB
~128kb/s bitrate

After:
6.6GB
~64kb/s bitrate

Warning, if you are going to try this, try it with one song first and see if the quality is good enough for you (I tried many variations in order to reach my optimal compression quality).

How To:

1.
Forget MP3's. Yes, that's right, MP3 is TERRIBLE! (also there's licencing stuff with the codecs that gave me issues). On Ubuntu it may work out of the box, but for legal reasons Debian doesn't have the codec in its stable repositories. Luckily, I use Debian and did some research into MP3 alternative. OGG Vorbis is where it's at! "Ogg Vorbis is much better than MP3 at very low bitrates (64kbps, etc)."(wiki vs.) Alright, great now we have our audio encoding figured out.

2.
FFMPEG is your friend, play with it. Seriusly, give it a whirl and see what you can do to your audio. Here is what I used for my music:
ffmpeg -i "$input" -aq 15 -acodec vorbis -strict experimental "$output"

3.
Finally, here is the script I came up with to convert all of my music at once:


#!/bin/bash
dir="/home/user/Music/shrunken"
#the find command has a bug where it doesn't actually exclude the shrunken directory (but im sure you can fix it)
find . -path "/home/user/Music/shrunken/*" -prune -o -name *.mp3 -print| while read f
do
input=${f:2}
fileLoc=${f:1}
output="$dir${fileLoc%.*}.ogg"
extension=${output%%.*}
echo $input
folder=$(dirname "$extension")
#mkdir with the "-p" option tells it to auto-create the sub-directories required
mkdir -p "$folder"
#the "echo" is a neat trick that defaults all of the questions ffmpeg might ask about replacing files to "no"
echo "n"|ffmpeg -i "$input" -aq 15 -acodec vorbis -strict experimental "$output"
done
Yes, there are bugs. Yes, it's not perfect. But your smart, you can handle it. Good Luck!

(Side note: My music player on android is jukefox - great piece of software right there)

Friday, April 6, 2012

MATE

Finally there is a Gnome2 fork for Linux kernel 3+. Find it here. Why does this matter so much? Well, in a previous post I talked about why Gnome2 is the best desktop window manager. Linux Torvalds agrees:










Linus Torvalds on GNOME 3.0
"While you are at it, could you also fork gnome, and support a gnome2 environment?"

"I want my sane interfaces back. I have yet to meet anybody who likes the unholy mess that is gnome3."

"It's not that I have rendering problems with gnome3 (although I do have those too), it's that the user experience of Gnome3 even without rendering problems is unacceptable.

Why can't I have shortcuts on my desktop? Why can't I have the expose functionality? Wobbly windows?Why does anybody sane think that it's a good idea to have that "go to the crazy 'activities'" menu mode? I used to be upset when gnome developers decided it was "too complicated" for the user to remap some mouse buttons. In gnome3, the developers have apparently decided that it's "too complicated" to actually do real work on your desktop, and have decided to make it really annoying to do.

Here's an example of "the crazy": you want a new terminal window. So you go to "activities" and press the "terminal" thing that you've made part of your normal desktop thing (but why can't I just have it on the desktop, instead of in that insane "activities" mode?). What happens? Nothing. It brings your existing terminal to the forefront.

That's just crazy crap. Now I need to use Shift-Control-N in an old terminal to bring up a new one. Yeah, that's a real user experience improvement. Sure.

I'm sure there are other ways, but that's just an example of the kind of "head up the arse" behavior of gnome3. Seriously. I have been asking other developers about gnome3, they all think it's crazy. I'm using Xfce. I think it's a step down from gnome2, but it's a huge step up from gnome3. Really."



Linus Torvalds is a genius, so even if you don't trust me, you can at least trust him. If you'v been cursed by upgrading to kernel 3+ and being forced to use XFCE (or Gnome Shell), give MATE a try.

Tuesday, April 3, 2012

Apple... Stop Hatin'

Apple... Why? As a developer I see the benefits of using OSX as a development platform (at least over Windows), what I can't get over is the fact that I can't develop iPhone applications under Linux. I don't mind paying the $100 and going through the review process, what I do mind is being restricted to an inferior operating system on inferior hardware. In my first post I wrote about my setup, 8-Cores 8GB DDR3 1866GHz RAM, and the Ati Radeon HD 5870. I didn't mention that my build came in at ~$1000 (I'v made upgrades here and there but 1k is a good estimate.)

Now lets compare my ~$1000 computer to a similarly priced Apple product. The iMac, $1200.

  • 4GB RAM
  • Quad Core (2.5GHz)
  • Ati Radeon HD 6750M


What... Those specs don't even come close to mine. Yes, I can buy a Mac Pro, and yes I know that I'm paying for the brand as well (+OS). But in order to stay competitive on the hardware side of things with regards to developing, I can't be spending $2000+ every other year for an up-to-date machine.

Apple, you need to open up to Linux developers (especially for the iPhone).