C Program for ID3 Tagging
Digital audio files can contain, in addition to the audio track, related text and/or graphical information. The information you’re probably familiar with takes the form of Song title, Artist name, Album name, Year, and Genre. This is the information displayed when you playback a digital audio file on your computer or portable device.
The process of including information other than sound into these digital audio files is commonly referred to as “tagging” in which you “tag” the audio file with additional information that describes the audio file. The original standard for tagging digital files was developed in 1996 by Eric Kemp and he coined the term ID3. At that time ID3 simply meant “IDentify an MP3”.
Versions of ID3:
There are majorly 2 versions of ID3, ID3v1, and ID3v2 as described below:
1. ID3v1: The MP3 standard did not include a method for storing file metadata. In 1996 Eric Kemp had the idea to add a small chunk of data to the audio file, thus solving the problem. The method, now known as ID3v1, quickly became the standard for storing metadata in MP3s.
The ID3v1 tag occupies 128 bytes, beginning with the string TAG 128 bytes from the end of the file. The tag was placed at the end of the file to maintain compatibility with older media players. Some players would play a small burst of static when they read the tag, but most ignored it, and almost all modern players will correctly skip it. This tag allows 30 bytes each for the title, artist, album, and a “comment”, four bytes for the year, and a byte to identify the genre of the song from a predefined list of 80 values (Winamp later extended this list to 148 values).
One improvement to ID3v1 was made by Michael Mutschler in 1997. Since the comment field was too small to write anything useful, he decided to trim it by two bytes and use those two bytes to store the track number. Such tags are referred to as ID3v1.1
2. ID3v2: In 1998, a new specification called ID3v2 was created by multiple contributors. Although it bears the name ID3, its structure is very different from ID3v1.
ID3v2 tags are of variable size and usually occur at the start of the file, which aids streaming media as the metadata is essentially available as soon as the file starts streaming instead of requiring the entire file to be read first as is the case with ID3v1. ID3v2 tags consist of a number of frames, each of which contains a piece of metadata. For example, the TIT2 frame contains the title, and the WOAR frame contains the URL of the artist’s website. Frames can be up to 16MB in length, while the total tag size is limited to 256MB. The internationalization problem was solved by allowing the encoding of strings not only in ISO-8859-1, but also in Unicode. ID3v2 has further sub-classifications to 3 versions as ID3v2.2, ID3v2.3, and ID3v2.4 with minor changes in frames amongst them.
ID3 tags may be edited in a variety of ways. On some platforms, the file’s properties may be edited by viewing extended information in the file manager. Additionally, most audio players allow editing single or groups of files. Editing groups of files are often referred to as “batch tagging”. There are also specialized applications, called taggers, which concentrate specifically on editing the tags and related tasks. Some, such as puddletag offer advanced features such as advanced batch tagging or editing based on regular expressions.
Below is the code for implementing your own tagger.
Input: Input MP3 file name which needs to tagged like input.mp3 and output MP3 file name which would be created as a tagged MP3 file like output.mp3. Output: MP3 file with tagging information as entered by the user.
Below is the C code for implementing your own tagger:
Note: The folder in which you are running the code should contain your input.mp3 file.