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.
41 lines
718 B
Go
41 lines
718 B
Go
|
|
package main
|
|
|
|
import (
|
|
"github.com/Danile71/joy4/av"
|
|
"github.com/Danile71/joy4/format"
|
|
"github.com/Danile71/joy4/av/avutil"
|
|
"github.com/Danile71/joy4/cgo/ffmpeg"
|
|
)
|
|
|
|
// need ffmpeg installed
|
|
|
|
func init() {
|
|
format.RegisterAll()
|
|
}
|
|
|
|
func main() {
|
|
file, _ := avutil.Open("projectindex.flv")
|
|
streams, _ := file.Streams()
|
|
var dec *ffmpeg.AudioDecoder
|
|
|
|
for _, stream := range streams {
|
|
if stream.Type() == av.AAC {
|
|
dec, _ = ffmpeg.NewAudioDecoder(stream.(av.AudioCodecData))
|
|
}
|
|
}
|
|
|
|
for i := 0; i < 10; i++ {
|
|
pkt, _ := file.ReadPacket()
|
|
if streams[pkt.Idx].Type() == av.AAC {
|
|
ok, frame, _ := dec.Decode(pkt.Data)
|
|
if ok {
|
|
println("decode samples", frame.SampleCount)
|
|
}
|
|
}
|
|
}
|
|
|
|
file.Close()
|
|
}
|
|
|