Skip to content

Commit

Permalink
add videorate to web egress (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostbyte73 authored May 2, 2024
1 parent 78c7f85 commit 40832fa
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions pkg/pipeline/builder/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ import (
lksdk "github.com/livekit/server-sdk-go/v2"
)

const videoTestSrcName = "video_test_src"
const (
videoTestSrcName = "video_test_src"
maxDuplicationTime = time.Second
)

type VideoBin struct {
bin *gstreamer.Bin
Expand Down Expand Up @@ -211,6 +214,17 @@ func (b *VideoBin) buildWebInput() error {
return errors.ErrGstPipelineError(err)
}

videoRate, err := gst.NewElement("videorate")
if err != nil {
return errors.ErrGstPipelineError(err)
}
if err = videoRate.SetProperty("max-duplication-time", uint64(maxDuplicationTime)); err != nil {
return err
}
if err = videoRate.SetProperty("skip-to-first", true); err != nil {
return err
}

caps, err := gst.NewElement("capsfilter")
if err != nil {
return errors.ErrGstPipelineError(err)
Expand All @@ -223,7 +237,7 @@ func (b *VideoBin) buildWebInput() error {
return errors.ErrGstPipelineError(err)
}

if err = b.bin.AddElements(xImageSrc, videoQueue, videoConvert, caps); err != nil {
if err = b.bin.AddElements(xImageSrc, videoQueue, videoConvert, videoRate, caps); err != nil {
return err
}

Expand Down Expand Up @@ -489,7 +503,7 @@ func (b *VideoBin) addSelector() error {
if err != nil {
return errors.ErrGstPipelineError(err)
}
if err = videoRate.SetProperty("max-duplication-time", uint64(time.Second)); err != nil {
if err = videoRate.SetProperty("max-duplication-time", uint64(maxDuplicationTime)); err != nil {
return err
}
if err = videoRate.SetProperty("skip-to-first", true); err != nil {
Expand Down Expand Up @@ -647,7 +661,7 @@ func addVideoConverter(b *gstreamer.Bin, p *config.PipelineConfig) error {
if err != nil {
return errors.ErrGstPipelineError(err)
}
if err = videoRate.SetProperty("max-duplication-time", uint64(time.Second)); err != nil {
if err = videoRate.SetProperty("max-duplication-time", uint64(maxDuplicationTime)); err != nil {
return err
}
if err = videoRate.SetProperty("skip-to-first", true); err != nil {
Expand Down

0 comments on commit 40832fa

Please sign in to comment.