pythonmetadatamp4m4amutagen

mp4 synchronized lyrics tag format


I'm writing a program to embed metadata into .m4a files, such as:

The information I found lead to think that the 'lyrics' tag supports synchronized lyricsn (which would be perfect btw).

The issue I'm trying to solve is I couldn't find any information or documentation on what format to write the syncronized lyrics in (eg: [mm:ss.xxx]lyrics / (milliseconds) lyrics / etc...).

For context I'm using the mutagen library in Python.


Solution

  • The most official specification for the lyrics m4a (mp4) tag is Apple's Music Specification.
    tl;dr - 02:08.957

    They define it as follows

    you can use the <lyrics> tag to deliver the lyrics in plain text
    

    Track Lyrics Set's notes

    The format used is called TTML.
    The timestamps are in the form of 02:05.936.
    An excerpt from the above docs:

        <div begin="01:55.855" end="02:16.755" itunes:song-part="Outro">
          <p begin="01:55.855" end="01:58.807" ttm:agent="v1">City of stars</p>
          <p begin="01:59.104" end="02:02.506" ttm:agent="v1">Are you shining just for me?</p>
          <p begin="02:05.936" end="02:08.957" ttm:agent="v1">City of stars</p>
          <p begin="02:10.380" end="02:16.755" ttm:agent="v2">You never shined so brightly</p>
        </div>