Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- MP4 QuickTime metadata whose `meta` handler is `mdta` is read and written through its `keys` atom, in `moov/udta/meta` (where ffmpeg's `-movflags use_metadata_tags` writes it) and in `moov/meta` (where QuickTime and Apple devices write it). The handler and each key's namespace are checked first ([QTFF metadata handler atom](https://developer.apple.com/documentation/quicktime-file-format/metadata_handler_atom)). Apple's `com.apple.quicktime.*` keys that have a property (title, displayname, artist, album, comment, composer, copyright, description, encodedby, genre, publisher, year, software, keywords, artwork), ffmpeg's names (title, artist, album, album_artist, composer, date, comment, genre, copyright, description, grouping, lyrics, encoder, encoded_by, publisher, the five sort_* fields, category, keywords, track and disc as `n/m`, compilation, gapless_playback, podcast, rating) and every other name as a freeform field (com.apple.iTunes, or org.musicbrainz for the MusicBrainz names; another mean is written as `mean:name`) map to their properties, and a `udta`-namespace key to its atom. A set replaces every item its field was read from (keyed items, an iTunes atom a lenient writer such as mutagen added beside them, and items the reader could not take, such as a vinyl track `A1`) with one item at the field's key index, where the first one was; a field with no key gets one named the way the file names its keys. No iTunes atom is written into an `mdta` meta; one found there is kept until its field is set, and it wins over the keyed item because it is the newer edit. An unedited save writes every item back as it was, in order. A `moov/meta` beside `udta/meta` (an ffmpeg file that Apple software or ExifTool gave keys) is merged in and wins for the fields it declares, since QTFF gives metadata precedence over user data that declares the same information; AVFoundation reads it the same way. A set writes the new value where the winning value lives and drops the other meta's copy. A damaged `keys` atom maps nothing and is kept as it is. TagLib# and mutagen do not read keyed items.
- `AudibleFile` and `AudibleTag` read and write Audible `.aa` audiobooks: the text dictionary (title, author, narrator, provider, dates, descriptions, keywords, copyright, short and parent titles, product and title IDs, and any other key through `GetValue`/`SetValue`), the cover image, and the duration. A save rewrites the dictionary and moves every table-of-contents offset, the declared file size, and the cover position by the change in its size. The encrypted audio and the DRM keys are copied unchanged; `SetValue` refuses `codec`, `HeaderSeed`, `HeaderKey`, and `EncryptedBlocks`, and `Clear` keeps them. `MediaFormat.Audible` and `TagTypes.Audible` are new, and `.aa` is detected by its magic or extension. Edited `.aa` files have been checked with ffprobe, ffmpeg, and ExifTool, not with Audible's own apps, which may check a digest the file stores; keep a copy of the original or save to a new path.
- `.aax` opens as MP4 by extension as well as by content. `Mp4Tag` and `Mp4File` gain `Narrator` (`©nrt`), `ShortTitle` (`@sti`), `ParentTitle` (`@pti`), `ParentShortTitle` (`@PST`), `ParentProductId` (`@ppi`), `ProductId` (`prID`), `ReleaseDate` (`rldt`), and `ProductVersion` (`VERS`). An Audible `aavd` sample entry reports AAC.

### Fixed

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ See the [Migration Guide](docs/MIGRATION-FROM-TAGLIB.md) for detailed comparison
- **Format Support**:
- Audio: MP3 (ID3v1/ID3v2), FLAC, Ogg Vorbis, Ogg Opus, Ogg FLAC, WAV (RIFF INFO/ID3v2), AIFF (ID3v2), MP4/M4A (AAC/ALAC), ASF/WMA, DSF (DSD), DFF (DSDIFF), WavPack, Monkey's Audio (.ape), Musepack
- Matroska/WebM (`.mkv`, `.mka`, `.mks`, `.mk3d`, `.webm`): tags, duration, audio and video properties, and pictures. Tag values can be saved. Picture attachments are read but not rewritten.
- Audible `.aa`: the text dictionary (title, author, narrator, dates, descriptions, and every other key by name), the cover image, and the duration. Dictionary edits can be saved; the encrypted audio, its DRM keys, and the cover are copied unchanged. Edited files have been checked with ffprobe, ffmpeg, and ExifTool, not with Audible's own apps, which may check a digest the file stores (the purpose of the `68ec733412b9` key is unknown). Keep a copy of the original, or save to a new path. Audible `.aax` is MPEG-4 and opens as MP4/M4A, with its audiobook atoms (narrator, short and parent titles, product IDs, release date) as named properties. Decryption is out of scope.

## Format Support Matrix

Expand Down Expand Up @@ -72,6 +73,8 @@ See the [Migration Guide](docs/MIGRATION-FROM-TAGLIB.md) for detailed comparison
| WavPack | APE tag | — | Native only |
| Monkey's Audio | APE tag | — | Native only |
| Musepack | APE tag | — | Native only |
| Audible .aa | Audible dictionary (chunk 2) | — | Native only |
| Audible .aax | iTunes atoms (ilst) | — | Native only |

## Installation

Expand Down
29 changes: 28 additions & 1 deletion docs/MIGRATION-FROM-TAGLIB.md
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,33 @@ if (result.IsSuccess)
}
```

### Audible Files (.aa, .aax)

An `.aa` file has its own container with a key/value text dictionary. `.aax` is MPEG-4 and opens as `Mp4File`.

```csharp
var result = AudibleFile.ReadFromFile("book.aa");
if (result.IsSuccess)
{
var aa = result.File!;
Console.WriteLine($"{aa.Tag.Title} by {aa.Tag.Author}, read by {aa.Tag.Narrator}");
Console.WriteLine($"Duration: {aa.Properties.Duration}, codec: {aa.Tag.Codec}");

// Any dictionary key by name. DRM keys (codec, HeaderSeed, HeaderKey, EncryptedBlocks) cannot be changed.
Console.WriteLine(aa.Tag.GetValue("pub_date_start"));
aa.Tag.Narrator = "New Narrator";
aa.SaveToFile(); // rewrites the dictionary; the encrypted audio is copied unchanged
}

var aax = Mp4File.ReadFromFile("book.aax").File!;
Console.WriteLine($"{aax.Narrator} / {aax.ProductId} / {aax.ReleaseDate}");
```

Differences from TagLib# for `.aa` (observed by running TagLib# 2.3 on the same files):

- TagLib# reports the `provider` key as `Album` and `AlbumArtists`, and a duration of 0. TagLibSharp2 reports `Album` as null, `Artist` as the `author` key, the provider as `AudibleTag.Provider`, and the duration from the audio chunk size and codec.
- TagLib#'s save leaves an `.aa` file unchanged. TagLibSharp2 writes the dictionary. Edited files have been checked with ffprobe, ffmpeg, and ExifTool, not with Audible's own apps, which may check a digest the file stores. Keep a copy of the original, or save to a new path.

### Musepack Files

Musepack (.mpc) is a lossy audio format with excellent quality at low bitrates. It uses APE tags.
Expand Down Expand Up @@ -643,7 +670,7 @@ if (result.IsSuccess)

TagLibSharp2 includes several features not available in TagLib#:

- **Automatic format detection**: `MediaFile.Read()` auto-detects 16 formats: MP3, FLAC, Ogg Vorbis, Ogg Opus, Ogg FLAC, WAV, AIFF, MP4/M4A, ASF/WMA, DSF, DFF, WavPack, Monkey's Audio, Musepack, and Matroska/WebM
- **Automatic format detection**: `MediaFile.Read()` auto-detects MP3, FLAC, Ogg Vorbis, Ogg Opus, Ogg FLAC, WAV, AIFF, MP4/M4A (including Audible .aax), ASF/WMA, DSF, DFF, WavPack, Monkey's Audio, Musepack, Matroska/WebM, and Audible .aa
- **DSD audio support**: Native DSF and DFF format support for high-resolution DSD audio
- **Lossless format breadth**: WavPack and Monkey's Audio support with APE tag handling
- **Async I/O**: Full async support throughout the API with cancellation token support
Expand Down
Loading