You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1017 B
Go
45 lines
1017 B
Go
package main
|
|
|
|
import (
|
|
"git.icomsys.co.kr/ljhwan026/joy4/av"
|
|
"git.icomsys.co.kr/ljhwan026/joy4/av/avutil"
|
|
"git.icomsys.co.kr/ljhwan026/joy4/av/transcode"
|
|
"git.icomsys.co.kr/ljhwan026/joy4/cgo/ffmpeg"
|
|
"git.icomsys.co.kr/ljhwan026/joy4/format"
|
|
)
|
|
|
|
// need ffmpeg with libfdkaac installed
|
|
|
|
func init() {
|
|
format.RegisterAll()
|
|
}
|
|
|
|
func main() {
|
|
infile, _ := avutil.Open("speex.flv")
|
|
|
|
findcodec := func(stream av.AudioCodecData, i int) (need bool, dec av.AudioDecoder, enc av.AudioEncoder, err error) {
|
|
need = true
|
|
dec, _ = ffmpeg.NewAudioDecoder(stream)
|
|
enc, _ = ffmpeg.NewAudioEncoderByName("libfdk_aac")
|
|
enc.SetSampleRate(stream.SampleRate())
|
|
enc.SetChannelLayout(av.CH_STEREO)
|
|
enc.SetBitrate(12000)
|
|
enc.SetOption("profile", "HE-AACv2")
|
|
return
|
|
}
|
|
|
|
trans := &transcode.Demuxer{
|
|
Options: transcode.Options{
|
|
FindAudioDecoderEncoder: findcodec,
|
|
},
|
|
Demuxer: infile,
|
|
}
|
|
|
|
outfile, _ := avutil.Create("out.ts")
|
|
avutil.CopyFile(outfile, trans)
|
|
|
|
outfile.Close()
|
|
infile.Close()
|
|
trans.Close()
|
|
}
|