Is it possible to add ID3 tags to m4a files using mutagen?

Viewed 7168

I run into a problem while writing a script to tag my music library with mutagen. The following code works fine when dealing with mp3 files but corrupts the m4a files.

def set_video_tags(video, filepath):
    try:
        tags = ID3(filepath, v2_version=3)
    except ID3NoHeaderError:
        tags = ID3()

    tags.add(TXXX(3, desc='desc:custom_tag',text= video.custom_text))
    tags.save(filepath, v2_version=3)

After processing the m4a files, tags can be read back using mutagen but aren't detected by any other players and the audio doesn't playback.

I tried to delete MP4 tags from the files before calling this function but it didn't help.

What am I doing wrong?

1 Answers
Related