Crate id3

source · []
Expand description


Build Status Crate Documentation

A library for reading and writing ID3 metadata.

Implemented Features

  • ID3v1 reading
  • ID3v2.2, ID3v2.3, ID3v2.4 reading/writing
  • MP3, WAV and AIFF files
  • Latin1, UTF16 and UTF8 encodings
  • Text frames
  • Extended Text frames
  • Link frames
  • Extended Link frames
  • Comment frames
  • Lyrics frames
  • Synchronised Lyrics frames
  • Picture frames
  • Encapsulated Object frames
  • Chapter frames
  • Unsynchronisation
  • Compression
  • MPEG Location Lookup Table frames
  • Tag and File Alter Preservation bits


Reading tag frames

use id3::{Tag, TagLike};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let tag = Tag::read_from_path("testdata/id3v24.id3")?;

    // Get a bunch of frames...
    if let Some(artist) = tag.artist() {
        println!("artist: {}", artist);
    if let Some(title) = tag.title() {
        println!("title: {}", title);
    if let Some(album) = tag.album() {
        println!("album: {}", album);

    // Get frames before getting their content for more complex tags.
    if let Some(artist) = tag.get("TPE1").and_then(|frame| frame.content().text()) {
        println!("artist: {}", artist);

Modifying any existing tag.

use id3::{Error, ErrorKind, Tag, TagLike, Version};
use std::fs::copy;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    copy("testdata/quiet.mp3", "/tmp/music.mp3")?;

    let mut tag = match Tag::read_from_path("/tmp/music.mp3") {
        Ok(tag) => tag,
        Err(Error{kind: ErrorKind::NoTag, ..}) => Tag::new(),
        Err(err) => return Err(Box::new(err)),

    tag.set_album("Fancy Album Title");

    tag.write_to_path("/tmp/music.mp3", Version::Id3v24)?;

Creating a new tag, overwriting any old tag.

use id3::{Tag, TagLike, Frame, Version};
use id3::frame::Content;
use std::fs::copy;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    copy("testdata/quiet.mp3", "/tmp/music.mp3")?;

    let mut tag = Tag::new();
    tag.set_album("Fancy Album Title");

    // Set the album the hard way.
    tag.add_frame(Frame::text("TALB", "album"));

    tag.write_to_path("/tmp/music.mp3", Version::Id3v24)?;


pub use crate::frame::Frame;


Contains types and methods for operating on ID3 frames.

Utilities for working with ID3v1 tags.


The Encoder may be used to encode tags with custom settings.

A structure able to represent any error that may occur while performing metadata operations.

An ID3 tag containing zero or more Frames.

Represents a date and time according to the ID3v2.4 spec:


The decoded contents of a Frame.

Kinds of errors that may occur while performing metadata operations.

Denotes the version of a tag.


TagLike is a trait that provides a set of useful default methods that make manipulation of tag frames easier.


Takes a tag result and maps any partial tag to Ok. An Ok result is left untouched. An Err without partial tag is returned as the initial error.

Type Definitions

Type alias for the result of tag operations.