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.
|
// GetPTSRange retreives the first and last PTS of an MPEGTS clip.
|
||||||
func GetPTSRange(clip []byte, pid uint16) (pts [2]uint64, err error) {
|
func GetPTSRange(clip []byte, pid uint16) (pts [2]uint64, err error) {
|
||||||
// Find the first packet with PID pidType.
|
var _pkt packet.Packet
|
||||||
pkt, _, err := FindPid(clip, pid)
|
// Find the first packet with PID pidType and PUSI.
|
||||||
if err != nil {
|
var i int
|
||||||
return [2]uint64{}, err
|
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.
|
// 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)
|
payload, err := packet.Payload(&_pkt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [2]uint64{}, err
|
return [2]uint64{}, err
|
||||||
|
|
Loading…
Reference in New Issue