Music in the cloud, a new kind of cloud service, has become very popular over the last couple of years.
It makes sense. It helps free valuable portable space on smartphones, it facilitates the sharing of music with family and friends and most importantly, It’s much cheaper than regular cloud storage. In some cases, as with Google Music, it’s free.
Theoretically, when you pay for this kind of service, you’re buying extremely cheap cloud storage space. In the case of Google, you’re even getting it for free. Let’s see:
Of course, this makes sense for service providers because in most cases, people use these services to store music in the form of MP3 files. If a file is already contained in the service provider’s catalog, there’s no need to even upload it from the client’s computer. And one single copy of this MP3 can serve millions of happy customers. In the end, only a small fraction of all that theoretical space is actually occupied.
What I would like to show your here is how we can teach a new trick to our music-in-the-cloud-services in order to make them accept, not only MP3 files, but any kind of file.
I know what you’re probably thinking: “Let’s take any file and change the extension to MP3″
Genius, right?… wrong… In fact, these services are a little smarter than that. They all expect you to upload music. So we need to do some work on our files before we can upload them to the cloud. Here’s how it really works:
An MP3 file has a very specific structure. It is composed of several frames, each of them preceded by a header. The header contains information about the MP3 version, the bit-rate, the frequency and some other meaningful information. Metadata is optionally added to the file by means of ID tags.
I wrote a Python script that wraps any file into an MP3 disguise. It does this by cutting the data in chunks of very specific size, adding the necessary headers, putting the frames together and finally, adding an ID tag to store information about the original binary file. If the file is to large, the script cuts it into pieces and then wraps each piece as an MP3 file. Each chunk is marked using the track information contained in the ID tag.
By default, the script marks the files with the Artist name “Fake MP3 Encoder” and the Album name “My Data in the Music Cloud”. Both values can be changed directly from the command line. Album artwork is also added to the file to help identify more easily the Album containing your wrapped files in iTunes, Google Music or Amazon Cloud Player.
So this is my wrapper: