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"
|
"os/signal"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
@ -73,9 +72,9 @@ func NewCamera(stream int) (*Camera, error) {
|
||||||
var device string
|
var device string
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "linux":
|
case "linux":
|
||||||
device = "/dev/video" + strconv.Itoa(stream)
|
device = fmt.Sprintf("/dev/video%d", stream)
|
||||||
case "darwin":
|
case "darwin":
|
||||||
device = strconv.Itoa(stream)
|
device = fmt.Sprintf(`"%d"`, stream)
|
||||||
case "windows":
|
case "windows":
|
||||||
// If OS is windows, we need to parse the listed devices to find which corresponds to the
|
// If OS is windows, we need to parse the listed devices to find which corresponds to the
|
||||||
// given "stream" index.
|
// given "stream" index.
|
||||||
|
@ -83,10 +82,10 @@ func NewCamera(stream int) (*Camera, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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)
|
return nil, fmt.Errorf("could not find device with index: %d", stream)
|
||||||
}
|
}
|
||||||
device = "video=" + devices[stream]
|
device = fmt.Sprintf("video=%s", devices[stream])
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported OS: %s", runtime.GOOS)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
writer := VideoWriter{filename: filename}
|
writer := &VideoWriter{filename: filename}
|
||||||
|
|
||||||
if options == nil {
|
if options == nil {
|
||||||
options = &Options{}
|
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,
|
// Once the user calls Write() for the first time on a VideoWriter struct,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue