From 48d36c20823b2fd2fcddf215319c9758aae69359 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 3 Dec 2019 14:36:16 +1030 Subject: [PATCH] Ffmpeg gets different args for mjpeg encoding --- device/webcam/webcam.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/device/webcam/webcam.go b/device/webcam/webcam.go index 788f4057..a987f913 100644 --- a/device/webcam/webcam.go +++ b/device/webcam/webcam.go @@ -114,10 +114,14 @@ func (w *Webcam) Set(c config.Config) error { // Start will build the required arguments for ffmpeg and then execute the // command, piping video output where we can read using the Read method. func (w *Webcam) Start() error { + br := w.cfg.Bitrate * 1000 + args := []string{ "-i", w.cfg.InputPath, "-r", fmt.Sprint(w.cfg.FrameRate), - } + "-b:v", fmt.Sprint(br), + "-s", fmt.Sprintf("%dx%d", w.cfg.Width, w.cfg.Height), + } switch w.cfg.InputCodec { default: @@ -125,6 +129,8 @@ func (w *Webcam) Start() error { case codecutil.H264: args = append(args, "-f", "h264", + "-maxrate", fmt.Sprint(br), + "-bufsize", fmt.Sprint(br/2), ) case codecutil.MJPEG: args = append(args, @@ -132,17 +138,11 @@ func (w *Webcam) Start() error { ) } - br := w.cfg.Bitrate * 1000 args = append(args, - "-b:v", fmt.Sprint(br), - "-maxrate", fmt.Sprint(br), - "-bufsize", fmt.Sprint(br/2), - "-s", fmt.Sprintf("%dx%d", w.cfg.Width, w.cfg.Height), "-", ) w.log.Log(logger.Info, pkg+"ffmpeg args", "args", strings.Join(args, " ")) - fmt.Printf("%v", args) // !!!! w.cmd = exec.Command("ffmpeg", args...) var err error