Awesome Go

go-aac

CategoryAudio and Music
SubcategoryAudio and Music
Stars8

Pure-Go AAC-LC encoder and decoder ported from FFmpeg

About go-aac

go-aac

CI Go Reference OpenSSF Scorecard License: LGPL-2.1-or-later Sponsor

Pure-Go AAC-LC encoder and decoder, ported from FFmpeg's native AAC encoder and fixed-point decoder. No cgo and no external libraries. Each subsystem is validated bit for bit against the C reference, and the decoder's output is byte-identical to ffmpeg -c:a aac_fixed.

It is the AAC member of a family of pure-Go audio libraries with go-wav, go-flac, go-opus and go-m4a, and has the same API shape.

Status

  • Encoder: complete for AAC-LC, mono and stereo at 44.1 and 48 kHz, with FFmpeg's three coders (NMR, the default, twoloop and fast) and all four coding tools. Quality is on par with FFmpeg's aac encoder, and the default coder is faster than it.
  • Decoder: AAC-LC, mono and stereo, 7.35 to 96 kHz, ADTS or raw access units. HE-AAC is rejected with ErrUnsupportedSBR or ErrUnsupportedPS.
  • Not supported: HE-AAC (SBR/PS), xHE-AAC, LATM, ER/LD/ELD, more than two channels, VBR and MP4 muxing (use go-m4a).

Install

go get github.com/tphakala/go-aac

Example

import aacpcm "github.com/tphakala/go-aac/pcm"

// Encode interleaved 16-bit PCM to an ADTS stream.
cfg := aacpcm.Config{SampleRate: 48000, BitDepth: 16, Channels: 1, Bitrate: 96000}
err := aacpcm.EncodeInterleaved(w, cfg, pcmBytes)

// Decode an ADTS stream back to interleaved 16-bit PCM.
d, err := aacpcm.NewDecoder(r)
_, err = io.Copy(out, d)

Documentation

  • Usage: streaming and frame-level encoding and decoding, muxing raw access units, gapless playback, the low-level aac package.
  • Quality and validation: quality measurements and how the port is checked against the C reference.
  • Performance: benchmarks against FFmpeg, the SIMD kernels and -tags noasm, profiling notes.
  • API reference on pkg.go.dev.

Sponsor

go-aac is maintained in my own time. If it is useful to you or your project, you can support continued maintenance through GitHub Sponsors; sponsorship is entirely optional and never gates any feature.

Sponsor on GitHub

License

LGPL-2.1-or-later. go-aac is a derivative work of FFmpeg's LGPL-licensed AAC encoder and cannot be relicensed permissively. See LICENSE and PROVENANCE.md.

Frequently Asked Questions

What is go-aac?

go-aac is a Audio and Music library for the Go programming language. Pure-Go AAC-LC encoder and decoder ported from FFmpeg

How do I install go-aac?

Install go-aac with the Go module system using `go get tphakala/go-aac`. Check the repository for the current installation instructions.

What category does go-aac belong to?

go-aac is listed under Audio and Music, specifically Audio and Music.

← Back to Audio and Music