diff --git a/revid/Config.go b/revid/Config.go index cdb09e5e..0b4d66e1 100644 --- a/revid/Config.go +++ b/revid/Config.go @@ -77,6 +77,8 @@ const ( Revid = 12 Flv = 13 LibRtmp = 14 + QuantizationOn = 15 + QuantizationOff = 16 ) // Default config settings @@ -88,11 +90,22 @@ const ( defaultTimeout = "0" defaultQuantization = "40" defaultBitrate = "0" + defaultQuantizationMode = QuantizationOff ) // checkConfig checks for any errors in the config files and defaults settings // if particular parameters have not been defined. func (config *Config) Validate(r *revidInst) error { + switch config.QuantizationMode { + case QuantizationOn: + case QuantizationOff: + case NothingDefined: + r.Log(Warning, "No quantization mode defined, defaulting to QuantizationOff!") + config.QuantizationMode = QuantizationOff + default: + return errors.New("Bad QuantizationMode define in config!") + } + switch config.Input { case Rtp: case Raspivid: diff --git a/revid/RevidInstance.go b/revid/RevidInstance.go index 215cf22a..c037037e 100644 --- a/revid/RevidInstance.go +++ b/revid/RevidInstance.go @@ -451,24 +451,39 @@ func (r *revidInst) setupOutputForFile() (err error) { // setupInputForRaspivid sets up things for input from raspivid i.e. starts // a raspivid process and pipes it's data output. func (r *revidInst) setupInputForRaspivid() error { - //fps,_ := strconv.Atoi(r.config.FrameRate) - //r.parser.SetDelay( uint( float64(1000) / float64(fps) ) ) r.Log(Info, "Starting raspivid!") switch r.config.InputCodec { case H264: - r.cmd = exec.Command("raspivid", - "-cd", "H264", - "-o", "-", - "-n", - "-t", r.config.Timeout, - "-b", "500000", - //"-qp", r.config.Quantization, - "-w", r.config.Width, - "-h", r.config.Height, - "-fps", r.config.FrameRate, - "-ih", - "-g", r.config.IntraRefreshPeriod, - ) + switch r.config.QuantizationMode { + case QuantizationOn: + r.cmd = exec.Command("raspivid", + "-cd", "H264", + "-o", "-", + "-n", + "-t", r.config.Timeout, + "-b", "0", + "-qp", r.config.Quantization, + "-w", r.config.Width, + "-h", r.config.Height, + "-fps", r.config.FrameRate, + "-ih", + "-g", r.config.IntraRefreshPeriod, + ) + case QuantizationOff: + r.cmd = exec.Command("raspivid", + "-cd", "H264", + "-o", "-", + "-n", + "-t", r.config.Timeout, + "-b", r.config.Bitrate, + "-w", r.config.Width, + "-h", r.config.Height, + "-fps", r.config.FrameRate, + "-ih", + "-g", r.config.IntraRefreshPeriod, + ) + } + case Mjpeg: r.cmd = exec.Command("raspivid", "-cd", "MJPEG",