From 618fadd90bb6acfdfb1110570c52d7dacb28246e Mon Sep 17 00:00:00 2001 From: saxon Date: Fri, 14 Dec 2018 20:05:10 +1030 Subject: [PATCH] revid: trying to fix jumpy rtp --- revid/config.go | 3 +-- stream/mts/encoder.go | 2 +- stream/rtp/encoder.go | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/revid/config.go b/revid/config.go index 72165f60..b6402860 100644 --- a/revid/config.go +++ b/revid/config.go @@ -188,7 +188,6 @@ func (c *Config) Validate(r *Revid) error { switch c.Output1 { case File: - case Rtp: case Udp: case Rtmp, FfmpegRtmp: if c.RtmpUrl == "" { @@ -204,7 +203,7 @@ func (c *Config) Validate(r *Revid) error { defaultOutput) c.Output1 = defaultOutput fallthrough - case Http: + case Http, Rtp: c.Logger.Log(smartlogger.Info, pkg+"defaulting frames per clip for http out", "framesPerClip", httpFramesPerClip) c.FramesPerClip = httpFramesPerClip diff --git a/stream/mts/encoder.go b/stream/mts/encoder.go index 3236c95b..31fe4923 100644 --- a/stream/mts/encoder.go +++ b/stream/mts/encoder.go @@ -38,7 +38,7 @@ import ( const ( psiPacketSize = 184 - psiSendCount = 21 + psiSendCount = 7 ) type MetaData struct { diff --git a/stream/rtp/encoder.go b/stream/rtp/encoder.go index c8750e95..e20be442 100644 --- a/stream/rtp/encoder.go +++ b/stream/rtp/encoder.go @@ -63,7 +63,7 @@ func NewEncoder(dst io.Writer, fps int) *Encoder { ssrc: rand.Uint32(), frameInterval: time.Duration(float64(time.Second) / float64(fps)), fps: fps, - buffer: make([]byte, 0, sendLength), + buffer: make([]byte, 0), } } @@ -72,8 +72,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) >= sendLength { - e.Encode(e.buffer) - e.buffer = e.buffer[:0] + e.Encode(e.buffer[:sendLength]) + e.buffer = e.buffer[sendLength:] } return len(data), nil }