mirror of https://bitbucket.org/ausocean/av.git
Merge branch 'RevidCLI' of https://bitbucket.org/ausocean/av into RevidCLI
This commit is contained in:
commit
9afe4b1334
|
@ -63,13 +63,14 @@ const (
|
||||||
quantizationPtr = 16
|
quantizationPtr = 16
|
||||||
timeoutPtr = 17
|
timeoutPtr = 17
|
||||||
intraRefreshPeriodPtr = 18
|
intraRefreshPeriodPtr = 18
|
||||||
|
rotatePtr = 19
|
||||||
)
|
)
|
||||||
|
|
||||||
// Other misc consts
|
// Other misc consts
|
||||||
const (
|
const (
|
||||||
sleepTime = 2 * 43200
|
sleepTime = 2 * 43200
|
||||||
defaultRunDuration = 2 * 43200
|
defaultRunDuration = 2 * 43200
|
||||||
noOfConfigconfigFlags = 19
|
noOfConfigconfigFlags = 20
|
||||||
revidStopTime = 5
|
revidStopTime = 5
|
||||||
prepTime = 20
|
prepTime = 20
|
||||||
loggerVerbosity = 3
|
loggerVerbosity = 3
|
||||||
|
@ -118,6 +119,7 @@ func main() {
|
||||||
{"Quantization", "Desired quantization value"},
|
{"Quantization", "Desired quantization value"},
|
||||||
{"Timeout", "Http timeout in seconds"},
|
{"Timeout", "Http timeout in seconds"},
|
||||||
{"IntraRefreshPeriod", "The IntraRefreshPeriod i.e. how many keyframes we send"},
|
{"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
|
// Create the configFlags based on the flagNames array
|
||||||
|
@ -221,6 +223,7 @@ func main() {
|
||||||
config.Quantization = *configFlags[quantizationPtr]
|
config.Quantization = *configFlags[quantizationPtr]
|
||||||
config.Timeout = *configFlags[timeoutPtr]
|
config.Timeout = *configFlags[timeoutPtr]
|
||||||
config.IntraRefreshPeriod = *configFlags[intraRefreshPeriodPtr]
|
config.IntraRefreshPeriod = *configFlags[intraRefreshPeriodPtr]
|
||||||
|
config.Rotate = *configFlags[rotatePtr]
|
||||||
|
|
||||||
// Also give the config a logger object
|
// Also give the config a logger object
|
||||||
config.Logger = smartLogger.New(loggerVerbosity, smartLogger.White)
|
config.Logger = smartLogger.New(loggerVerbosity, smartLogger.White)
|
||||||
|
@ -274,7 +277,8 @@ func periodicNetsenderReport(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inputs := []string{"X20", "X21"}
|
//inputs := []string{"X20", "X21"}
|
||||||
|
inputs := netsender.GetConfigParam("inputs")
|
||||||
if _, _, err := netsender.Send(netsender.RequestPoll, inputs); err != nil {
|
if _, _, err := netsender.Send(netsender.RequestPoll, inputs); err != nil {
|
||||||
config.Logger.Log("Error", err.Error())
|
config.Logger.Log("Error", err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,7 @@ const (
|
||||||
defaultBitrate = "500000"
|
defaultBitrate = "500000"
|
||||||
defaultQuantizationMode = QuantizationOff
|
defaultQuantizationMode = QuantizationOff
|
||||||
defaultFramesPerClip = "1"
|
defaultFramesPerClip = "1"
|
||||||
|
defaultRotate = "0"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Validate checks for any errors in the config fields and defaults settings
|
// 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!")
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ const (
|
||||||
sendFailedDelay = 5
|
sendFailedDelay = 5
|
||||||
maxSendFailedErrorCount = 500
|
maxSendFailedErrorCount = 500
|
||||||
clipSizeThreshold = 11
|
clipSizeThreshold = 11
|
||||||
|
rtmpConnectionMaxTries = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
// Log Types
|
// Log Types
|
||||||
|
@ -278,6 +279,7 @@ func (r *revid) Stop() {
|
||||||
if r.cmd != nil && r.cmd.Process != nil {
|
if r.cmd != nil && r.cmd.Process != nil {
|
||||||
r.cmd.Process.Kill()
|
r.cmd.Process.Kill()
|
||||||
}
|
}
|
||||||
|
r.rtmpInst.EndSession()
|
||||||
}
|
}
|
||||||
|
|
||||||
// getFrameNoPacketization gets a frame directly from the revid output chan
|
// getFrameNoPacketization gets a frame directly from the revid output chan
|
||||||
|
@ -503,11 +505,18 @@ func (r *revid) setupOutputForFfmpegRtmp() error {
|
||||||
|
|
||||||
// setupOutputForLibRtmp sets up rtmp output using the wrapper for the c based
|
// setupOutputForLibRtmp sets up rtmp output using the wrapper for the c based
|
||||||
// librtmp library - makes connection and starts comms etc.
|
// librtmp library - makes connection and starts comms etc.
|
||||||
func (r *revid) setupOutputForLibRtmp() (err error) {
|
func (r *revid) setupOutputForLibRtmp() error {
|
||||||
r.rtmpInst = rtmp.NewRTMPSession(r.config.RtmpUrl, rtmpConnectionTimout)
|
for r.rtmpInst = rtmp.NewRTMPSession(r.config.RtmpUrl, rtmpConnectionTimout),
|
||||||
err = r.rtmpInst.StartSession()
|
err = r.rtmpInst.StartSession(), noOfTries := 0;
|
||||||
// go r.testRtmp(5000)
|
err != nil && noOfTries < rtmpConnectionMaxTries; noOfTries++
|
||||||
return
|
{
|
||||||
|
r.rtmpInst.EndSession()
|
||||||
|
r.Log(Error, err.Error())
|
||||||
|
r.Log(Info, "Trying to establish rtmp connection again!")
|
||||||
|
r.rtmpInst = rtmp.NewRTMPSession(r.config.RtmpUrl, rtmpConnectionTimout)
|
||||||
|
err = r.rtmpInst.StartSession()
|
||||||
|
}
|
||||||
|
return errors.New("Could not establish rtmp connection, check rtmp url!")
|
||||||
}
|
}
|
||||||
|
|
||||||
// setupOutputForFile sets up an output file to output data to
|
// setupOutputForFile sets up an output file to output data to
|
||||||
|
@ -536,6 +545,7 @@ func (r *revid) setupInputForRaspivid() error {
|
||||||
"-fps", r.config.FrameRate,
|
"-fps", r.config.FrameRate,
|
||||||
"-ih",
|
"-ih",
|
||||||
"-g", r.config.IntraRefreshPeriod,
|
"-g", r.config.IntraRefreshPeriod,
|
||||||
|
"-ro", r.config.Rotate,
|
||||||
)
|
)
|
||||||
case QuantizationOff:
|
case QuantizationOff:
|
||||||
r.cmd = exec.Command("raspivid",
|
r.cmd = exec.Command("raspivid",
|
||||||
|
@ -549,6 +559,7 @@ func (r *revid) setupInputForRaspivid() error {
|
||||||
"-fps", r.config.FrameRate,
|
"-fps", r.config.FrameRate,
|
||||||
"-ih",
|
"-ih",
|
||||||
"-g", r.config.IntraRefreshPeriod,
|
"-g", r.config.IntraRefreshPeriod,
|
||||||
|
"-ro", r.config.Rotate,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue