Cleanup
This commit is contained in:
parent
25fa3dd387
commit
2c194879df
2 changed files with 6 additions and 7 deletions
|
@ -8,7 +8,6 @@ import (
|
|||
"os/signal"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
)
|
||||
|
@ -73,9 +72,9 @@ func NewCamera(stream int) (*Camera, error) {
|
|||
var device string
|
||||
switch runtime.GOOS {
|
||||
case "linux":
|
||||
device = "/dev/video" + strconv.Itoa(stream)
|
||||
device = fmt.Sprintf("/dev/video%d", stream)
|
||||
case "darwin":
|
||||
device = strconv.Itoa(stream)
|
||||
device = fmt.Sprintf(`"%d"`, stream)
|
||||
case "windows":
|
||||
// If OS is windows, we need to parse the listed devices to find which corresponds to the
|
||||
// given "stream" index.
|
||||
|
@ -83,10 +82,10 @@ func NewCamera(stream int) (*Camera, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if stream >= len(devices) {
|
||||
if stream < 0 || stream >= len(devices) {
|
||||
return nil, fmt.Errorf("could not find device with index: %d", stream)
|
||||
}
|
||||
device = "video=" + devices[stream]
|
||||
device = fmt.Sprintf("video=%s", devices[stream])
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported OS: %s", runtime.GOOS)
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ func NewVideoWriter(filename string, width, height int, options *Options) (*Vide
|
|||
return nil, err
|
||||
}
|
||||
|
||||
writer := VideoWriter{filename: filename}
|
||||
writer := &VideoWriter{filename: filename}
|
||||
|
||||
if options == nil {
|
||||
options = &Options{}
|
||||
|
@ -180,7 +180,7 @@ func NewVideoWriter(filename string, width, height int, options *Options) (*Vide
|
|||
}
|
||||
}
|
||||
|
||||
return &writer, nil
|
||||
return writer, nil
|
||||
}
|
||||
|
||||
// Once the user calls Write() for the first time on a VideoWriter struct,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue