aac

package module
v0.0.0-...-e088a49 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

README

aac-go

aac-go provides AAC codec encoder based on VisualOn AAC encoder library.

Usage

package main

import (
	"bytes"
	"io/ioutil"
	"os"

	"git.gammaspectra.live/S.O.N.G/voaac-go"
	"github.com/youpy/go-wav"
)

func main() {
	file, err := os.Open("test.wav")
	if err != nil {
		panic(err)
	}

	wreader := wav.NewReader(file)
	f, err := wreader.Format()
	if err != nil {
		panic(err)
	}

	buf := bytes.NewBuffer(make([]byte, 0))

	opts := &aac.Options{}
	opts.SampleRate = int(f.SampleRate)
	opts.NumChannels = int(f.NumChannels)

	enc, err := aac.NewEncoder(buf, opts)
	if err != nil {
		panic(err)
	}

	err = enc.Encode(wreader)
	if err != nil {
		panic(err)
	}

	err = enc.Close()
	if err != nil {
		panic(err)
	}

	err = ioutil.WriteFile("test.aac", buf.Bytes(), 0644)
	if err != nil {
		panic(err)
	}
}

More

For H.264 encoder see x264-go.

Documentation

Overview

Package aac provides AAC codec encoder based on [VisualOn AAC encoder](https://github.com/mstorsjo/vo-aacenc) library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder type.

func NewEncoder

func NewEncoder(w io.Writer, opts *Options) (e *Encoder, err error)

NewEncoder returns new AAC encoder.

func (*Encoder) Close

func (e *Encoder) Close() error

Close closes encoder.

func (*Encoder) Encode

func (e *Encoder) Encode(r io.Reader) (err error)

Encode encodes data from reader.

type Options

type Options struct {
	// Audio file sample rate
	SampleRate int
	// Encoder bit rate in bits/sec
	BitRate int
	// Number of channels on input (1,2)
	NumChannels int
}

Options represent encoding options.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL