can you add metadata to m4a audio files

is there a way to use applescript to assign author/artist and title to a .m4a file. I wanted to assign this data so if a person imported the .m4a file into iTunes the appropriate information would so up.

thanks for any help

Kevin

Model: macbook pro
Browser: Safari 537.77.4
Operating System: Mac OS X (10.8)

As far as I know Mac OS X doesn’t ship with standard tools that could do it without help from iTunes. A quick Google gave me mutagen which is a python module which can be easily accessed by a do shell script. I have no experience with mutagen but python scripts are setup quite easy.

Update:
I’ve downloaded mutagen and installed it and created a small script.

installation in terminal after download:
[format]cd /path/to/mutagen/
./setup.py build
sudo ./setup.py install[/format]
Then I ran the following code, and worked:

do shell script "python -c 'from mutagen.mp4 import MP4
audio = MP4(\"/Users/<username>/Desktop/no-tag.m4a\")
audio[\"\\xa9nam\"] = \"my own title\"
audio.save()'"

\xa9nam is the key for title, on mutagen documentation you can find a complete list of supported keys.

thanks for the reply. I will try to work this into my script.

My only question is future usefulness. Is the mutagen stable or will I have to change it as the MAC OS is updated?

This is all I can say about mutagen: Mutagen is “stable” because m4a is mpeg4-part3 where metadata is stored the same way as any other mpeg4 compression. It’s also poplar (2000 downloads a week). It’s in development for more than 5 years. It’s a python module that is recognized by python itself (not some home made module). Mutagen is installed in the /Library/Python folder which means it’s untouched between software updates (or at least should be). Only after a clean install (or possible mayor OS update?) you need to re-install this python module.

The biggest drawback is that you need to maintain the mutagen module yourself, that means when a new version is released you need to download it an install it by yourself. But this process can be automated by you of course.

Hmm
I use this in a Filemaker Pro solution that I have 5 people using. It is not really a workable solution to have to push out those changes.

I currently use applescript from within Filemaker Pro solution to open Quicktime player, record a voice file (approx. 26 minutes in length) then save the file to a folder as .m4a file. I am able to get all that to work. I was looking for a way to tag the file with the the authors name, so the user has some control over the audio file when they distribute it to their clients.

Perhaps I will just use applescript to set the comments of the file via the Finder

thanks for your help


tell application "iTunes"
	set thetrack  to add afile
	set artist of thetrack to "The Artist"
        set name of thetrack to "A beautiful discourse"
end tell

thank you