mp4ameta
A library for reading and writing iTunes style MPEG-4 audio metadata.
Most commonly this kind of metadata is found inside m4a or m4b files but basically any mp4 container supports it.
Examples
The Easy Way
let mut tag = read_from_path.unwrap;
println!;
tag.set_artist;
tag.write_to_path.unwrap;
The Hard Way
use ;
let mut tag = read_from_path.unwrap;
let artist_ident = Fourcc;
let artist = tag.strings_of.next.unwrap;
println!;
tag.set_data;
tag.write_to_path.unwrap;
Using Freeform Identifiers
use ;
let mut tag = read_from_path.unwrap;
let isrc_ident = new_static;
let isrc = tag.strings_of.next.unwrap;
println!;
tag.set_data;
tag.write_to_path.unwrap;
Chapters
There are two ways of storing chapters in mp4 files. They can either be stored inside a chapter list, or a chapter track.
use ;
use Duration;
let mut tag = read_from_path.unwrap;
for chapter in tag.chapter_track
tag.chapter_track_mut.clear;
tag.chapter_list_mut.extend;
tag.write_to_path.unwrap;
Read and Write Configurations
Read only the data that is relevant for your usecase. And (over)write only the data that you want to edit.
By default all data is read and written.
use ;
// Only read the metadata item list, not chapters or audio information
let read_cfg = ReadConfig ;
let mut tag = read_with_path.unwrap;
println!;
tag.clear_meta_items;
// Only overwrite the metadata item list, leave chapters intact
let write_cfg = WriteConfig ;
tag.write_with_path.unwrap;
Useful Links
- QuickTime spec
- MultimediaWiki QuickTime container
- AtomicParsley docs
- Mutagen docs
- Hydrogen audio tag mapping
- MusicBrainz Picard tag mapping
- Filetype list
Testing
Run all tests:
cargo test
Test this library on your collection:
cargo test -- --nocapture collection <path>