Skip to content

Commit

Permalink
Set the vbv-buf-capacity property on the x264 encoder (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
biglittlebigben authored Aug 24, 2023
1 parent 45d36b1 commit 09976c9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/pipeline/builder/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package builder

import (
"fmt"
"time"

"github.com/tinyzimmer/go-gst/gst"

Expand Down Expand Up @@ -329,11 +330,17 @@ func addVideoEncoder(b *gstreamer.Bin, p *config.PipelineConfig) error {
return errors.ErrGstPipelineError(err)
}
}
bufCapacity := uint(2000) // 2s
if p.GetSegmentConfig() != nil {
// Avoid key frames other than at segments boundaries as splitmuxsink can become inconsistent otherwise
if err = x264Enc.SetProperty("option-string", "scenecut=0"); err != nil {
return errors.ErrGstPipelineError(err)
}
bufCapacity = uint(time.Duration(p.GetSegmentConfig().SegmentDuration) * (time.Second / time.Millisecond))
}

if err = x264Enc.SetProperty("vbv-buf-capacity", bufCapacity); err != nil {
return err
}

caps, err := gst.NewElement("capsfilter")
Expand Down

0 comments on commit 09976c9

Please sign in to comment.