revid: trying to fix jumpy rtp

This commit is contained in:
saxon 2018-12-14 20:05:10 +10:30
parent d8587bdbe2
commit 618fadd90b
3 changed files with 5 additions and 6 deletions

View File

@ -188,7 +188,6 @@ func (c *Config) Validate(r *Revid) error {
switch c.Output1 { switch c.Output1 {
case File: case File:
case Rtp:
case Udp: case Udp:
case Rtmp, FfmpegRtmp: case Rtmp, FfmpegRtmp:
if c.RtmpUrl == "" { if c.RtmpUrl == "" {
@ -204,7 +203,7 @@ func (c *Config) Validate(r *Revid) error {
defaultOutput) defaultOutput)
c.Output1 = defaultOutput c.Output1 = defaultOutput
fallthrough fallthrough
case Http: case Http, Rtp:
c.Logger.Log(smartlogger.Info, pkg+"defaulting frames per clip for http out", c.Logger.Log(smartlogger.Info, pkg+"defaulting frames per clip for http out",
"framesPerClip", httpFramesPerClip) "framesPerClip", httpFramesPerClip)
c.FramesPerClip = httpFramesPerClip c.FramesPerClip = httpFramesPerClip

View File

@ -38,7 +38,7 @@ import (
const ( const (
psiPacketSize = 184 psiPacketSize = 184
psiSendCount = 21 psiSendCount = 7
) )
type MetaData struct { type MetaData struct {

View File

@ -63,7 +63,7 @@ func NewEncoder(dst io.Writer, fps int) *Encoder {
ssrc: rand.Uint32(), ssrc: rand.Uint32(),
frameInterval: time.Duration(float64(time.Second) / float64(fps)), frameInterval: time.Duration(float64(time.Second) / float64(fps)),
fps: 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) { func (e *Encoder) Write(data []byte) (int, error) {
e.buffer = append(e.buffer, data...) e.buffer = append(e.buffer, data...)
for len(e.buffer) >= sendLength { for len(e.buffer) >= sendLength {
e.Encode(e.buffer) e.Encode(e.buffer[:sendLength])
e.buffer = e.buffer[:0] e.buffer = e.buffer[sendLength:]
} }
return len(data), nil return len(data), nil
} }