Updated config options

This commit is contained in:
Saxon1 2018-05-03 17:57:36 +09:30
parent 567d52aacc
commit 12cefea60a
2 changed files with 72 additions and 38 deletions

View File

@ -46,6 +46,7 @@ type Config struct {
Packetization uint8
QuantizationMode uint8
Verbosity uint8
Flip uint8
FramesPerClip string
RtmpUrl string
Bitrate string
@ -58,7 +59,6 @@ type Config struct {
Quantization string
Timeout string
IntraRefreshPeriod string
Rotate string
Logger smartLogger.LogInstance
}
@ -100,7 +100,7 @@ const (
defaultBitrate = "500000"
defaultQuantizationMode = QuantizationOff
defaultFramesPerClip = "1"
defaultRotate = "0"
defaultFlip = No
)
// Validate checks for any errors in the config fields and defaults settings
@ -205,6 +205,16 @@ func (config *Config) Validate(r *revid) error {
return errors.New("Bad packetization option defined in config!")
}
switch config.Flip {
case Yes:
case No:
case NothingDefined:
r.Log(Warning, "No flip option defined defaulting to not flipped!")
config.Flip = defaultFlip
default:
return errors.New("Bad flip option defined in config!")
}
if config.FramesPerClip == "" {
r.Log(Warning, "No FramesPerClip defined defined, defaulting to 1!")
config.Width = defaultFramesPerClip
@ -276,14 +286,5 @@ func (config *Config) Validate(r *revid) error {
return errors.New("Bad quantization defined in config!")
}
}
if config.Rotate == "" {
r.Log(Warning, fmt.Sprintf("No rotate defined defaulting to: %v", defaultRotate) )
r.config.Rotate = defaultRotate
} else {
if integer, err := strconv.Atoi(config.Rotate); integer < 0 || integer > 270 || err != nil {
return errors.New("Bad rotate defined in config!")
}
}
return nil
}

View File

@ -537,34 +537,67 @@ func (r *revid) setupInputForRaspivid() error {
case H264:
switch r.config.QuantizationMode {
case QuantizationOn:
r.cmd = exec.Command("raspivid",
"-cd", "H264",
"-o", "-",
"-n",
"-t", r.config.Timeout,
"-b", "0",
"-qp", r.config.Quantization,
"-w", r.config.Width,
"-h", r.config.Height,
"-fps", r.config.FrameRate,
"-ih",
"-g", r.config.IntraRefreshPeriod,
// "-ro", r.config.Rotate,
)
if config.Flip == config.No {
r.cmd = exec.Command("raspivid",
"-cd", "H264",
"-o", "-",
"-n",
"-t", r.config.Timeout,
"-b", "0",
"-qp", r.config.Quantization,
"-w", r.config.Width,
"-h", r.config.Height,
"-fps", r.config.FrameRate,
"-ih",
"-g", r.config.IntraRefreshPeriod,
// "-ro", r.config.Rotate,
)
} else {
r.cmd = exec.Command("raspivid",
"-cd", "H264",
"-o", "-",
"-n",
"-t", r.config.Timeout,
"-b", "0",
"-qp", r.config.Quantization,
"-w", r.config.Width,
"-h", r.config.Height,
"-fps", r.config.FrameRate,
"-ih",
"-g", r.config.IntraRefreshPeriod,
"-hf",
)
}
case QuantizationOff:
r.cmd = exec.Command("raspivid",
"-cd", "H264",
"-o", "-",
"-n",
"-t", r.config.Timeout,
"-b", r.config.Bitrate,
"-w", r.config.Width,
"-h", r.config.Height,
"-fps", r.config.FrameRate,
"-ih",
"-g", r.config.IntraRefreshPeriod,
// "-ro", r.config.Rotate,
)
if config.Flip == config.No {
r.cmd = exec.Command("raspivid",
"-cd", "H264",
"-o", "-",
"-n",
"-t", r.config.Timeout,
"-b", r.config.Bitrate,
"-w", r.config.Width,
"-h", r.config.Height,
"-fps", r.config.FrameRate,
"-ih",
"-g", r.config.IntraRefreshPeriod,
)
} else {
r.cmd = exec.Command("raspivid",
"-cd", "H264",
"-o", "-",
"-n",
"-t", r.config.Timeout,
"-b", r.config.Bitrate,
"-w", r.config.Width,
"-h", r.config.Height,
"-fps", r.config.FrameRate,
"-ih",
"-g", r.config.IntraRefreshPeriod,
"-hf",
)
}
}
case Mjpeg: