diff --git a/internal/capture/gst/gst.go b/internal/capture/gst/gst.go index 6989abdd..d41608a4 100644 --- a/internal/capture/gst/gst.go +++ b/internal/capture/gst/gst.go @@ -59,12 +59,12 @@ func CreateRTMPPipeline(pipelineDevice string, pipelineDisplay string, pipelineS } // CreateJPEGPipeline creates a GStreamer Pipeline -func CreateJPEGPipeline(pipelineDisplay string, pipelineSrc string) (*Pipeline, error) { +func CreateJPEGPipeline(pipelineDisplay string, pipelineSrc string, rate string, quality string) (*Pipeline, error) { var pipelineStr string if pipelineSrc != "" { pipelineStr = fmt.Sprintf(pipelineSrc, pipelineDisplay) } else { - pipelineStr = fmt.Sprintf("ximagesrc display-name=%s show-pointer=true use-damage=false ! videoconvert ! videoscale ! videorate ! video/x-raw,framerate=10/1 ! jpegenc quality=60" + appSink, pipelineDisplay) + pipelineStr = fmt.Sprintf("ximagesrc display-name=%s show-pointer=true use-damage=false ! videoconvert ! videoscale ! videorate ! video/x-raw,framerate=%s ! jpegenc quality=%s" + appSink, pipelineDisplay, rate, quality) } return CreatePipeline(pipelineStr, 0) diff --git a/internal/capture/screencast.go b/internal/capture/screencast.go index c9e1d7d1..da2f9ccf 100644 --- a/internal/capture/screencast.go +++ b/internal/capture/screencast.go @@ -81,6 +81,8 @@ func (manager *ScreencastManagerCtx) createPipeline() error { manager.pipeline, err = gst.CreateJPEGPipeline( manager.config.Display, manager.config.ScreencastPipeline, + manager.config.ScreencastRate, + manager.config.ScreencastQuality, ) if err != nil { diff --git a/internal/config/capture.go b/internal/config/capture.go index ede2a616..397367b4 100644 --- a/internal/config/capture.go +++ b/internal/config/capture.go @@ -16,6 +16,8 @@ type Capture struct { BroadcastPipeline string Screencast bool + ScreencastRate string + ScreencastQuality string ScreencastPipeline string } @@ -89,6 +91,16 @@ func (Capture) Init(cmd *cobra.Command) error { return err } + cmd.PersistentFlags().String("screencast_rate", "10/1", "set screencast frame rate") + if err := viper.BindPFlag("screencast_rate", cmd.PersistentFlags().Lookup("screencast_rate")); err != nil { + return err + } + + cmd.PersistentFlags().String("screencast_quality", "60", "set screencast JPEG quality") + if err := viper.BindPFlag("screencast_quality", cmd.PersistentFlags().Lookup("screencast_quality")); err != nil { + return err + } + cmd.PersistentFlags().String("screencast_pipeline", "", "custom screencast pipeline") if err := viper.BindPFlag("screencast_pipeline", cmd.PersistentFlags().Lookup("screencast_pipeline")); err != nil { return err @@ -127,5 +139,7 @@ func (s *Capture) Set() { s.BroadcastPipeline = viper.GetString("broadcast_pipeline") s.Screencast = viper.GetBool("screencast") + s.ScreencastRate = viper.GetString("screencast_rate") + s.ScreencastQuality = viper.GetString("screencast_quality") s.ScreencastPipeline = viper.GetString("screencast_pipeline") }