mirror of https://bitbucket.org/ausocean/av.git
fixing flilp bug
This commit is contained in:
parent
d178586d0a
commit
6f94ea3107
|
@ -42,6 +42,7 @@ import (
|
|||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
"filepath"
|
||||
|
||||
"bitbucket.org/ausocean/av/generator"
|
||||
"bitbucket.org/ausocean/av/parser"
|
||||
|
@ -74,6 +75,7 @@ const (
|
|||
maxSendFailedErrorCount = 500
|
||||
clipSizeThreshold = 11
|
||||
rtmpConnectionMaxTries = 5
|
||||
raspividNoOfTries = 3
|
||||
)
|
||||
|
||||
// Log Types
|
||||
|
@ -528,49 +530,45 @@ func (r *revid) setupInputForRaspivid() error {
|
|||
r.Log(Info, "Starting raspivid!")
|
||||
switch r.config.InputCodec {
|
||||
case H264:
|
||||
var quantizationFlag string
|
||||
var quantizationValue string
|
||||
var verticalFlipFlag string
|
||||
var horizontalFlipFlag string
|
||||
|
||||
switch r.config.QuantizationMode {
|
||||
case QuantizationOn:
|
||||
quantizationFlag = "-qp"
|
||||
quantizationValue = r.config.Quantization
|
||||
case QuantizationOff:
|
||||
quantizationFlag = ""
|
||||
quantizationValue = ""
|
||||
}
|
||||
|
||||
switch r.config.HorizontalFlip {
|
||||
case Yes:
|
||||
horizontalFlipFlag = "-hf"
|
||||
case No:
|
||||
horizontalFlipFlag = ""
|
||||
}
|
||||
|
||||
switch r.config.VerticalFlip {
|
||||
case Yes:
|
||||
verticalFlipFlag = "-vf"
|
||||
case No:
|
||||
verticalFlipFlag = ""
|
||||
}
|
||||
|
||||
r.cmd = exec.Command("raspivid",
|
||||
"-cd", "H264",
|
||||
arguments := []string{ "-cd", "H264",
|
||||
"-o", "-",
|
||||
"-n",
|
||||
"-t", r.config.Timeout,
|
||||
"-b", "0",
|
||||
quantizationFlag, quantizationValue,
|
||||
"-w", r.config.Width,
|
||||
"-h", r.config.Height,
|
||||
"-fps", r.config.FrameRate,
|
||||
"-ih",
|
||||
"-g", r.config.IntraRefreshPeriod,
|
||||
verticalFlipFlag,
|
||||
horizontalFlipFlag,
|
||||
)
|
||||
}
|
||||
|
||||
if r.config.QuantizationMode == QuantizationOn{
|
||||
append(arguments,"-qp")
|
||||
append(arguments,r.config.Quantization);
|
||||
}
|
||||
|
||||
if r.config.HorizontalFlip == Yes {
|
||||
append(arguments, "-hf")
|
||||
}
|
||||
|
||||
if r.config.VerticalFlip == Yes {
|
||||
append(arguments, "-vf")
|
||||
}
|
||||
|
||||
r.cmd = &Cmd{
|
||||
Path: "raspivid",
|
||||
Args: append([]string{"raspivid"}, arguments),
|
||||
}
|
||||
if filepath.Base(name) == name {
|
||||
if lp, err := LookPath(name); err != nil {
|
||||
cmd.lookPathErr = err
|
||||
} else {
|
||||
cmd.Path = lp
|
||||
}
|
||||
}
|
||||
|
||||
case Mjpeg:
|
||||
r.cmd = exec.Command("raspivid",
|
||||
|
@ -583,11 +581,18 @@ func (r *revid) setupInputForRaspivid() error {
|
|||
}
|
||||
stdout, _ := r.cmd.StdoutPipe()
|
||||
err := r.cmd.Start()
|
||||
r.inputReader = bufio.NewReader(stdout)
|
||||
if err != nil {
|
||||
r.Log(Error, err.Error())
|
||||
for i := 0; i < raspividNoOfTries; i++ {
|
||||
r.Log(Error, err.Error())
|
||||
err = r.cmd.Start()
|
||||
if err == nil {
|
||||
goto raspividSuccess
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
raspividSuccess:
|
||||
r.inputReader = bufio.NewReader(stdout)
|
||||
go r.readCamera()
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue