46 lines
766 B
Go
46 lines
766 B
Go
//go:build !disable_format_opus && cgo
|
|
|
|
package opus
|
|
|
|
import (
|
|
"git.gammaspectra.live/S.O.N.G/Kirika/audio/format/flac"
|
|
"git.gammaspectra.live/S.O.N.G/Kirika/test"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestEncodeOpus(t *testing.T) {
|
|
fp, err := os.Open(test.SingleSample24)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
defer fp.Close()
|
|
source, err := flac.NewFormat().Open(fp)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
|
|
target, err := os.CreateTemp("/tmp", "encode_test_*.opus")
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
|
|
defer func() {
|
|
name := target.Name()
|
|
target.Close()
|
|
os.Remove(name)
|
|
}()
|
|
|
|
options := make(map[string]interface{})
|
|
options["bitrate"] = "256k"
|
|
|
|
err = NewFormat().Encode(source, target, options)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
}
|