views:

87

answers:

3

Hi all,

I've got a bunch of audio files (let's say ogg or mp3), with metadata.

I wish to read their metadata into R so to create a data.frame with:

  • file name
  • file location
  • file artist
  • file album
  • etc

Any way you know of for doing that ?

+2  A: 

You take an existing mp3 or ogg client, look at what library it uses and then write a binding for said library to R, using the existing client as guide for that side -- and something like Rcpp as a guide on the other side to show you how to connect C/C++ libraries to R.

No magic bullet.

A cheaper and less reliable way is to use a cmdline tool that does what you want and write little helper functions that use system() to run that tool over the file, re-reading the output in R. Not pretty, not reliable, but possibly less challenging.

Dirk Eddelbuettel
I had a feeling this is where it would be going... Thanks Dirk
Tal Galili
Take a look at http://id3lib.sourceforge.net/
Greg
+1  A: 

Possible, yes, easy, no.

You "could" use a combination of readChar and/or readBin on the file and parse out the contents. This would be highly dependent, though, on parsing the frame tags from the raw bytes of the ID3v2 tag (and mind you it would change if it was a version 1 tag). If would certainly be a lot of work to implement a straight R solution. Take this Python code for example, it's very clean straight python code but a lot of branching and parsing.

Mark
Thank you for the response Mark. Your answer is valuable.
Tal Galili
+1  A: 

You can use exiftool with system command available in R. Optionally, you can create regexp to handle the fields you need... If I were you, I'd stick with Dirk's advice (as usual) =)!

aL3xa