Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the vbv-buf-capacity property on the x264 encoder #471

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading