Browse Source

优化webrtc的播放逻辑,修改时标错误

v4
jianglieshan 3 years ago
parent
commit
3cf3aef3ec
  1. 13
      main.go

13
main.go

@ -291,20 +291,19 @@ func run() {
lastTimeStampV = ts lastTimeStampV = ts
if pack.IDR { if pack.IDR {
for _, nalu := range vt.ExtraData.NALUs { for _, nalu := range vt.ExtraData.NALUs {
for _, packet := range vpacketer.Packetize(nalu, s) { for _, packet := range vpacketer.Packetize(nalu, 0) {
err = videoTrack.WriteRTP(packet) err = videoTrack.WriteRTP(packet)
} }
} }
} }
var firstTs uint32
for naluIndex, nalu := range pack.NALUs { for naluIndex, nalu := range pack.NALUs {
packets := vpacketer.Packetize(nalu, s) var packets []*rtp.Packet
for packIndex, packet := range packets { if naluIndex == len(pack.NALUs)-1 {
if naluIndex == 0 { packets = vpacketer.Packetize(nalu, s)
firstTs = packet.Timestamp
} else { } else {
packet.Timestamp = firstTs packets = vpacketer.Packetize(nalu, 0)
} }
for packIndex, packet := range packets {
packet.Marker = naluIndex == len(pack.NALUs)-1 && packIndex == len(packets)-1 packet.Marker = naluIndex == len(pack.NALUs)-1 && packIndex == len(packets)-1
err = videoTrack.WriteRTP(packet) err = videoTrack.WriteRTP(packet)
} }

Loading…
Cancel
Save