pub struct Header {
    pub source: HeaderSource,
    pub version: Option<Version>,
    pub layer: Option<Layer>,
    pub mode: Option<Mode>,
    pub min_channel_count: u8,
    pub max_channel_count: u8,
    pub min_sample_rate_hz: u16,
    pub max_sample_rate_hz: u16,
    pub total_sample_count: u64,
    pub total_duration: Duration,
    pub avg_sample_rate_hz: Option<u16>,
    pub avg_bitrate_bps: Option<u32>,
}
Expand description

Properties of an MPEG audio stream

A virtual MPEG audio header, built from both the XING header and optionally aggregated from all valid MPEG frame headers.

Fields

source: HeaderSource

Source of the metadata in this header

version: Option<Version>

MPEG version

The common MPEG version in all frames or None if either unknown or inconsistent.

layer: Option<Layer>

MPEG layer

The common MPEG layer in all frames or None if either unknown or inconsistent.

mode: Option<Mode>

MPEG mode

The common MPEG mode in all frames or None if either unknown or inconsistent.

min_channel_count: u8

Minimum number of channels

max_channel_count: u8

Maximum number of channels

min_sample_rate_hz: u16

Minimum sample rate in Hz

max_sample_rate_hz: u16

Maximum sample rate in Hz

total_sample_count: u64

Total number of samples per channel

total_duration: Duration

Total duration

avg_sample_rate_hz: Option<u16>

Average sample rate in Hz

avg_bitrate_bps: Option<u32>

Average bitrate in bits/sec

Implementations

Read from a source that implements Read

Examples
use std::{path::Path, fs::File, io::BufReader};
use mpeg_audio_header::{Header, ParseMode};

let path = Path::new("test/source.mp3");
let file = File::open(path).unwrap();
let mut source = BufReader::new(file);
let header = Header::read_from_source(&mut source, ParseMode::IgnoreVbrHeaders).unwrap();
println!("MPEG audio header: {:?}", header);

Read from a file

Examples
use std::{path::Path, fs::File};
use mpeg_audio_header::{Header, ParseMode};

let path = Path::new("test/source.mp3");
let file = File::open(path).unwrap();
let header = Header::read_from_file(&file, ParseMode::PreferVbrHeaders).unwrap();
println!("MPEG audio header: {:?}", header);

Read from a file path

Examples
use std::path::Path;
use mpeg_audio_header::{Header, ParseMode};

let path = Path::new("test/source.mp3");
let header = Header::read_from_path(&path, ParseMode::PreferVbrHeaders).unwrap();
println!("MPEG audio header: {:?}", header);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.