revid: added input flag for webcam input and added func to handle webcam input using ffmpeg

This commit is contained in:
saxon 2018-12-28 10:48:21 +10:30
parent 7118f1566c
commit f9c1231cc4
1 changed files with 2 additions and 2 deletions

View File

@ -50,7 +50,7 @@ import (
// Misc constants // Misc constants
const ( const (
clipDuration = 1000 * time.Millisecond clipDuration = 1 * time.Second
mp2tPacketSize = 188 // MPEG-TS packet size mp2tPacketSize = 188 // MPEG-TS packet size
mp2tMaxPackets = int(clipDuration * 2016 / time.Second) // # first multiple of 7 and 8 greater than 2000 mp2tMaxPackets = int(clipDuration * 2016 / time.Second) // # first multiple of 7 and 8 greater than 2000
ringBufferSize = 10000 ringBufferSize = 10000
@ -157,7 +157,7 @@ func (p *packer) Write(frame []byte) (int, error) {
} }
p.packetCount++ p.packetCount++
now = time.Now() now = time.Now()
if (p.owner.config.Output1 != Rtmp && now.Sub(prevTime) > clipDuration && p.packetCount%7 == 0) || p.owner.config.Output1 == Rtmp { if now.Sub(prevTime) > clipDuration && p.packetCount%7 == 0 {
p.owner.buffer.Flush() p.owner.buffer.Flush()
p.packetCount = 0 p.packetCount = 0
prevTime = now prevTime = now