diff --git a/internal/capture/manager.go b/internal/capture/manager.go index 94c57184..95bde947 100644 --- a/internal/capture/manager.go +++ b/internal/capture/manager.go @@ -129,6 +129,8 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt "! decodebin " + "! videoconvert " + "! videorate " + + "! videoscale " + + fmt.Sprintf("! video/x-raw,width=%d,height=%d ", config.WebcamWidth, config.WebcamHeight) + "! identity drop-allocation=true " + fmt.Sprintf("! v4l2sink sync=false device=%s", config.WebcamDevice), // TODO: Test this pipeline. @@ -138,6 +140,8 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt "! decodebin " + "! videoconvert " + "! videorate " + + "! videoscale " + + fmt.Sprintf("! video/x-raw,width=%d,height=%d ", config.WebcamWidth, config.WebcamHeight) + "! identity drop-allocation=true " + fmt.Sprintf("! v4l2sink sync=false device=%s", config.WebcamDevice), // TODO: Test this pipeline. @@ -147,6 +151,8 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt "! decodebin " + "! videoconvert " + "! videorate " + + "! videoscale " + + fmt.Sprintf("! video/x-raw,width=%d,height=%d ", config.WebcamWidth, config.WebcamHeight) + "! identity drop-allocation=true " + fmt.Sprintf("! v4l2sink sync=false device=%s", config.WebcamDevice), }, "webcam"), diff --git a/internal/config/capture.go b/internal/config/capture.go index ce01c7de..0b4289c9 100644 --- a/internal/config/capture.go +++ b/internal/config/capture.go @@ -36,6 +36,8 @@ type Capture struct { WebcamEnabled bool WebcamDevice string + WebcamWidth int + WebcamHeight int MicrophoneEnabled bool MicrophoneDevice string @@ -130,6 +132,16 @@ func (Capture) Init(cmd *cobra.Command) error { return err } + cmd.PersistentFlags().Int("capture.webcam.width", 1280, "webcam stream width") + if err := viper.BindPFlag("capture.webcam.width", cmd.PersistentFlags().Lookup("capture.webcam.width")); err != nil { + return err + } + + cmd.PersistentFlags().Int("capture.webcam.height", 720, "webcam stream height") + if err := viper.BindPFlag("capture.webcam.height", cmd.PersistentFlags().Lookup("capture.webcam.height")); err != nil { + return err + } + // microphone cmd.PersistentFlags().Bool("capture.microphone.enabled", true, "enable microphone stream") if err := viper.BindPFlag("capture.microphone.enabled", cmd.PersistentFlags().Lookup("capture.microphone.enabled")); err != nil { @@ -209,6 +221,8 @@ func (s *Capture) Set() { // webcam s.WebcamEnabled = viper.GetBool("capture.webcam.enabled") s.WebcamDevice = viper.GetString("capture.webcam.device") + s.WebcamWidth = viper.GetInt("capture.webcam.width") + s.WebcamHeight = viper.GetInt("capture.webcam.height") // microphone s.MicrophoneEnabled = viper.GetBool("capture.microphone.enabled")