mirror of https://bitbucket.org/ausocean/av.git
Everything seems to be working except for fps
This commit is contained in:
parent
31a13b2dc2
commit
91bc6fbff9
|
@ -217,14 +217,19 @@ func (r *revidInst) ChangeState(config Config) error {
|
|||
|
||||
switch config.InputCodec {
|
||||
case H264:
|
||||
if config.Bitrate != "" && config.Quantization != "" && (
|
||||
(strconv.Atoi(config.Bitrate) > 0 && strconv.AtoI(config.Quantization) > 0) ||
|
||||
(strconv.Atoi(config.Bitrate) == 0 && strconv.AtoI(config.Quantization) == 0) ){
|
||||
if config.Bitrate != "" && config.Quantization != "" {
|
||||
bitrate, _ := strconv.Atoi(config.Bitrate)
|
||||
quantization, _ := strconv.Atoi(config.Quantization)
|
||||
if (bitrate > 0 && quantization > 0) || (bitrate == 0 && quantization == 0) {
|
||||
return errors.New("Bad bitrate and quantization combination for H264 input!")
|
||||
}
|
||||
}
|
||||
case Mjpeg:
|
||||
if config.Quantization != "" && config.Quantization > 0 || config.Bitrate == "" {
|
||||
if config.Quantization != "" {
|
||||
quantization, _ := strconv.Atoi(config.Quantization)
|
||||
if quantization > 0 || config.Bitrate == "" {
|
||||
return errors.New("Bad bitrate or quantization for mjpeg input!")
|
||||
}
|
||||
}
|
||||
case NothingDefined:
|
||||
r.Log(Warning, "No input codec defined, defaulting to h264!")
|
||||
|
@ -305,7 +310,7 @@ func (r *revidInst) ChangeState(config Config) error {
|
|||
r.Log(Warning, "No quantization defined, defaulting to 35!")
|
||||
config.Quantization = defaultQuantization
|
||||
} else {
|
||||
if integer, err := strconv.Atoi(config.Quantization); integer <= 0 || integer > 51 || err != nil {
|
||||
if integer, err := strconv.Atoi(config.Quantization); integer < 0 || integer > 51 || err != nil {
|
||||
return errors.New("Bad quantization defined in config!")
|
||||
}
|
||||
}
|
||||
|
@ -342,26 +347,31 @@ func (r *revidInst) Start() {
|
|||
switch r.config.Input {
|
||||
case Raspivid:
|
||||
r.Log(Info, "Starting raspivid!")
|
||||
var codec string
|
||||
switch r.config.InputCodec {
|
||||
case H264:
|
||||
codec = "H264"
|
||||
r.cmd = exec.Command("raspivid",
|
||||
"-cd", "H264",
|
||||
"-o", "-",
|
||||
"-n",
|
||||
"-t", r.config.Timeout,
|
||||
"-b", r.config.Bitrate,
|
||||
"-qp", r.config.Quantization,
|
||||
"-w", r.config.Width,
|
||||
"-h", r.config.Height,
|
||||
"-fps", r.config.FrameRate,
|
||||
"-ih",
|
||||
"-g", r.config.IntraRefreshPeriod,
|
||||
)
|
||||
case Mjpeg:
|
||||
codec = "MJPEG"
|
||||
r.cmd = exec.Command("raspivid",
|
||||
"-cd", "MJPEG",
|
||||
"-o", "-",
|
||||
"-n",
|
||||
"-t", r.config.Timeout,
|
||||
"-fps", r.config.FrameRate,
|
||||
)
|
||||
}
|
||||
r.cmd = exec.Command("raspivid",
|
||||
"-cd", codec,
|
||||
"-o", "-",
|
||||
"-n",
|
||||
"-t", r.config.Timeout,
|
||||
"-b", r.config.Bitrate,
|
||||
"-qp", r.config.Quantization,
|
||||
"-w", r.config.Width,
|
||||
"-h", r.config.Height,
|
||||
"-fps", r.config.FrameRate,
|
||||
"-ih",
|
||||
"-g", r.config.IntraRefreshPeriod,
|
||||
)
|
||||
|
||||
stdout, _ := r.cmd.StdoutPipe()
|
||||
err := r.cmd.Start()
|
||||
r.inputReader = bufio.NewReader(stdout)
|
||||
|
|
|
@ -79,19 +79,18 @@ func TestRaspividMJPEGInput(t *testing.T){
|
|||
Input: Raspivid,
|
||||
InputCodec: Mjpeg,
|
||||
Output: File,
|
||||
OutputFileName: "output/TestRaspividMjpegOutput.mjpeg",
|
||||
OutputFileName: "output/TestMjpeg.mjpeg",
|
||||
Width: "1280",
|
||||
Bitrate: "1000000",
|
||||
Bitrate: "10000000",
|
||||
Height: "720",
|
||||
Quantization: "0",
|
||||
FrameRate: "25",
|
||||
}
|
||||
revidInst, err := NewRevidInstance(config)
|
||||
if err != nil {
|
||||
t.Errorf("Should not of have got an error!")
|
||||
t.Errorf("Should not of have got an error!: %v\n", err.Error())
|
||||
return
|
||||
}
|
||||
revidInst.Start()
|
||||
time.Sleep(5*time.Second)
|
||||
time.Sleep(20*time.Second)
|
||||
revidInst.Stop()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue