revid: not reading from camera correctly

Issue #8 resolved
Saxon Milton created an issue

when r.lexTo is called on line revid.go:474 it seems to return pretty much straight away with no error. There doesn't seem to be any errors before this point either - with execution of raspivid or piping.

Comments (6)

  1. Saxon Milton reporter

    I might be wrong with the errors. Just realised that we aren't capturing errors from startRaspivid(), so I'm going to do that now.

  2. kortschak

    The issue is that the args are being passed to exec (via exec.Command) as a single concatenated string. Don't do that; exec'ing something from Go does not spawn a shell to parse out arguments, so what you are passing is essentially raspivid '-cd H264 -o - -n -t 0 -b 500000 -w 1280 -h 720 -fps 25 -ih -g 100'.

    The diff for a fix will be

    diff --git a/revid/revid.go b/revid/revid.go
    index 72af0aa..151511b 100644
    --- a/revid/revid.go
    +++ b/revid/revid.go
    @@ -448,7 +448,7 @@ func (r *Revid) startRaspivid() error {
                    // Log all the args and create []string
                    argsStr := strings.Join(args, " ")
                    r.config.Logger.Log(smartlogger.Info, pkg+"raspivid args", "raspividArgs", argsStr)
    -               r.cmd = exec.Command("raspivid", argsStr)
    +               r.cmd = exec.Command("raspivid", args)
    
            case Mjpeg:
    

    if you want to send a PR (I don't have time to test this this weekend).

  3. Saxon Milton reporter

    My bad! Sorry for blaming it on your Lexing stuff. I'll probably squeeze this fix into the same PR as the http fix. I'll test tomorrow hopefully.

    I kno see that when you said use join for the arguments you only meant for the purpose of logging.

  4. kortschak

    Please don't put this in the http PR. Including tangentially related changes is the reason this got missed in review.

  5. Log in to comment