add webcam resolution + to config.

This commit is contained in:
Miroslav Šedivý 2022-01-08 23:53:45 +01:00
parent dc33aa37bc
commit 8b6a2ed6d6
2 changed files with 20 additions and 0 deletions

View File

@ -129,6 +129,8 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt
"! decodebin " + "! decodebin " +
"! videoconvert " + "! videoconvert " +
"! videorate " + "! videorate " +
"! videoscale " +
fmt.Sprintf("! video/x-raw,width=%d,height=%d ", config.WebcamWidth, config.WebcamHeight) +
"! identity drop-allocation=true " + "! identity drop-allocation=true " +
fmt.Sprintf("! v4l2sink sync=false device=%s", config.WebcamDevice), fmt.Sprintf("! v4l2sink sync=false device=%s", config.WebcamDevice),
// TODO: Test this pipeline. // TODO: Test this pipeline.
@ -138,6 +140,8 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt
"! decodebin " + "! decodebin " +
"! videoconvert " + "! videoconvert " +
"! videorate " + "! videorate " +
"! videoscale " +
fmt.Sprintf("! video/x-raw,width=%d,height=%d ", config.WebcamWidth, config.WebcamHeight) +
"! identity drop-allocation=true " + "! identity drop-allocation=true " +
fmt.Sprintf("! v4l2sink sync=false device=%s", config.WebcamDevice), fmt.Sprintf("! v4l2sink sync=false device=%s", config.WebcamDevice),
// TODO: Test this pipeline. // TODO: Test this pipeline.
@ -147,6 +151,8 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt
"! decodebin " + "! decodebin " +
"! videoconvert " + "! videoconvert " +
"! videorate " + "! videorate " +
"! videoscale " +
fmt.Sprintf("! video/x-raw,width=%d,height=%d ", config.WebcamWidth, config.WebcamHeight) +
"! identity drop-allocation=true " + "! identity drop-allocation=true " +
fmt.Sprintf("! v4l2sink sync=false device=%s", config.WebcamDevice), fmt.Sprintf("! v4l2sink sync=false device=%s", config.WebcamDevice),
}, "webcam"), }, "webcam"),

View File

@ -36,6 +36,8 @@ type Capture struct {
WebcamEnabled bool WebcamEnabled bool
WebcamDevice string WebcamDevice string
WebcamWidth int
WebcamHeight int
MicrophoneEnabled bool MicrophoneEnabled bool
MicrophoneDevice string MicrophoneDevice string
@ -130,6 +132,16 @@ func (Capture) Init(cmd *cobra.Command) error {
return err 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 // microphone
cmd.PersistentFlags().Bool("capture.microphone.enabled", true, "enable microphone stream") 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 { if err := viper.BindPFlag("capture.microphone.enabled", cmd.PersistentFlags().Lookup("capture.microphone.enabled")); err != nil {
@ -209,6 +221,8 @@ func (s *Capture) Set() {
// webcam // webcam
s.WebcamEnabled = viper.GetBool("capture.webcam.enabled") s.WebcamEnabled = viper.GetBool("capture.webcam.enabled")
s.WebcamDevice = viper.GetString("capture.webcam.device") s.WebcamDevice = viper.GetString("capture.webcam.device")
s.WebcamWidth = viper.GetInt("capture.webcam.width")
s.WebcamHeight = viper.GetInt("capture.webcam.height")
// microphone // microphone
s.MicrophoneEnabled = viper.GetBool("capture.microphone.enabled") s.MicrophoneEnabled = viper.GetBool("capture.microphone.enabled")