-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
baresip: add avcodec: constrain bitrate patch
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
From 8897f63134635868ae0d4cd21f06a58880bc1f9c Mon Sep 17 00:00:00 2001 | ||
From: Sebastian Reimers <[email protected]> | ||
Date: Fri, 23 Dec 2022 10:59:04 +0100 | ||
Subject: [PATCH] avcodec: constrain bitrate | ||
|
||
With rc_buffer_size and rc_max_rate the encoder can better calculate | ||
a constant average bitrate and this avoids large bitrate spikes. | ||
|
||
See: https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate | ||
--- | ||
modules/avcodec/encode.c | 5 ++++- | ||
1 file changed, 4 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/modules/avcodec/encode.c b/modules/avcodec/encode.c | ||
index 8ce4eb8b5..b45cd0947 100644 | ||
--- a/modules/avcodec/encode.c | ||
+++ b/modules/avcodec/encode.c | ||
@@ -164,7 +164,10 @@ static int open_encoder(struct videnc_state *st, | ||
|
||
av_opt_set_defaults(st->ctx); | ||
|
||
- st->ctx->bit_rate = prm->bitrate; | ||
+ st->ctx->bit_rate = prm->bitrate; | ||
+ st->ctx->rc_max_rate = prm->bitrate; | ||
+ st->ctx->rc_buffer_size = prm->bitrate / 2; | ||
+ | ||
st->ctx->width = size->w; | ||
st->ctx->height = size->h; | ||
|