gots (Go Transport Streams) is a library for working with MPEG transport streams. It provides abstractions for reading packet information and program specific information (psi)
Add requests to Github issues. To submit a PR see CONTRIBUTING
go test -race ./...Travis-CI will run these tests:
go test -v ./...This software is licensed under the MIT license. For full text see LICENSE
We take our code of conduct very seriously. Please abide by it.
This is a simple example that extracts all PIDs from a ts file and prints them. CLI example parser can be found here
funcmain() {
pidSet:=make(map[uint16]bool, 5)
filename:="./scenario1.ts"file, err:=os.Open(filename)
iferr==nil {
pkt:=make([]byte, packet.PacketSize)
forread, err:=file.Read(pkt); read>0&&err==nil; read, err=file.Read(pkt) {
iferr!=nil {
println(err)
return
}
pid, err:=packet.Pid(pkt)
iferr!=nil {
println(err)
continue
}
pidSet[pid] =true
}
forv:=rangepidSet {
fmt.Printf("Found pid %d\n", v)
}
} else {
fmt.Printf("Unable to open file [%s] due to [%s]\n", filename, err.Error())
}