-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (32 loc) · 861 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 (
"fmt"
"github.com/vitmod/vdk/av"
"github.com/vitmod/vdk/av/avutil"
"github.com/vitmod/vdk/format"
)
func init() {
format.RegisterAll()
}
func main() {
file, _ := avutil.Open("projectindex.flv")
streams, _ := file.Streams()
for _, stream := range streams {
if stream.Type().IsAudio() {
astream := stream.(av.AudioCodecData)
fmt.Println(astream.Type(), astream.SampleRate(), astream.SampleFormat(), astream.ChannelLayout())
} else if stream.Type().IsVideo() {
vstream := stream.(av.VideoCodecData)
fmt.Println(vstream.Type(), vstream.Width(), vstream.Height())
}
}
for i := 0; i < 10; i++ {
var pkt av.Packet
var err error
if pkt, err = file.ReadPacket(); err != nil {
break
}
fmt.Println("pkt", i, streams[pkt.Idx].Type(), "len", len(pkt.Data), "keyframe", pkt.IsKeyFrame)
}
file.Close()
}