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.
joy4/examples/open_probe_file/main.go

40 lines
882 B
Go

package main
import (
"fmt"
"gitlab.com/ics_cinnamon/joy4/av"
"gitlab.com/ics_cinnamon/joy4/av/avutil"
"gitlab.com/ics_cinnamon/joy4/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()
}