diff --git a/revid/Config.go b/revid/Config.go index ac8ca6a0..cdb09e5e 100644 --- a/revid/Config.go +++ b/revid/Config.go @@ -86,7 +86,7 @@ const ( defaultHeight = "720" defaultIntraRefreshPeriod = "100" defaultTimeout = "0" - defaultQuantization = "35" + defaultQuantization = "40" defaultBitrate = "0" ) diff --git a/revid/RevidInstance.go b/revid/RevidInstance.go index 30bf3430..0ed9a4a8 100644 --- a/revid/RevidInstance.go +++ b/revid/RevidInstance.go @@ -59,12 +59,12 @@ const ( clipDuration = 1 // s mp2tPacketSize = 188 // MPEG-TS packet size mp2tMaxPackets = 2016 * clipDuration // # first multiple of 7 and 8 greater than 2000 - ringBufferSize = 1000 / clipDuration + ringBufferSize = 100 / clipDuration ringBufferElementSize = 100000 maxClipSize = 100000 httpTimeOut = 5 // s packetsPerFrame = 7 - h264BufferSize = 100000 + h264BufferSize = 1000000 bitrateTime = 60 mjpegParserInChanLen = 100000 ffmpegPath = "/home/saxon/bin/ffmpeg" @@ -311,15 +311,13 @@ func (r *revidInst) outputClips() { now := time.Now() prevTime := now bytes := 0 - delay := 0 + fps, _ := strconv.Atoi(r.config.FrameRate) + delay := int64(float64(1000) / float64(fps)) for r.isRunning { // Here we slow things down as much as we can to decrease cpu usage switch { case r.ringBuffer.GetNoOfElements() < 2: - delay++ time.Sleep(time.Duration(delay) * time.Millisecond) - case delay > 10: - delay -= 10 } // If the ringbuffer has something we can read and send off if clip, err := r.ringBuffer.Read(); err == nil { diff --git a/revid/revid_test.go b/revid/revid_test.go index 04d337be..e4ece8fa 100644 --- a/revid/revid_test.go +++ b/revid/revid_test.go @@ -170,6 +170,7 @@ func TestRtmpOutputUsingLibRtmp(t *testing.T){ */ + // Test revidInst with a Raspivid h264 input func TestRaspividToRtmp(t *testing.T){ config := Config{ @@ -187,7 +188,7 @@ func TestRaspividToRtmp(t *testing.T){ return } revidInst.Start() - time.Sleep(120*time.Second) + time.Sleep(240*time.Second) revidInst.Stop() }