Understanding the libvorbis vorbis_comment Structure

This article provides a clear and concise overview of the vorbis_comment structure within the libvorbis library. You will learn about the specific fields defined in this C structure, how metadata is formatted, and how the library handles audio tagging (such as artist name, track title, and album info) in Ogg Vorbis files.

In the libvorbis library, the vorbis_comment structure is the primary container used to read, write, and manage metadata. Similar to ID3 tags in MP3 files, Vorbis comments store tag information as human-readable text.

The vorbis_comment Structure Definition

In the C library header (<vorbis/codec.h>), the structure is defined as follows:

typedef struct vorbis_comment {
  char **user_comments;
  int *comment_lengths;
  int comments;
  char *vendor;
} vorbis_comment;

Description of Structure Fields

The vorbis_comment structure contains four key fields:

How Metadata is Formatted

The metadata strings stored within the user_comments array follow a strict “FIELD=value” format: