From b647a774cd2ef75540e5a1d0254da45823a79488 Mon Sep 17 00:00:00 2001 From: Alex Eidt Date: Mon, 27 Dec 2021 19:37:42 -0800 Subject: [PATCH] Added ffmpeg check in VideoWriter --- camera.go | 1 + utils.go | 4 ++-- videowriter.go | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/camera.go b/camera.go index 1dc4cf5..34b660f 100644 --- a/camera.go +++ b/camera.go @@ -63,6 +63,7 @@ func getCameraData(device string, camera *Camera) { "-i", device, ) + camera.cmd = cmd pipe, err := cmd.StderrPipe() if err != nil { panic(err) diff --git a/utils.go b/utils.go index a4b7440..64149c9 100644 --- a/utils.go +++ b/utils.go @@ -91,13 +91,13 @@ func parseDevices(buffer []byte) []string { devices := make([]string, 0) bufferstr := string(buffer) - index := strings.Index(bufferstr, "DirectShow video devices") + index := strings.Index(bufferstr, "DirectShow video device") if index == -1 { return devices } bufferstr = bufferstr[index:] - index = strings.Index(bufferstr, "DirectShow audio devices") + index = strings.Index(bufferstr, "DirectShow audio device") if index != -1 { bufferstr = bufferstr[:index] } diff --git a/videowriter.go b/videowriter.go index f28e1d2..9a53aee 100644 --- a/videowriter.go +++ b/videowriter.go @@ -36,6 +36,9 @@ type Options struct { } func NewVideoWriter(filename string, width, height int, options *Options) *VideoWriter { + // Check if ffmpeg is installed on the users machine. + checkExists("ffmpeg") + writer := VideoWriter{filename: filename} writer.width = width