Is it possible to read music file metadata using R?

半腔热情 提交于 2019-12-07 22:53:30

问题


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 ?


回答1:


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.




回答2:


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.




回答3:


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) =)!



来源:https://stackoverflow.com/questions/3390262/is-it-possible-to-read-music-file-metadata-using-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!