revid: self-document and harmonize arguments to raspivid

This commit is contained in:
Dan Kortschak 2018-10-05 07:56:26 +09:30
parent c20ed48c40
commit 81997cd68e
1 changed files with 22 additions and 29 deletions

View File

@ -71,7 +71,6 @@ const (
rtmpConnectionMaxTries = 5
raspividNoOfTries = 3
sendingWaitTime = 5 * time.Millisecond
runContinuously = "0" // -t arg to raspivid
pkg = "revid:"
)
@ -415,42 +414,36 @@ func (r *Revid) outputClips() {
func (r *Revid) startRaspivid() error {
r.config.Logger.Log(smartlogger.Info, pkg+"starting raspivid")
var args []string
const disabled = "0"
args := []string{
"--output", "-",
"--nopreview",
"--timeout", disabled,
"--width", r.config.Width,
"--height", r.config.Height,
"--bitrate", r.config.Bitrate,
"--framerate", r.config.FrameRate,
}
if r.config.HorizontalFlip == Yes {
args = append(args, "--hflip")
}
if r.config.VerticalFlip == Yes {
args = append(args, "--vflip")
}
switch r.config.InputCodec {
default:
return fmt.Errorf("revid: invalid input codec: %v", r.config.InputCodec)
case H264:
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,
}
args = append(args,
"--codec", "H264",
"--inline",
"--intra", r.config.IntraRefreshPeriod,
)
if r.config.QuantizationMode == QuantizationOn {
args = append(args, "-qp", r.config.Quantization)
}
if r.config.HorizontalFlip == Yes {
args = append(args, "-hf")
}
if r.config.VerticalFlip == Yes {
args = append(args, "-vf")
}
case Mjpeg:
args = []string{
"-cd", "MJPEG",
"-o", "-",
"-n",
"-t", runContinuously,
"-fps", r.config.FrameRate,
}
args = append(args, "--codec", "MJPEG")
}
r.config.Logger.Log(smartlogger.Info, pkg+"raspivid args", "raspividArgs", strings.Join(args, " "))
r.cmd = exec.Command("raspivid", args...)