Search code examples
pythonpython-3.xitunesmp4mutagen

Mutagen does not recognize MP4 iTunes voice memo tags


Problem

I have recorded some voice memos on iPhone. I have added titles for different events. After synchronizing, those appear in a separate album. In iTunes they are listed with titles, but the MP4-files are named by the following format: yyyymmdd hhmmss.m4a (AAC encoded).

In order to move the files I would like to rename those files with a little python-script using mutagen.

import mutagen.mp4 as m
f = m.MP4("file.m4a")
print(f.tags)
print(f.MP4Tags())
# f['\xa9nam'] = "test" # works
print(f['\xa9nam']) # only works if edited by previous line or in iTunes

However, mutagen does not recognize the tags correctly, but only after they have been edited (in iTunes). The output of f.tags looks like this:

{'----:com.apple.iTunes:iTunSMPB': [MP4FreeForm(b' 00000000 00000840 000003E0 0000000007823BE0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000', <AtomDataType.UTF8: 1>)], '©too': ['com.apple.VoiceMemos (iOS 10.2)']}

and f.MP4Tags() yields {}. After editing the title it does appear in f.tags:

{'©nam': ['test'], '----:com.apple.iTunes:iTunSMPB': [MP4FreeForm(b' 00000000 00000840 000003E0 0000000007823BE0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000', <AtomDataType.UTF8: 1>)], '©too': ['com.apple.VoiceMemos (iOS 10.2)']}

Question

How to read original *.m4a - iPhone voice memo tags ?


Solution

  • As discussed here the title is not stored inside the file tags but only in the iTunes library file.

    One can set iTunes to create an *.xml containing this information in a readable fashion.

    A similar question on apple-support was answered with a link to a basic script for renaming the voice memos; reading exactly from that.