Documentation
¶
Index ¶
- Constants
- func AAC(r io.ReadSeeker) (float64, error)
- func DSD(r io.ReadSeeker) (float64, error)
- func Duration(file io.ReadSeeker, filetype int) (float64, error)
- func FLAC(r io.ReadSeeker) (float64, error)
- func Mp3(r io.ReadSeeker) (float64, error)
- func Mp4(r io.ReadSeeker) (float64, error)
- func Ogg(r io.ReadSeeker) (float64, error)
- func Wav(r io.ReadSeeker) (float64, error)
- func WebM(r io.ReadSeeker) (float64, error)
- type VBRI
- type Xing
Constants ¶
const ( TypeFlac int = 0 TypeMp4 int = 1 TypeMp3 int = 2 TypeOgg int = 3 TypeDsd int = 4 TypeWav int = 5 TypeAac int = 6 TypeWebM int = 7 )
File Type Constant
Variables ¶
This section is empty.
Functions ¶
func AAC ¶
func AAC(r io.ReadSeeker) (float64, error)
AAC parses raw AAC ADTS streams and returns duration in seconds. It scans ADTS frames, accumulating samples and dividing by sample rate. Ref: ISO/IEC 13818-7 (ADTS header)
func Duration ¶
func Duration(file io.ReadSeeker, filetype int) (float64, error)
Duration Get duration of specific music file type.
func Mp3 ¶
func Mp3(r io.ReadSeeker) (float64, error)
Mp3 Calculate mp3 files duration.
I/O cost depends on what the stream declares. When a Xing or VBRI header is present the frame count is read from it and only the first frame's region is touched. When neither is present -- which includes plain CBR streams, whose duration was previously derived from the file size alone -- the whole stream is read to end of file in 256 KiB blocks to count frames. Only 4-byte frame headers are decoded, never audio, but the bytes are still read.
That is negligible for a local file (0.67 ms for a 7.9 MB stream) but it changes the cost profile for an io.ReadSeeker backed by the network, such as an HTTP range-request reader: size timeouts and any caching accordingly.