2018-04-19 10:03:12 +03:00
|
|
|
/*
|
|
|
|
NAME
|
|
|
|
RevidCLI.go
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
See Readme.md
|
|
|
|
|
|
|
|
AUTHORS
|
|
|
|
Saxon A. Nelson-Milton <saxon@ausocean.org>
|
|
|
|
Jack Richardson <jack@ausocean.org>
|
|
|
|
|
|
|
|
LICENSE
|
2018-06-01 14:20:56 +03:00
|
|
|
RevidCLI.go is Copyright (C) 2017-2018 the Australian Ocean Lab (AusOcean)
|
2018-04-19 10:03:12 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
along with revid in gpl.txt. If not, see [GNU licenses](http://www.gnu.org/licenses).
|
|
|
|
*/
|
2018-04-15 13:42:06 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
2018-05-06 11:38:45 +03:00
|
|
|
"fmt"
|
2018-06-09 03:46:04 +03:00
|
|
|
"os"
|
2018-04-19 09:42:07 +03:00
|
|
|
"strconv"
|
2018-04-19 11:19:36 +03:00
|
|
|
"time"
|
2018-04-19 08:58:16 +03:00
|
|
|
|
2018-04-19 11:19:36 +03:00
|
|
|
"bitbucket.org/ausocean/av/revid"
|
2018-05-03 06:51:28 +03:00
|
|
|
"bitbucket.org/ausocean/iot/pi/netsender"
|
2018-05-24 06:35:29 +03:00
|
|
|
"bitbucket.org/ausocean/utils/smartlogger"
|
2018-04-15 13:42:06 +03:00
|
|
|
)
|
|
|
|
|
2018-06-08 15:44:23 +03:00
|
|
|
const (
|
|
|
|
// progName is the program name for logging purposes.
|
|
|
|
progName = "revid-cli"
|
|
|
|
|
|
|
|
// Logging is set to INFO level.
|
|
|
|
loggerVerbosity = 3
|
|
|
|
)
|
|
|
|
|
2018-04-19 11:11:18 +03:00
|
|
|
// Indexes for configFlags
|
2018-04-15 13:42:06 +03:00
|
|
|
const (
|
2018-06-07 14:50:57 +03:00
|
|
|
inputPtr = iota
|
|
|
|
inputCodecPtr
|
|
|
|
outputPtr
|
|
|
|
rtmpMethodPtr
|
|
|
|
packetizationPtr
|
|
|
|
quantizationModePtr
|
|
|
|
verbosityPtr
|
|
|
|
framesPerClipPtr
|
|
|
|
rtmpUrlPtr
|
|
|
|
bitratePtr
|
|
|
|
outputFileNamePtr
|
|
|
|
inputFileNamePtr
|
|
|
|
heightPtr
|
|
|
|
widthPtr
|
|
|
|
frameRatePtr
|
|
|
|
httpAddressPtr
|
|
|
|
quantizationPtr
|
|
|
|
timeoutPtr
|
|
|
|
intraRefreshPeriodPtr
|
|
|
|
verticalFlipPtr
|
|
|
|
horizontalFlipPtr
|
|
|
|
|
|
|
|
noOfConfigFlags
|
2018-04-15 13:42:06 +03:00
|
|
|
)
|
|
|
|
|
2018-04-19 09:42:07 +03:00
|
|
|
// Other misc consts
|
|
|
|
const (
|
2018-06-08 15:22:11 +03:00
|
|
|
netSendRetryTime = 5 * time.Second
|
|
|
|
defaultRunDuration = 24 * time.Hour
|
|
|
|
revidStopTime = 5 * time.Second
|
|
|
|
prepTime = 20 * time.Second
|
2018-04-19 09:42:07 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// Globals
|
|
|
|
var (
|
2018-06-09 05:01:21 +03:00
|
|
|
revidInst *revid.Revid
|
2018-05-07 02:56:22 +03:00
|
|
|
config revid.Config
|
2018-04-19 08:58:16 +03:00
|
|
|
)
|
|
|
|
|
2018-04-15 13:42:06 +03:00
|
|
|
func main() {
|
2018-06-07 14:50:57 +03:00
|
|
|
flagNames := [noOfConfigFlags]struct{ name, description string }{
|
2018-05-06 11:38:45 +03:00
|
|
|
{"Input", "The input type"},
|
|
|
|
{"InputCodec", "The codec of the input"},
|
|
|
|
{"Output", "The output type"},
|
|
|
|
{"RtmpMethod", "The method used to send over rtmp (ffmpeg or librtmp)"},
|
|
|
|
{"Packetization", "The method of data packetisation"},
|
|
|
|
{"QuantizationMode", "The level of quantization"},
|
|
|
|
{"Verbosity", "Verbosity on or off"},
|
|
|
|
{"FramesPerClip", "Number of frames per clip sent"},
|
|
|
|
{"RtmpUrl", "Url of rtmp endpoint"},
|
|
|
|
{"Bitrate", "Bitrate of recorded video"},
|
|
|
|
{"OutputFileName", "The directory of the output file"},
|
|
|
|
{"InputFileName", "The directory of the input file"},
|
|
|
|
{"Height", "Height in pixels"},
|
|
|
|
{"Width", "Width in pixels"},
|
|
|
|
{"FrameRate", "Frame rate of captured video"},
|
|
|
|
{"HttpAddress", "Destination address of http posts"},
|
|
|
|
{"Quantization", "Desired quantization value"},
|
|
|
|
{"Timeout", "Http timeout in seconds"},
|
|
|
|
{"IntraRefreshPeriod", "The IntraRefreshPeriod i.e. how many keyframes we send"},
|
|
|
|
{"VerticalFlip", "Flip video vertically"},
|
2018-05-05 06:47:07 +03:00
|
|
|
{"HorizontalFlip", "Flip video horizontally"},
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:11:18 +03:00
|
|
|
// Create the configFlags based on the flagNames array
|
2018-05-06 11:38:45 +03:00
|
|
|
configFlags := make([](*string), noOfConfigFlags)
|
2018-06-07 14:50:57 +03:00
|
|
|
for i, f := range &flagNames {
|
|
|
|
configFlags[i] = flag.String(f.name, "", f.description)
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 10:03:12 +03:00
|
|
|
// Do we want a netsender session
|
2018-06-09 03:46:04 +03:00
|
|
|
useNetsender := flag.Bool("NetSender", false, "Are we checking vars through netsender?")
|
2018-04-19 10:03:12 +03:00
|
|
|
// User might also want to define how long revid runs for
|
2018-06-08 15:22:11 +03:00
|
|
|
runDurationPtr := flag.Duration("runDuration", defaultRunDuration, "How long do you want revid to run for?")
|
2018-04-19 09:42:07 +03:00
|
|
|
|
2018-04-15 13:42:06 +03:00
|
|
|
flag.Parse()
|
|
|
|
|
2018-04-19 11:14:38 +03:00
|
|
|
switch *configFlags[inputPtr] {
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Raspivid":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Input = revid.Raspivid
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Rtp":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Input = revid.Rtp
|
2018-04-15 13:42:06 +03:00
|
|
|
case "File":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Input = revid.File
|
2018-04-19 12:37:25 +03:00
|
|
|
case "":
|
|
|
|
default:
|
|
|
|
fmt.Println("Bad input argument!")
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:14:38 +03:00
|
|
|
switch *configFlags[inputCodecPtr] {
|
2018-04-15 13:42:06 +03:00
|
|
|
case "H264Codec":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.InputCodec = revid.H264Codec
|
2018-04-19 12:37:25 +03:00
|
|
|
case "":
|
|
|
|
default:
|
|
|
|
fmt.Println("Bad input codec argument!")
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:14:38 +03:00
|
|
|
switch *configFlags[outputPtr] {
|
2018-04-15 13:42:06 +03:00
|
|
|
case "File":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Output = revid.File
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Http":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Output = revid.Http
|
2018-04-19 12:39:48 +03:00
|
|
|
case "NativeRtmp":
|
|
|
|
config.Output = revid.NativeRtmp
|
|
|
|
case "FfmpegRtmp":
|
|
|
|
config.Output = revid.FfmpegRtmp
|
2018-04-19 12:37:25 +03:00
|
|
|
case "":
|
|
|
|
default:
|
|
|
|
fmt.Println("Bad output argument!")
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:14:38 +03:00
|
|
|
switch *configFlags[rtmpMethodPtr] {
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Ffmpeg":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.RtmpMethod = revid.Ffmpeg
|
2018-04-15 13:42:06 +03:00
|
|
|
case "LibRtmp":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.RtmpMethod = revid.LibRtmp
|
2018-04-19 12:37:25 +03:00
|
|
|
case "":
|
|
|
|
default:
|
|
|
|
fmt.Println("Bad rtmp method argument!")
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:24:44 +03:00
|
|
|
switch *configFlags[packetizationPtr] {
|
2018-04-15 13:42:06 +03:00
|
|
|
case "None":
|
2018-04-19 11:19:36 +03:00
|
|
|
config.Packetization = revid.None
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Rtp":
|
2018-04-19 11:19:36 +03:00
|
|
|
config.Packetization = revid.Rtp
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Flv":
|
2018-04-19 11:19:36 +03:00
|
|
|
config.Packetization = revid.Flv
|
2018-04-19 12:37:25 +03:00
|
|
|
case "":
|
|
|
|
default:
|
|
|
|
fmt.Println("Bad packetization argument!")
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:19:36 +03:00
|
|
|
switch *configFlags[quantizationModePtr] {
|
2018-04-15 13:42:06 +03:00
|
|
|
case "QuantizationOn":
|
2018-04-19 11:24:44 +03:00
|
|
|
config.QuantizationMode = revid.QuantizationOn
|
2018-04-15 13:42:06 +03:00
|
|
|
case "QuantizationOff":
|
2018-04-19 11:24:44 +03:00
|
|
|
config.QuantizationMode = revid.QuantizationOff
|
2018-04-19 12:37:25 +03:00
|
|
|
case "":
|
|
|
|
default:
|
|
|
|
fmt.Println("Bad quantization mode argument!")
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:14:38 +03:00
|
|
|
switch *configFlags[verbosityPtr] {
|
2018-04-15 13:42:06 +03:00
|
|
|
case "No":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Verbosity = revid.No
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Yes":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Verbosity = revid.Yes
|
2018-04-19 12:37:25 +03:00
|
|
|
case "":
|
|
|
|
default:
|
|
|
|
fmt.Println("Bad verbosity argument!")
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-05-03 15:36:17 +03:00
|
|
|
switch *configFlags[horizontalFlipPtr] {
|
2018-05-03 11:32:36 +03:00
|
|
|
case "No":
|
2018-05-05 06:45:45 +03:00
|
|
|
config.HorizontalFlip = revid.No
|
2018-05-03 11:32:36 +03:00
|
|
|
case "Yes":
|
2018-05-05 06:45:45 +03:00
|
|
|
config.HorizontalFlip = revid.Yes
|
2018-05-03 11:32:36 +03:00
|
|
|
case "":
|
2018-05-06 10:18:17 +03:00
|
|
|
config.HorizontalFlip = revid.No
|
2018-05-03 11:32:36 +03:00
|
|
|
default:
|
2018-05-03 15:36:17 +03:00
|
|
|
fmt.Println("Bad horizontal flip option!")
|
|
|
|
}
|
|
|
|
|
|
|
|
switch *configFlags[verticalFlipPtr] {
|
|
|
|
case "No":
|
2018-05-05 06:45:45 +03:00
|
|
|
config.VerticalFlip = revid.No
|
2018-05-03 15:36:17 +03:00
|
|
|
case "Yes":
|
|
|
|
config.VerticalFlip = revid.Yes
|
|
|
|
case "":
|
2018-05-06 10:18:17 +03:00
|
|
|
config.VerticalFlip = revid.No
|
2018-05-03 15:36:17 +03:00
|
|
|
default:
|
|
|
|
fmt.Println("Bad vertical flip option!")
|
2018-05-03 11:32:36 +03:00
|
|
|
}
|
|
|
|
|
2018-05-06 11:38:45 +03:00
|
|
|
config.FramesPerClip = *configFlags[framesPerClipPtr]
|
|
|
|
config.RtmpUrl = *configFlags[rtmpUrlPtr]
|
|
|
|
config.Bitrate = *configFlags[bitratePtr]
|
|
|
|
config.OutputFileName = *configFlags[outputFileNamePtr]
|
|
|
|
config.InputFileName = *configFlags[inputFileNamePtr]
|
|
|
|
config.Height = *configFlags[heightPtr]
|
|
|
|
config.Width = *configFlags[widthPtr]
|
|
|
|
config.FrameRate = *configFlags[frameRatePtr]
|
|
|
|
config.HttpAddress = *configFlags[httpAddressPtr]
|
|
|
|
config.Quantization = *configFlags[quantizationPtr]
|
|
|
|
config.Timeout = *configFlags[timeoutPtr]
|
|
|
|
config.IntraRefreshPeriod = *configFlags[intraRefreshPeriodPtr]
|
2018-04-19 09:42:07 +03:00
|
|
|
|
2018-06-14 10:07:57 +03:00
|
|
|
var ns netsender.Sender
|
2018-06-01 14:20:56 +03:00
|
|
|
var vs int
|
2018-06-09 03:46:04 +03:00
|
|
|
if *useNetsender {
|
2018-06-01 14:20:56 +03:00
|
|
|
// initialize NetSender and use NetSender's logger
|
|
|
|
config.Logger = netsender.GetLogger()
|
2018-06-08 15:22:11 +03:00
|
|
|
|
2018-06-09 03:46:04 +03:00
|
|
|
var err error
|
2018-06-14 10:07:57 +03:00
|
|
|
err = ns.Init(nil, nil, nil)
|
2018-06-09 03:46:04 +03:00
|
|
|
if err != nil {
|
|
|
|
l := smartlogger.New(loggerVerbosity, smartlogger.File, "/var/log/netsender/")
|
|
|
|
l.Log(progName, "Error", err.Error()) // TODO(kortschak): Make this "Fatal" when that exists.
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2018-05-30 06:15:37 +03:00
|
|
|
} else {
|
2018-06-01 14:20:56 +03:00
|
|
|
// alternatively, instantiate our own logger
|
2018-05-30 06:15:37 +03:00
|
|
|
config.Logger = smartlogger.New(loggerVerbosity, smartlogger.File, "/var/log/netsender/")
|
2018-04-20 05:20:33 +03:00
|
|
|
}
|
2018-04-20 09:53:51 +03:00
|
|
|
|
2018-06-08 15:22:11 +03:00
|
|
|
time.Sleep(prepTime)
|
2018-05-07 04:16:44 +03:00
|
|
|
startRevid()
|
|
|
|
paused := false
|
2018-04-19 08:58:16 +03:00
|
|
|
|
2018-06-01 14:20:56 +03:00
|
|
|
// loop in NetSender mode
|
2018-06-09 03:46:04 +03:00
|
|
|
for *useNetsender {
|
2018-06-15 10:59:59 +03:00
|
|
|
if err := sendTo(&ns); err != nil {
|
|
|
|
config.Logger.Log(progName, "Warning", err.Error())
|
2018-06-08 15:22:11 +03:00
|
|
|
time.Sleep(netSendRetryTime)
|
2018-05-07 04:16:44 +03:00
|
|
|
continue
|
|
|
|
}
|
2018-06-01 14:20:56 +03:00
|
|
|
|
|
|
|
if vs != ns.GetVarSum() {
|
2018-06-07 14:50:57 +03:00
|
|
|
// vars changed
|
2018-06-14 10:07:57 +03:00
|
|
|
vars, err := ns.Vars()
|
2018-06-01 14:20:56 +03:00
|
|
|
if err != nil {
|
2018-06-15 10:59:59 +03:00
|
|
|
config.Logger.Log(progName, "Warning", err.Error())
|
2018-06-08 15:22:11 +03:00
|
|
|
time.Sleep(netSendRetryTime)
|
2018-06-01 14:20:56 +03:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
vs = ns.GetVarSum()
|
2018-05-07 04:16:44 +03:00
|
|
|
if vars["mode"] == "Paused" {
|
|
|
|
if !paused {
|
2018-06-01 14:20:56 +03:00
|
|
|
config.Logger.Log(progName, "Info", "Pausing revid")
|
2018-05-07 04:16:44 +03:00
|
|
|
stopRevid()
|
|
|
|
paused = true
|
|
|
|
}
|
|
|
|
} else {
|
2018-06-01 14:20:56 +03:00
|
|
|
updateRevid(vars, !paused)
|
2018-05-07 04:16:44 +03:00
|
|
|
if paused {
|
|
|
|
paused = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-08 01:02:08 +03:00
|
|
|
sleepTime, _ := strconv.Atoi(ns.GetConfigParam("mp"))
|
2018-04-19 08:58:16 +03:00
|
|
|
time.Sleep(time.Duration(sleepTime) * time.Second)
|
|
|
|
}
|
2018-04-19 09:42:07 +03:00
|
|
|
|
2018-04-19 10:03:12 +03:00
|
|
|
// If we're not running a netsender session then we run revid for the amount
|
|
|
|
// of time the user defined or the default 2 days
|
2018-06-08 15:22:11 +03:00
|
|
|
time.Sleep(*runDurationPtr)
|
2018-05-07 04:16:44 +03:00
|
|
|
stopRevid()
|
2018-04-19 08:58:16 +03:00
|
|
|
}
|
|
|
|
|
2018-06-15 10:59:59 +03:00
|
|
|
// sendTo implements our main NetSender client and handles NetReceiver configuration
|
|
|
|
// (as distinct from httpSender which just sends video data).
|
|
|
|
func sendTo(ns *netsender.Sender) error {
|
2018-06-14 10:07:57 +03:00
|
|
|
// populate input values, if any
|
2018-06-15 13:04:50 +03:00
|
|
|
inputs := netsender.MakePins(ns.GetConfigParam("ip"), "X")
|
2018-06-14 10:07:57 +03:00
|
|
|
for i, pin := range inputs {
|
|
|
|
if pin.Name == "X23" {
|
|
|
|
inputs[i].Value = int(revidInst.GetBitrate())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-12 07:00:30 +03:00
|
|
|
_, reconfig, err := ns.Send(netsender.RequestPoll, inputs, nil)
|
2018-06-08 15:45:14 +03:00
|
|
|
if err != nil {
|
2018-06-01 14:20:56 +03:00
|
|
|
return err
|
2018-06-08 15:45:14 +03:00
|
|
|
}
|
|
|
|
if reconfig {
|
|
|
|
return ns.Config()
|
2018-04-19 09:42:07 +03:00
|
|
|
}
|
2018-06-01 14:20:56 +03:00
|
|
|
return nil
|
2018-05-07 04:16:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// wrappers for stopping and starting revid
|
|
|
|
func startRevid() {
|
|
|
|
createRevidInstance()
|
|
|
|
revidInst.Start()
|
2018-04-19 08:58:16 +03:00
|
|
|
}
|
|
|
|
|
2018-06-08 15:56:20 +03:00
|
|
|
func createRevidInstance() {
|
|
|
|
// Try to create the revid instance with the given config
|
|
|
|
var err error
|
2018-06-09 05:01:21 +03:00
|
|
|
for revidInst, err = revid.New(config); err != nil; {
|
2018-06-08 15:56:20 +03:00
|
|
|
// If the config does have a logger, use it to output error, otherwise
|
|
|
|
// just output to std output
|
|
|
|
if config.Logger != nil {
|
|
|
|
config.Logger.Log(progName, "FATAL ERROR", err.Error())
|
|
|
|
} else {
|
|
|
|
fmt.Printf("FATAL ERROR: %v", err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-07 04:16:44 +03:00
|
|
|
func stopRevid() {
|
2018-04-19 11:11:18 +03:00
|
|
|
revidInst.Stop()
|
2018-06-07 14:50:57 +03:00
|
|
|
|
|
|
|
// FIXME(kortschak): Is this waiting on completion of work?
|
|
|
|
// Use a wait group and Wait method if it is.
|
2018-06-08 15:22:11 +03:00
|
|
|
time.Sleep(revidStopTime)
|
2018-05-07 04:16:44 +03:00
|
|
|
}
|
|
|
|
|
2018-06-01 14:20:56 +03:00
|
|
|
func updateRevid(vars map[string]string, stop bool) {
|
2018-05-07 04:16:44 +03:00
|
|
|
if stop {
|
|
|
|
stopRevid()
|
|
|
|
}
|
2018-04-20 11:23:59 +03:00
|
|
|
|
2018-06-01 14:20:56 +03:00
|
|
|
//look through the vars and update revid where needed
|
2018-04-19 08:58:16 +03:00
|
|
|
for key, value := range vars {
|
|
|
|
switch key {
|
2018-05-06 11:38:45 +03:00
|
|
|
case "FramesPerClip":
|
|
|
|
asInt, err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
config.FramesPerClip = value
|
|
|
|
}
|
|
|
|
case "RtmpUrl":
|
|
|
|
config.RtmpUrl = value
|
|
|
|
case "Bitrate":
|
2018-05-14 09:53:55 +03:00
|
|
|
revidInst.Log(revid.Debug, fmt.Sprintf("The value: %v", value))
|
2018-05-06 11:38:45 +03:00
|
|
|
asInt, err := strconv.Atoi(value)
|
2018-05-14 09:53:55 +03:00
|
|
|
revidInst.Log(revid.Debug, fmt.Sprintf("Bitrate as integer: %v", asInt))
|
2018-05-06 11:38:45 +03:00
|
|
|
if asInt > 0 && err == nil {
|
2018-05-14 09:53:55 +03:00
|
|
|
revidInst.Log(revid.Debug, "Updating bitrate")
|
2018-05-06 11:38:45 +03:00
|
|
|
config.Bitrate = value
|
|
|
|
}
|
|
|
|
case "OutputFileName":
|
|
|
|
config.OutputFileName = value
|
|
|
|
case "InputFileName":
|
|
|
|
config.InputFileName = value
|
|
|
|
case "Height":
|
|
|
|
asInt, err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
config.Height = value
|
|
|
|
}
|
|
|
|
case "Width":
|
|
|
|
asInt, err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
config.Width = value
|
|
|
|
}
|
|
|
|
case "FrameRate":
|
|
|
|
asInt, err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
config.FrameRate = value
|
|
|
|
}
|
|
|
|
case "HttpAddress":
|
|
|
|
config.HttpAddress = value
|
|
|
|
case "Quantization":
|
|
|
|
asInt, err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
config.Quantization = value
|
|
|
|
}
|
|
|
|
case "Timeout":
|
|
|
|
asInt, err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
config.Timeout = value
|
|
|
|
}
|
|
|
|
case "IntraRefreshPeriod":
|
|
|
|
asInt, err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
config.IntraRefreshPeriod = value
|
|
|
|
}
|
|
|
|
case "HorizontalFlip":
|
|
|
|
switch value {
|
|
|
|
case "Yes":
|
|
|
|
config.HorizontalFlip = revid.Yes
|
|
|
|
case "No":
|
|
|
|
config.HorizontalFlip = revid.No
|
|
|
|
}
|
|
|
|
case "VerticalFlip":
|
|
|
|
switch value {
|
|
|
|
case "Yes":
|
|
|
|
config.VerticalFlip = revid.Yes
|
|
|
|
case "No":
|
|
|
|
config.VerticalFlip = revid.No
|
|
|
|
}
|
2018-04-19 08:58:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-07 04:16:44 +03:00
|
|
|
startRevid()
|
2018-04-19 08:58:16 +03:00
|
|
|
}
|