Skip to content

Commit cb4afa2

Browse files
committed
修改设置自定义码率的上限
Change-Id: I102684d34bf1c0fe389a0c2153f9e7f895715243
1 parent f8c9443 commit cb4afa2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sdk/video-link-android/src/main/java/com/tencent/iot/video/link/encoder/VideoEncoder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class VideoEncoder {
2525
private OnEncodeListener encoderListener;
2626
private long seq = 0L;
2727
private int MAX_BITRATE_LENGTH = 1000000;
28+
private int beginBitRate = 0;
2829

2930
public VideoEncoder(VideoEncodeParam param) {
3031
this.videoEncodeParam = param;
@@ -42,6 +43,7 @@ private void initMediaCodec() {
4243
if (bitRate > MAX_BITRATE_LENGTH) {
4344
bitRate = MAX_BITRATE_LENGTH;
4445
}
46+
beginBitRate = bitRate;
4547
mediaFormat.setInteger(MediaFormat.KEY_BIT_RATE, bitRate);
4648
//描述视频格式的帧速率(以帧/秒为单位)的键。帧率,一般在15至30之内,太小容易造成视频卡顿。
4749
mediaFormat.setInteger(MediaFormat.KEY_FRAME_RATE, videoEncodeParam.getFrameRate());
@@ -68,10 +70,8 @@ private void initMediaCodec() {
6870
@TargetApi(Build.VERSION_CODES.KITKAT)
6971
public void setVideoBitRate(int bitRate) {
7072
int nowBitrate = videoEncodeParam.getBitRate();
71-
int nowWidth = videoEncodeParam.getWidth();
72-
int nowHeight = videoEncodeParam.getHeight();
7373

74-
if ((bitRate > nowWidth * nowHeight) || (bitRate < 10000) || (nowBitrate == bitRate) || (bitRate > MAX_BITRATE_LENGTH)) {
74+
if ((bitRate > beginBitRate) || (bitRate < 10000) || (nowBitrate == bitRate) || (bitRate > MAX_BITRATE_LENGTH)) {
7575
return;
7676
}
7777

0 commit comments

Comments
 (0)