From c20ed48c4092c9a3ba251db435cef1dfcd4e114d Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Wed, 3 Oct 2018 22:09:51 +0930 Subject: [PATCH] revid: move command creation and logging out of switch --- revid/revid.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/revid/revid.go b/revid/revid.go index 309bc8fe..41571af5 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -31,6 +31,7 @@ package revid import ( "errors" + "fmt" "io" "os" "os/exec" @@ -413,9 +414,14 @@ func (r *Revid) outputClips() { // a raspivid process and pipes it's data output. func (r *Revid) startRaspivid() error { r.config.Logger.Log(smartlogger.Info, pkg+"starting raspivid") + + var args []string switch r.config.InputCodec { + default: + return fmt.Errorf("revid: invalid input codec: %v", r.config.InputCodec) + case H264: - args := []string{ + args = []string{ "-cd", "H264", "-o", "-", "-n", @@ -427,7 +433,6 @@ func (r *Revid) startRaspivid() error { "-ih", "-g", r.config.IntraRefreshPeriod, } - if r.config.QuantizationMode == QuantizationOn { args = append(args, "-qp", r.config.Quantization) } @@ -437,19 +442,19 @@ func (r *Revid) startRaspivid() error { if r.config.VerticalFlip == Yes { args = append(args, "-vf") } - r.config.Logger.Log(smartlogger.Info, pkg+"raspivid args", "raspividArgs", strings.Join(args, " ")) - r.cmd = exec.Command("raspivid", args...) case Mjpeg: - // FIXME(saxon): do above in this case too - r.cmd = exec.Command("raspivid", + args = []string{ "-cd", "MJPEG", "-o", "-", "-n", "-t", runContinuously, "-fps", r.config.FrameRate, - ) + } } + r.config.Logger.Log(smartlogger.Info, pkg+"raspivid args", "raspividArgs", strings.Join(args, " ")) + r.cmd = exec.Command("raspivid", args...) + d, err := strconv.Atoi(r.config.FrameRate) if err != nil { return err