forked from kerberos-io/joy4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (31 loc) · 760 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"github.com/RealKeyboardWarrior/joy4/av"
"github.com/RealKeyboardWarrior/joy4/av/avutil"
"github.com/RealKeyboardWarrior/joy4/cgo/ffmpeg"
"github.com/RealKeyboardWarrior/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()
}