C++ library for reading and writing MP4/M4A/AAC (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Go to file
Martchus 41a4c0c165 WIP: Make use of copy-overloads using sendfile64() 2023-04-29 12:08:58 +02:00
.github Add stalebot config 2022-04-12 01:04:24 +02:00
aac Fix spelling and typos 2021-07-02 11:12:39 +02:00
adts Fix spelling and typos 2021-07-02 11:12:39 +02:00
av1 Adapt to changes in c++utilities 2019-06-12 20:40:45 +02:00
avc Fix spelling and typos 2021-07-02 11:12:39 +02:00
avi Adapt to changes in c++utilities 2019-06-10 23:11:39 +02:00
cmake/scripts Ease setting up build by downloading iso_639-2.json automatically 2023-03-04 19:00:24 +01:00
doc Apply clang-format to example code 2021-12-21 01:08:10 +01:00
flac Avoid unqualified calls to `std::move` 2023-02-20 19:54:42 +01:00
id3 Avoid unqualified calls to `std::move` 2023-02-20 19:54:42 +01:00
ivf Add API to allow aborting overall/expensive parsing functions 2021-02-04 23:21:50 +01:00
matroska WIP: Make use of copy-overloads using sendfile64() 2023-04-29 12:08:58 +02:00
mp4 Avoid unqualified calls to `std::move` 2023-02-20 19:54:42 +01:00
mpegaudio Fix compilation with libc++ 2021-12-05 17:49:36 +01:00
ogg Add missing documentation 2022-08-02 21:41:05 +02:00
opus Adapt to changes in c++utilities 2019-06-10 23:11:39 +02:00
scripts Extend Ogg related tests 2021-08-18 22:48:17 +02:00
testfiles Add MP4 testfile with chapters 2019-03-28 17:54:18 +01:00
tests Avoid use of platform-specific `unistd.h` header 2023-02-11 13:55:04 +01:00
vorbis Use `pubsetbuf` only with `libstdc++` 2023-02-28 21:06:52 +01:00
wav Fix warnings 2021-03-20 21:26:25 +01:00
.gitignore Apply clang-format later 2017-05-01 03:19:44 +02:00
CMakeLists.txt Bump minor version 2023-02-18 21:42:38 +01:00
LICENSE Initial commit 2015-04-22 19:11:19 +02:00
README.md Update copyright notice 2023-01-17 18:33:49 +01:00
abstractattachment.cpp Avoid unqualified calls to `std::move` 2023-02-20 19:54:42 +01:00
abstractattachment.h Fix warnings 2021-03-20 21:26:25 +01:00
abstractchapter.cpp Add API to allow aborting overall/expensive parsing functions 2021-02-04 23:21:50 +01:00
abstractchapter.h Add API to allow aborting overall/expensive parsing functions 2021-02-04 23:21:50 +01:00
abstractcontainer.cpp Fix spelling and typos 2021-07-02 11:12:39 +02:00
abstractcontainer.h Add API to allow aborting overall/expensive parsing functions 2021-02-04 23:21:50 +01:00
abstracttrack.cpp Add fields to AbstractTrack to support a few more Mkv specs in the future 2022-02-16 00:24:21 +01:00
abstracttrack.h Add fields to AbstractTrack to support a few more Mkv specs in the future 2022-02-16 00:24:21 +01:00
aspectratio.cpp Adapt to c++utilities v5 2019-05-04 16:04:21 +02:00
aspectratio.h Make many constructors explicit to avoid unintended implicit conversions 2020-12-05 20:48:57 +01:00
backuphelper.cpp Use `makeNativePath()` instead of `u8path()` 2022-03-17 22:41:35 +01:00
backuphelper.h Use `std::filesystem` in backup helper code 2021-09-11 23:54:49 +02:00
basicfileinfo.cpp Fix spelling and typos 2021-07-02 11:12:39 +02:00
basicfileinfo.h Improve passing paths 2021-04-23 22:16:43 +02:00
caseinsensitivecomparer.h Fix spelling and typos 2021-07-02 11:12:39 +02:00
diagnostics.cpp Use std::string_view where it makes sense 2021-01-30 21:53:06 +01:00
diagnostics.h Use std::string_view where it makes sense 2021-01-30 21:53:06 +01:00
exceptions.cpp Improve documentation 2020-11-05 19:52:09 +01:00
exceptions.h Use noexcept directly 2019-02-17 17:14:07 +01:00
fieldbasedtag.h Apply clang-format 2023-02-03 13:31:40 +01:00
genericcontainer.h Simplify code 2021-12-31 00:30:11 +01:00
genericfileelement.h WIP: Make use of copy-overloads using sendfile64() 2023-04-29 12:08:58 +02:00
generictagfield.h Apply clang-format 2023-02-03 13:31:40 +01:00
global.h Adapt to changes in c++utilities 2019-06-12 20:40:45 +02:00
localeawarestring.cpp Apply clang-format 2018-03-07 01:17:50 +01:00
localeawarestring.h Add Locale class to deal with differently specified languages/countries 2020-12-16 17:48:08 +01:00
localehelper.cpp Fix spelling and typos 2021-07-02 11:12:39 +02:00
localehelper.h Remove unused optional header from localehelper.h 2021-01-20 20:10:56 +01:00
margin.h Make many constructors explicit to avoid unintended implicit conversions 2020-12-05 20:48:57 +01:00
mediafileinfo.cpp Avoid unqualified calls to `std::move` 2023-02-20 19:54:42 +01:00
mediafileinfo.h Improve handling time values of MP4 files 2022-02-15 23:22:48 +01:00
mediaformat.cpp Add media format entry for H.266 2023-02-18 21:43:16 +01:00
mediaformat.h Add media format entry for H.266 2023-02-18 21:43:16 +01:00
positioninset.h Make many constructors explicit to avoid unintended implicit conversions 2020-12-05 20:48:57 +01:00
progressfeedback.cpp Document progress feedback 2018-06-03 20:32:35 +02:00
progressfeedback.h Apply clang-format 2023-02-03 13:31:40 +01:00
settings.h Use helper for flag enum from c++utilities 2019-08-12 20:22:57 +02:00
signature.cpp Detect zstd compressed files 2023-03-05 22:37:14 +01:00
signature.h Detect zstd compressed files 2023-03-05 22:37:14 +01:00
size.cpp Fix spelling and typos 2021-07-02 11:12:39 +02:00
size.h Fix spelling and typos 2021-07-02 11:12:39 +02:00
tag.cpp Extend documentation of Tag::size() 2021-08-08 00:04:28 +02:00
tag.h Move TagType into separate header 2022-06-20 21:21:11 +02:00
tagtarget.cpp Avoid unqualified calls to `std::move` 2023-02-20 19:54:42 +01:00
tagtarget.h Add `TagTarget::matches()` 2021-12-31 00:31:32 +01:00
tagtype.h Move TagType into separate header 2022-06-20 21:21:11 +02:00
tagvalue.cpp Use `pubsetbuf` only with `libstdc++` 2023-02-28 21:06:52 +01:00
tagvalue.h Avoid unqualified calls to `std::move` 2023-02-20 19:54:42 +01:00

README.md

Tag Parser

C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags.

Supported formats

The tag library can read and write the following tag formats:

  • iTunes-style MP4/M4A tags (MP4-DASH is supported)
  • ID3v1 and ID3v2 tags
    • conversion between ID3v1 and different versions of ID3v2 is possible
  • Vorbis, Opus and FLAC comments in Ogg streams
    • cover art via "METADATA_BLOCK_PICTURE" is supported
  • Vorbis comments and "METADATA_BLOCK_PICTURE" in raw FLAC streams
  • Matroska/WebM tags and attachments

File layout options

Tag position

The library allows you to choose whether tags should be placed at the beginning or at the end of an MP4/Matroska file.

Padding

Padding allows adding additional tag information without rewriting the entire file or appending the tag. Usage of padding can be configured:

  • minimum/maximum padding: The file is rewritten if the padding would fall below/exceed the specified limits.
  • preferred padding: If the file needs to be rewritten the preferred padding is used.

Default value for minimum and maximum padding is zero. Hence the library will almost always have to rewrite the entire file to apply changes. To prevent this, set at least the maximum padding to a higher value.

It is also possible to force rewriting the entire file always.

Taking advantage of padding is currently not supported when dealing with Ogg streams (it is supported when dealing with raw FLAC streams).

Additional features

The library can also display technical information such as the ID, format, language, bitrate, duration, size, timestamps, sampling frequency, FPS and other information of the tracks.

It also allows to inspect and validate the element structure of MP4 and Matroska files.

Text encoding, Unicode support

The library is aware of different text encodings and can convert between different encodings using iconv.

Usage

  • For building/installing the library, checkout the build instructions below.
  • To use the library with CMake, use its find module (e.g. find_package(tagparser 10.1.0 REQUIRED)) which provides the imported target tagparser you can link against. Otherwise, use the pkg-config module tagparser to query the required compiler/linker flags.
  • For a code example that shows how to read and write tag fields in a format-independent way, have a look at example.cpp.
  • The most important class is TagParser::MediaFileInfo providing access to everything else.
  • IO errors are propagated via standard std::ios_base::failure.
  • Fatal processing errors are propagated by throwing a class derived from TagParser::Failure.
  • All operations which might generate warnings, non-fatal errors, ... take a TagParser::Diagnostics object to store those messages.
  • All operations which might be aborted or might provide progress feedback take a TagParser::AbortableProgressFeedback object for callbacks and aborting.
  • Field values are stored using TagParser::TagValue objects. Those objects erase the actual type similar to QVariant from the Qt framework. The documentation of TagParser::TagValue covers how different types and encodings are handled.

Further documentation

For more examples check out the command line interface of Tag Editor. API documentation can be generated using Doxygen with make tagparser_apidoc.

Bugs, stability

Bugs can be reported on GitHub.

It is recommend to create backups before editing because I can not test whether the library works with all kinds of files. (When forcing rewrite a backup is always created.)

Build instructions

The tagparser library depends on c++utilities and is built in the same way. It also depends on zlib, iso-codes and requires at least CMake 3.19. Tests depend on CppUnit. For checking integrity of testfiles, the OpenSSL crypto library is required.

The location of the JSON file from iso-codes can be specified via the CMake variable LANGUAGE_FILE_ISO_639_2.

For building multiple projects in one go (c++utilities, tagparser and the tag editor), checkout the "Building this straight" instructions.

TODOs

  • Support more formats (EXIF, PDF metadata, Theora, ...)
  • Support adding cue-sheet to FLAC files

More TODOs are tracked in the issue section at GitHub.

Copyright © 2015-2023 Marius Kittler

All code is licensed under GPL-2-or-later.