diff --git a/container/mts/pes/pes.go b/container/mts/pes/pes.go index b0e40f86..5b5cb612 100644 --- a/container/mts/pes/pes.go +++ b/container/mts/pes/pes.go @@ -26,6 +26,8 @@ LICENSE package pes +import "github.com/Comcast/gots" + const MaxPesSize = 64 * 1 << 10 /* @@ -108,16 +110,11 @@ func (p *Packet) Bytes(buf []byte) []byte { boolByte(p.ACIF)<<2 | boolByte(p.CRCF)<<1 | boolByte(p.EF)), p.HeaderLength, }...) + if p.PDI == byte(2) { - pts := 0x2100010001 | (p.PTS&0x1C0000000)<<3 | (p.PTS&0x3FFF8000)<<2 | - (p.PTS&0x7FFF)<<1 - buf = append(buf, []byte{ - byte((pts & 0xFF00000000) >> 32), - byte((pts & 0x00FF000000) >> 24), - byte((pts & 0x0000FF0000) >> 16), - byte((pts & 0x000000FF00) >> 8), - byte(pts & 0x00000000FF), - }...) + ptsIdx := len(buf) + buf = buf[:ptsIdx+5] + gots.InsertPTS(buf[ptsIdx:], p.PTS) } buf = append(buf, append(p.Stuff, p.Data...)...) return buf