mirror of https://bitbucket.org/ausocean/av.git
revid: fixed raspivid args and logging
This commit is contained in:
parent
c4d0f2ccbc
commit
d17f7c87e9
|
@ -36,6 +36,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"bitbucket.org/ausocean/av/rtmp"
|
||||
|
@ -421,39 +422,32 @@ func (r *Revid) startRaspivid() error {
|
|||
r.config.Logger.Log(smartlogger.Info, "Starting raspivid!")
|
||||
switch r.config.InputCodec {
|
||||
case H264:
|
||||
// FIXME(saxon): consider using a map right from the start to store
|
||||
// the raspivid args
|
||||
raspiArgs := make(map[string]string)
|
||||
raspiArgs["-cd"] = "H264"
|
||||
raspiArgs["-o"] = "-"
|
||||
raspiArgs["-n"] = ""
|
||||
raspiArgs["-t"] = runContinuously
|
||||
raspiArgs["-b"] = r.config.Bitrate
|
||||
raspiArgs["-w"] = r.config.Width
|
||||
raspiArgs["-h"] = r.config.Height
|
||||
raspiArgs["-fps"] = r.config.FrameRate
|
||||
raspiArgs["-ih"] = ""
|
||||
raspiArgs["-g"] = r.config.IntraRefreshPeriod
|
||||
args := []string{
|
||||
"-cd", "H264",
|
||||
"-o", "-",
|
||||
"-n",
|
||||
"-t", runContinuously,
|
||||
"-b", r.config.Bitrate,
|
||||
"-w", r.config.Width,
|
||||
"-h", r.config.Height,
|
||||
"-fps", r.config.FrameRate,
|
||||
"-ih",
|
||||
"-g", r.config.IntraRefreshPeriod,
|
||||
}
|
||||
|
||||
if r.config.QuantizationMode == QuantizationOn {
|
||||
raspiArgs["-qp"] = r.config.Quantization
|
||||
args = append(args, "-qp", r.config.Quantization)
|
||||
}
|
||||
if r.config.HorizontalFlip == Yes {
|
||||
raspiArgs["-hf"] = strconv.Itoa(int(r.config.HorizontalFlip))
|
||||
args = append(args, "-hf")
|
||||
}
|
||||
if r.config.VerticalFlip == Yes {
|
||||
raspiArgs["-vf"] = strconv.Itoa(int(r.config.VerticalFlip))
|
||||
args = append(args, "-vf")
|
||||
}
|
||||
// Log all the args and create []string
|
||||
args := make([]string, 0)
|
||||
for i := range raspiArgs {
|
||||
r.config.Logger.Log(smartlogger.Info, "Raspivid arg", i, raspiArgs[i])
|
||||
// First append the flag
|
||||
args = append(args, i)
|
||||
// and now append any values for the flag
|
||||
args = append(args, raspiArgs[i])
|
||||
}
|
||||
r.cmd = exec.Command("raspivid", args...)
|
||||
argsStr := strings.Join(args, " ")
|
||||
r.config.Logger.Log(smartlogger.Info, "Raspivid args", "raspividArgs", argsStr)
|
||||
r.cmd = exec.Command("raspivid", argsStr)
|
||||
|
||||
case Mjpeg:
|
||||
// FIXME(saxon): do above in this case too
|
||||
|
|
Loading…
Reference in New Issue