diff --git a/internal/capture/manager.go b/internal/capture/manager.go index 6e6950a8..4a1ebfe2 100644 --- a/internal/capture/manager.go +++ b/internal/capture/manager.go @@ -34,14 +34,14 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt "! audio/x-raw,channels=2 "+ "! audioconvert "+ "! queue "+ - "! voaacenc bitrate=128000 "+ + "! voaacenc bitrate=%d "+ "! mux. "+ "ximagesrc display-name=%s show-pointer=true use-damage=false "+ "! video/x-raw "+ "! videoconvert "+ "! queue "+ - "! x264enc threads=4 bitrate=4096 key-int-max=15 byte-stream=true tune=zerolatency speed-preset=veryfast "+ - "! mux.", config.AudioDevice, config.Display, + "! x264enc threads=4 bitrate=%d key-int-max=15 byte-stream=true tune=zerolatency speed-preset=%s "+ + "! mux.", config.AudioDevice, config.BroadcastAudioBitrate*1000, config.Display, config.BroadcastVideoBitrate, config.BroadcastPreset, ) } diff --git a/internal/config/capture.go b/internal/config/capture.go index 095ad736..d3612263 100644 --- a/internal/config/capture.go +++ b/internal/config/capture.go @@ -17,7 +17,10 @@ type Capture struct { AudioCodec codec.RTPCodec AudioPipeline string - BroadcastPipeline string + BroadcastAudioBitrate int + BroadcastVideoBitrate int + BroadcastPreset string + BroadcastPipeline string ScreencastEnabled bool ScreencastRate string @@ -43,6 +46,21 @@ func (Capture) Init(cmd *cobra.Command) error { } // broadcast + cmd.PersistentFlags().Int("capture.screencast.audio_bitrate", 128, "broadcast audio bitrate in KB/s") + if err := viper.BindPFlag("capture.screencast.audio_bitrate", cmd.PersistentFlags().Lookup("capture.screencast.audio_bitrate")); err != nil { + return err + } + + cmd.PersistentFlags().Int("capture.screencast.video_bitrate", 4096, "broadcast video bitrate in KB/s") + if err := viper.BindPFlag("capture.screencast.video_bitrate", cmd.PersistentFlags().Lookup("capture.screencast.video_bitrate")); err != nil { + return err + } + + cmd.PersistentFlags().String("capture.screencast.preset", "veryfast", "broadcast speed preset for h264 encoding") + if err := viper.BindPFlag("capture.screencast.preset", cmd.PersistentFlags().Lookup("capture.screencast.preset")); err != nil { + return err + } + cmd.PersistentFlags().String("capture.broadcast.pipeline", "", "gstreamer pipeline used for broadcasting") if err := viper.BindPFlag("capture.broadcast.pipeline", cmd.PersistentFlags().Lookup("capture.broadcast.pipeline")); err != nil { return err @@ -94,6 +112,9 @@ func (s *Capture) Set() { s.AudioCodec = codec.Opus() } + s.BroadcastAudioBitrate = viper.GetInt("capture.broadcast.audio_bitrate") + s.BroadcastVideoBitrate = viper.GetInt("capture.broadcast.video_bitrate") + s.BroadcastPreset = viper.GetString("capture.broadcast.preset") s.BroadcastPipeline = viper.GetString("capture.broadcast.pipeline") s.ScreencastEnabled = viper.GetBool("capture.screencast.enabled")