|
|
|
@ -78,9 +78,14 @@ func (t *tsFile) newReader() io.Reader { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (t *tsFile) writeH264( |
|
|
|
func (t *tsFile) writeH264( |
|
|
|
h264SPS []byte, h264PPS []byte, |
|
|
|
h264SPS []byte, |
|
|
|
dts time.Duration, pts time.Duration, isIDR bool, nalus [][]byte) error { |
|
|
|
h264PPS []byte, |
|
|
|
|
|
|
|
dts time.Duration, |
|
|
|
|
|
|
|
pts time.Duration, |
|
|
|
|
|
|
|
isIDR bool, |
|
|
|
|
|
|
|
nalus [][]byte) error { |
|
|
|
if !t.firstPacketWritten { |
|
|
|
if !t.firstPacketWritten { |
|
|
|
|
|
|
|
t.firstPacketWritten = true |
|
|
|
t.minPTS = pts |
|
|
|
t.minPTS = pts |
|
|
|
t.maxPTS = pts |
|
|
|
t.maxPTS = pts |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
@ -121,13 +126,8 @@ func (t *tsFile) writeH264( |
|
|
|
af = &astits.PacketAdaptationField{} |
|
|
|
af = &astits.PacketAdaptationField{} |
|
|
|
} |
|
|
|
} |
|
|
|
af.RandomAccessIndicator = true |
|
|
|
af.RandomAccessIndicator = true |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !t.firstPacketWritten { |
|
|
|
// send PCR with every IDR
|
|
|
|
t.firstPacketWritten = true |
|
|
|
|
|
|
|
if af == nil { |
|
|
|
|
|
|
|
af = &astits.PacketAdaptationField{} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
af.HasPCR = true |
|
|
|
af.HasPCR = true |
|
|
|
pcr := time.Since(t.startPCR) |
|
|
|
pcr := time.Since(t.startPCR) |
|
|
|
af.PCR = &astits.ClockReference{Base: int64(pcr.Seconds() * 90000)} |
|
|
|
af.PCR = &astits.ClockReference{Base: int64(pcr.Seconds() * 90000)} |
|
|
|
@ -160,6 +160,7 @@ func (t *tsFile) writeH264( |
|
|
|
func (t *tsFile) writeAAC(sampleRate int, channelCount int, pts time.Duration, au []byte) error { |
|
|
|
func (t *tsFile) writeAAC(sampleRate int, channelCount int, pts time.Duration, au []byte) error { |
|
|
|
if t.videoTrack == nil { |
|
|
|
if t.videoTrack == nil { |
|
|
|
if !t.firstPacketWritten { |
|
|
|
if !t.firstPacketWritten { |
|
|
|
|
|
|
|
t.firstPacketWritten = true |
|
|
|
t.minPTS = pts |
|
|
|
t.minPTS = pts |
|
|
|
t.maxPTS = pts |
|
|
|
t.maxPTS = pts |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
@ -187,8 +188,8 @@ func (t *tsFile) writeAAC(sampleRate int, channelCount int, pts time.Duration, a |
|
|
|
RandomAccessIndicator: true, |
|
|
|
RandomAccessIndicator: true, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if t.videoTrack == nil && !t.firstPacketWritten { |
|
|
|
if t.videoTrack == nil { |
|
|
|
t.firstPacketWritten = true |
|
|
|
// if audio is the only track, send PCR with every AU
|
|
|
|
af.HasPCR = true |
|
|
|
af.HasPCR = true |
|
|
|
pcr := time.Since(t.startPCR) |
|
|
|
pcr := time.Since(t.startPCR) |
|
|
|
af.PCR = &astits.ClockReference{Base: int64(pcr.Seconds() * 90000)} |
|
|
|
af.PCR = &astits.ClockReference{Base: int64(pcr.Seconds() * 90000)} |
|
|
|
|