Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read and write id3v1 and id3v2 tags in Elixir

I would like to scan music files and read/write metadata using Elixir (this whole project is about learning Elixir - so please don't tell me to use Python!). As I understand it, I have two choices: call a system utility or (as no libraries exist in Erlang or Elixir that I am aware of) write an Elixir library. For m4a files, I make a system call to MP4Box and it writes an xml file to disk. I then read in the file, parse it, and load the data into a database.

def parse(file_name) do
  System.cmd("MP4Box", ["-diso",file_name])
  Ainur.XmlParser.parse(xml_file_name(file_name))
  |> get_tags
end

Very slow, especially for thousands of files. And I want it to run at start up everytime to check for changed/new files.

Now I am trying to do the same for mp3's with id3 tags. I tried libid3-tools on Ubuntu and it only found the id3v1 tags. eyeD3 only found id3v2 tags. My mp3's have both so I need to make sure there are the same (I suppose I could delete the id3v1 tags, but I have been led to believe that id3v1 tags are needed on legacy equipment).

Are there any Erlang or Elixir libraries for music metadata? If not, are system calls to ubuntu utilities my best choice (any recommendations on which ones)?

Or do I need to write a library to obtain reasonable performance? If so, is there an existing library in a functional language that I could try to port?

Or is it possible to call a library written in another language directly from Elixir (without the system call)?

like image 697
Paul B Avatar asked May 23 '15 21:05

Paul B


1 Answers

You can always use erlang NIFs (http://erlang.org/doc/tutorial/nif.html) to wrap an external library

like image 140
Paweł Obrok Avatar answered Sep 29 '22 14:09

Paweł Obrok