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