2019-10-13 14:17:50 +03:00
|
|
|
/*
|
|
|
|
DESCRIPTION
|
|
|
|
See package description.
|
|
|
|
|
|
|
|
AUTHORS
|
|
|
|
Saxon A. Nelson-Milton <saxon@ausocean.org>
|
|
|
|
|
|
|
|
LICENSE
|
|
|
|
Copyright (C) 2019 the Australian Ocean Lab (AusOcean)
|
|
|
|
|
|
|
|
It is free software: you can redistribute it and/or modify them
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
|
|
|
*/
|
|
|
|
|
2020-04-23 06:43:37 +03:00
|
|
|
// Package config-cli is a command-line program for configuring the GeoVision camera.
|
2019-10-13 14:17:50 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"strconv"
|
|
|
|
|
2019-11-08 09:59:01 +03:00
|
|
|
"bitbucket.org/ausocean/av/device/geovision/config"
|
2019-10-13 14:17:50 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
var (
|
|
|
|
hostPtr = flag.String("host", "192.168.1.50", "IP of GeoVision camera.")
|
|
|
|
codecPtr = flag.String("codec", "", "h264, h265 or mjpeg")
|
|
|
|
heightPtr = flag.Int("height", 0, "256, 360 or 720")
|
|
|
|
fpsPtr = flag.Int("fps", 0, "Frame rate in frames per second.")
|
|
|
|
vbrPtr = flag.Bool("vbr", false, "If true, variable bitrate.")
|
|
|
|
vbrQualityPtr = flag.Int("quality", -1, "General quality under variable bitrate, 0 to 4 inclusive.")
|
|
|
|
vbrRatePtr = flag.Int("vbr-rate", 0, "Variable bitrate maximal bitrate in kbps.")
|
|
|
|
cbrRatePtr = flag.Int("cbr-rate", 0, "Constant bitrate, bitrate in kbps.")
|
|
|
|
refreshPtr = flag.Float64("refresh", 0, "Inter refresh period in seconds.")
|
|
|
|
)
|
|
|
|
flag.Parse()
|
|
|
|
|
2019-11-08 09:59:01 +03:00
|
|
|
var options []config.Option
|
2019-10-13 14:17:50 +03:00
|
|
|
|
|
|
|
if *codecPtr != "" {
|
2019-11-08 09:59:01 +03:00
|
|
|
var c config.Codec
|
2019-10-13 14:17:50 +03:00
|
|
|
switch *codecPtr {
|
|
|
|
case "h264":
|
2019-11-08 09:59:01 +03:00
|
|
|
c = config.CodecH264
|
2019-10-13 14:17:50 +03:00
|
|
|
case "h265":
|
2019-11-08 09:59:01 +03:00
|
|
|
c = config.CodecH265
|
2019-10-13 14:17:50 +03:00
|
|
|
case "mjpeg":
|
2019-11-08 09:59:01 +03:00
|
|
|
c = config.CodecMJPEG
|
2019-10-13 14:17:50 +03:00
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("invalid codec: %s", *codecPtr))
|
|
|
|
}
|
2019-11-08 09:59:01 +03:00
|
|
|
options = append(options, config.CodecOut(c))
|
2019-10-13 14:17:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if *heightPtr != 0 {
|
2019-11-08 09:59:01 +03:00
|
|
|
options = append(options, config.Height(*heightPtr))
|
2019-10-13 14:17:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if *fpsPtr != 0 {
|
2019-11-08 09:59:01 +03:00
|
|
|
options = append(options, config.FrameRate(*fpsPtr))
|
2019-10-13 14:17:50 +03:00
|
|
|
}
|
|
|
|
|
2019-11-08 09:59:01 +03:00
|
|
|
options = append(options, config.VariableBitrate(*vbrPtr))
|
2019-10-13 14:17:50 +03:00
|
|
|
|
|
|
|
if *vbrQualityPtr != -1 {
|
2019-11-08 09:59:01 +03:00
|
|
|
options = append(options, config.VBRQuality(config.Quality(strconv.Itoa(*vbrQualityPtr))))
|
2019-10-13 14:17:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if *vbrRatePtr != 0 {
|
2019-11-08 09:59:01 +03:00
|
|
|
options = append(options, config.VBRBitrate(*vbrRatePtr))
|
2019-10-13 14:17:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if *cbrRatePtr != 0 {
|
2019-11-08 09:59:01 +03:00
|
|
|
options = append(options, config.CBRBitrate(*cbrRatePtr))
|
2019-10-13 14:17:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if *refreshPtr != 0 {
|
2019-11-08 09:59:01 +03:00
|
|
|
options = append(options, config.Refresh(*refreshPtr))
|
2019-10-13 14:17:50 +03:00
|
|
|
}
|
|
|
|
|
2019-11-08 09:59:01 +03:00
|
|
|
err := config.Set(*hostPtr, options...)
|
2019-10-13 14:17:50 +03:00
|
|
|
if err != nil {
|
2019-11-08 09:59:01 +03:00
|
|
|
panic(fmt.Sprintf("error from config.Set: %v", err))
|
2019-10-13 14:17:50 +03:00
|
|
|
}
|
|
|
|
}
|