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.
39 lines
732 B
Go
39 lines
732 B
Go
package main
|
|
|
|
import (
|
|
"gitlab.com/ics_cinnamon/joy4/av"
|
|
"gitlab.com/ics_cinnamon/joy4/av/avutil"
|
|
"gitlab.com/ics_cinnamon/joy4/cgo/ffmpeg"
|
|
"gitlab.com/ics_cinnamon/joy4/format"
|
|
)
|
|
|
|
// 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()
|
|
}
|