implementing rotate

This commit is contained in:
Saxon Milton 2018-05-01 06:07:37 +09:30
parent 6803554434
commit 9b4681e29f
3 changed files with 16 additions and 1 deletions

View File

@ -63,13 +63,14 @@ const (
quantizationPtr = 16
timeoutPtr = 17
intraRefreshPeriodPtr = 18
rotatePtr = 19
)
// Other misc consts
const (
sleepTime = 2 * 43200
defaultRunDuration = 2 * 43200
noOfConfigconfigFlags = 19
noOfConfigconfigFlags = 20
revidStopTime = 5
prepTime = 20
loggerVerbosity = 3
@ -118,6 +119,7 @@ func main() {
{"Quantization", "Desired quantization value"},
{"Timeout", "Http timeout in seconds"},
{"IntraRefreshPeriod", "The IntraRefreshPeriod i.e. how many keyframes we send"},
{"Rotate", "Rotate video the specified number of degrees"},
}
// Create the configFlags based on the flagNames array
@ -221,6 +223,7 @@ func main() {
config.Quantization = *configFlags[quantizationPtr]
config.Timeout = *configFlags[timeoutPtr]
config.IntraRefreshPeriod = *configFlags[intraRefreshPeriodPtr]
config.Rotate = *configFlags[rotatePtr]
// Also give the config a logger object
config.Logger = smartLogger.New(loggerVerbosity, smartLogger.White)

View File

@ -98,6 +98,7 @@ const (
defaultBitrate = "500000"
defaultQuantizationMode = QuantizationOff
defaultFramesPerClip = "1"
defaultRotate = "0"
)
// Validate checks for any errors in the config fields and defaults settings
@ -273,5 +274,14 @@ 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

@ -543,6 +543,7 @@ func (r *revid) setupInputForRaspivid() error {
"-fps", r.config.FrameRate,
"-ih",
"-g", r.config.IntraRefreshPeriod,
"-ro", r.config.Rotate,
)
case QuantizationOff:
r.cmd = exec.Command("raspivid",
@ -556,6 +557,7 @@ func (r *revid) setupInputForRaspivid() error {
"-fps", r.config.FrameRate,
"-ih",
"-g", r.config.IntraRefreshPeriod,
"-ro", r.config.Rotate,
)
}