mirror of https://bitbucket.org/ausocean/av.git
97 lines
2.6 KiB
Go
97 lines
2.6 KiB
Go
/*
|
|
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.
|
|
*/
|
|
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"bitbucket.org/ausocean/av/input/gvctrl"
|
|
)
|
|
|
|
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()
|
|
|
|
var options []gvctrl.Option
|
|
|
|
if *codecPtr != "" {
|
|
var c gvctrl.Codec
|
|
switch *codecPtr {
|
|
case "h264":
|
|
c = gvctrl.CodecH264
|
|
case "h265":
|
|
c = gvctrl.CodecH265
|
|
case "mjpeg":
|
|
c = gvctrl.CodecMJPEG
|
|
default:
|
|
panic(fmt.Sprintf("invalid codec: %s", *codecPtr))
|
|
}
|
|
options = append(options, gvctrl.CodecOut(c))
|
|
}
|
|
|
|
if *heightPtr != 0 {
|
|
options = append(options, gvctrl.Height(*heightPtr))
|
|
}
|
|
|
|
if *fpsPtr != 0 {
|
|
options = append(options, gvctrl.FrameRate(*fpsPtr))
|
|
}
|
|
|
|
options = append(options, gvctrl.VariableBitrate(*vbrPtr))
|
|
|
|
if *vbrQualityPtr != -1 {
|
|
options = append(options, gvctrl.VBRQuality(gvctrl.Quality(strconv.Itoa(*vbrQualityPtr))))
|
|
}
|
|
|
|
if *vbrRatePtr != 0 {
|
|
options = append(options, gvctrl.VBRBitrate(*vbrRatePtr))
|
|
}
|
|
|
|
if *cbrRatePtr != 0 {
|
|
options = append(options, gvctrl.CBRBitrate(*cbrRatePtr))
|
|
}
|
|
|
|
if *refreshPtr != 0 {
|
|
options = append(options, gvctrl.Refresh(*refreshPtr))
|
|
}
|
|
|
|
err := gvctrl.Set(*hostPtr, options...)
|
|
if err != nil {
|
|
panic(fmt.Sprintf("error from gvctrl.Set: %v", err))
|
|
}
|
|
}
|