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 ¶
View Source
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.
- Xing or VBRI header present: the frame count is read from it and only the first frame's region is touched.
- Neither header present, constant bitrate: a bounded set of frame headers is sampled across the stream (see probeConstantBitRate) and the duration comes from dividing the audio byte range by the bitrate, which is exact for CBR. Cost is a fixed handful of small windows regardless of file size.
- Neither header present, variable bitrate: the whole stream is read to end of audio in 256 KiB blocks to count frames, because nothing in the file declares the length and no cheaper method is correct. Only 4-byte frame headers are decoded, never audio, but the bytes are still read.
The last case is negligible for a local file but 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.
Types ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.