mirror of https://bitbucket.org/ausocean/av.git
container/mts: GetPTSRange checks for PUSI when looking for first PTS
This commit is contained in:
parent
74d22dde2e
commit
0497ee5302
|
@ -320,15 +320,22 @@ func DiscontinuityIndicator(f bool) Option {
|
|||
|
||||
// GetPTSRange retreives the first and last PTS of an MPEGTS clip.
|
||||
func GetPTSRange(clip []byte, pid uint16) (pts [2]uint64, err error) {
|
||||
// Find the first packet with PID pidType.
|
||||
pkt, _, err := FindPid(clip, pid)
|
||||
var _pkt packet.Packet
|
||||
// Find the first packet with PID pidType and PUSI.
|
||||
var i int
|
||||
for {
|
||||
pkt, _i, err := FindPid(clip[i:], pid)
|
||||
if err != nil {
|
||||
return [2]uint64{}, err
|
||||
}
|
||||
copy(_pkt[:], pkt)
|
||||
if _pkt.PayloadUnitStartIndicator() {
|
||||
break
|
||||
}
|
||||
i = _i + PacketSize
|
||||
}
|
||||
|
||||
// Get the payload of the packet, which will be the start of the PES packet.
|
||||
var _pkt packet.Packet
|
||||
copy(_pkt[:], pkt)
|
||||
payload, err := packet.Payload(&_pkt)
|
||||
if err != nil {
|
||||
return [2]uint64{}, err
|
||||
|
|
Loading…
Reference in New Issue