fix PESUIntToTs problem
This commit is contained in:
parent
841ebf6b90
commit
77392eddb2
@ -15,6 +15,7 @@ type Stream struct {
|
||||
Header *ts.PESHeader
|
||||
Title string
|
||||
Data bytes.Buffer
|
||||
Type uint
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -39,10 +40,11 @@ func main() {
|
||||
if stream == nil {
|
||||
stream = &Stream{
|
||||
PID: pid,
|
||||
Type: info.StreamType,
|
||||
}
|
||||
if info.StreamType == ts.ElementaryStreamTypeH264 {
|
||||
if stream.Type == ts.ElementaryStreamTypeH264 {
|
||||
stream.Title = "h264"
|
||||
} else if info.StreamType == ts.ElementaryStreamTypeAdtsAAC {
|
||||
} else if stream.Type == ts.ElementaryStreamTypeAdtsAAC {
|
||||
stream.Title = "aac"
|
||||
}
|
||||
streams[pid] = stream
|
||||
@ -64,7 +66,7 @@ func main() {
|
||||
return
|
||||
}
|
||||
if stream.Data.Len() == int(stream.Header.DataLength) {
|
||||
fmt.Println(stream.Title, stream.Data.Len(), "total")
|
||||
fmt.Println(stream.Type, stream.Title, stream.Data.Len(), "total")
|
||||
fmt.Println(hex.Dump(stream.Data.Bytes()))
|
||||
}
|
||||
return
|
||||
|
@ -516,7 +516,8 @@ func ReadPESHeader(r io.Reader) (res *PESHeader, err error) {
|
||||
self.PTS = PESUIntToTs(v)
|
||||
|
||||
if debug {
|
||||
fmt.Printf("pes: pts %d %f\n", self.PTS, float64(self.PTS)/90000)
|
||||
fmt.Printf("pes: pts %x(%x)=>%x %f\n",
|
||||
v, (v>>1)&0xef, self.PTS, float64(self.PTS)/90000)
|
||||
}
|
||||
}
|
||||
|
||||
|
2
ts.go
2
ts.go
@ -64,7 +64,7 @@ type PESHeader struct {
|
||||
|
||||
func PESUIntToTs(v uint64) (ts uint64) {
|
||||
// 0010 PTS 32..30 1 PTS 29..15 1 PTS 14..00 1
|
||||
return (((v>>33)&0x7)<<30) | (((v>>17)&0xef)<<15) | ((v>>1)&0xef)
|
||||
return (((v>>33)&0x7)<<30) | (((v>>17)&0x7fff)<<15) | ((v>>1)&0x7fff)
|
||||
}
|
||||
|
||||
func UIntToPCR(v uint64) uint64 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user