Skip to content
forked from viert/lame

Simple libmp3lame-powered mp3 encoder for Go

License

Notifications You must be signed in to change notification settings

git-jiadong/go-lame

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go-LAME Wrapper

====

This project integrates the libmp3lame source code directly into Go, providing a set of Go-native interfaces for MP3 encoding. By embedding the LAME library, the project eliminates the need for external dynamic library dependencies, offering a seamless, standalone solution for developers working with MP3 encoding in Go.

Key Features:

  • Direct integration of libmp3lame with Go.
  • No external dependencies or dynamic libraries required.
  • Simple and efficient Go-native interfaces for MP3 encoding tasks.
  • Perfect for applications where portability and simplicity are critical.

Example:

package main

import (
	"bufio"
	"os"

	"github.com/git-jiadong/go-lame"
)

func main() {

	//input.raw: 44100 rate 2 channel 16bits pcm
	//output.mp3: 16000 rate 2 channel 16bits mp3
	f, err := os.Open("input.raw")
	if err != nil {
		panic(err)
	}
	defer f.Close()
	reader := bufio.NewReader(f)

	of, err := os.Create("output.mp3")
	if err != nil {
		panic(err)
	}
	defer of.Close()

	wr := lame.NewWriter(of)
	wr.Encoder.SetInSamplerate(44100)
	wr.Encoder.SetOutSamplerate(16000)
	wr.Encoder.SetNumChannels(2)
	wr.Encoder.SetQuality(5)
	// IMPORTANT!
	wr.Encoder.InitParams()
	reader.WriteTo(wr)
	wr.Close()
}

About

Simple libmp3lame-powered mp3 encoder for Go

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 99.3%
  • Go 0.7%