Skip to content
mpg123 bindings for golang
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Go bindings for the mpg123 mp3 decoding library

These bingings were heavily influenced by weberc2's work


First init the library


Open a file and check the error

mp3, err := mpg123.Open("example.mp3")
if err != nil {

errors are passed verbatim from mpg123

Get the format

rate, channels, encoding, format := mp3.Format()
fmt.Printf("Rate: %i Channels: %i Encoding: %i Format: %s\n", rate, channels, encoding, format)

format is compatible with audio.Format consts

Read 100 bytes of mp3 data into a buffer

data := make([]byte, 100)
err := mp3.Read(data)

mp3 conforms to the io.Reader, io.Seeker, io.Closer interfaces, though seeking is not yet implemented.

This means it can be used quite handily with the go audio library.

You can’t perform that action at this time.