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

This commit is contained in:
jianglieshan
2022-01-10 16:54:57 +08:00
parent 4ffebc18e2
commit 3cf3aef3ec

15
main.go
View File

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