mpeg-audio-header

Crates.iompeg-audio-header
lib.rsmpeg-audio-header
version0.0.6
sourcesrc
created_at2022-02-04 13:30:24.039201
updated_at2023-01-30 22:52:42.783783
descriptionAn all-you-can-eat parser for MPEG audio metadata
homepage
repositoryhttps://github.com/uklotzde/mpeg-audio-header
max_upload_size
id526791
size88,745
Uwe Klotz (uklotzde)

documentation

README

mpeg-audio-header

Crates.io Docs.rs Deps.rs Security audit Continuous integration License: MPL 2.0

Parse metadata of an MPEG audio stream from VBR (XING/VBRI) and MPEG frame headers.

Disclaimer

This crate is unmaintained. I recommend to take a look at lofty-rs as a more versatile replacement.

If you encounter issues or missing features in lofty-rs, please report them and they will probably get fixed quickly.

Motivation

The specification of the MPEG audio format is very weak. There is no dedicated header that contains consistent metadata of the encoded audio stream like the number of channels, the sample rate (Hz), or the average bitrate (bits per second) for estimating the compression ratio and audio quality.

This library aims to determine audio metadata by applying a best effort heuristic. The metadata is either contained in a VBR header (XING/VBRI) that precedes the audio frames or it could be collected and aggregated from all MPEG frame headers to obtain more precise and reliable information.

Limitations

The metadata parser has deliberately been designed as fault tolerant and may provide results even for corrupt or invalid files. The accuracy of such results is undefined. A more restritive parsing strategy with respective error reporting might be added in the future. Currently only I/O errors could stop the parser from continuing.

This crate does not aim to parse ID3 or APE metadata and never will. Use a dedicated crate like id3 or ape for this purpose.

Testing

Test files are expected to be available in the test-data/ directory. They are not provided as part of this repository and currently need to be downloaded manually. Please refer to the .keep file in each directory which contains the respective download URL. Automatically downloading the test files on demand would be awesome.

The test files are referred to by their path. If no dedicated checks for the resulting header contents are provided then only reading the header of those files must succeed. Expected failures for corrupt files could also be verified.

Run the tests with -- --nocapture for diagnostic output on stdout/stderr.

Credits

This crate initially started as a fork of mp3-duration. Soon it became obvious that a substantial rewrite was necessary to cope with the new requirements and to properly handle all format variants correctly. Yet some code fragments may still reflect that heritage.

Some ideas have also been borrowed from symphonia and lofty-rs.

License

Licensed under the Mozilla Public License 2.0 (MPL-2.0) (see MPL-2.0.txt or https://www.mozilla.org/MPL/2.0/).

Permissions of this copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work.

Contribution

Any contribution intentionally submitted for inclusion in the work by you shall be licensed under the Mozilla Public License 2.0 (MPL-2.0).

It is required to add the following header with the corresponding SPDX short identifier to the top of each file:

// SPDX-License-Identifier: MPL-2.0
Commit count: 18

cargo fmt