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

CBR for rtmp streams #568

Merged
merged 1 commit into from
Dec 26, 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
9 changes: 6 additions & 3 deletions pkg/pipeline/builder/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,6 @@ func (b *VideoBin) addEncoder() error {
if err != nil {
return errors.ErrGstPipelineError(err)
}
if err = x264Enc.SetProperty("bitrate", uint(b.conf.VideoBitrate)); err != nil {
return errors.ErrGstPipelineError(err)
}
x264Enc.SetArg("speed-preset", "veryfast")
if b.conf.KeyFrameInterval != 0 {
if err = x264Enc.SetProperty("key-int-max", uint(b.conf.KeyFrameInterval*float64(b.conf.Framerate))); err != nil {
Expand All @@ -538,6 +535,12 @@ func (b *VideoBin) addEncoder() error {
if err = x264Enc.SetProperty("vbv-buf-capacity", bufCapacity); err != nil {
return err
}
if b.conf.GetStreamConfig() != nil {
x264Enc.SetArg("pass", "cbr")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cbr is the default value according to the documentation. Any reason to set it anyway?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the veryfast setting sets rc=crf, I wasn't sure whether that meant it's being overridden

}
if err = x264Enc.SetProperty("bitrate", uint(b.conf.VideoBitrate)); err != nil {
return errors.ErrGstPipelineError(err)
}

caps, err := gst.NewElement("capsfilter")
if err != nil {
Expand Down