diff --git a/stream/rtp/encoder.go b/stream/rtp/encoder.go index 20df9434..329a24c0 100644 --- a/stream/rtp/encoder.go +++ b/stream/rtp/encoder.go @@ -73,8 +73,8 @@ func NewEncoder(dst io.Writer, fps int) *Encoder { func (e *Encoder) Write(data []byte) (int, error) { e.buffer = append(e.buffer, data...) for len(e.buffer) >= sendLen { - e.Encode(e.buffer[:sendLen]) - e.buffer = e.buffer[sendLen:] + e.Encode(e.buffer) + e.buffer = e.buffer[:0] } return len(data), nil }