Skip to content

Commit 69d2a4c

Browse files
committed
试验性开启B帧
1 parent 3061e7b commit 69d2a4c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

app/src/main/java/com/demo/mediacodec/MediaCodecUtils.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,12 @@ public static MediaFormat createOutputFormat(@NonNull Context ctx, @NonNull Uri
209209
outputFormat.setFloat("max-fps-to-encoder", config.fps);
210210
}
211211
outputFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 1);
212+
213+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
214+
//FIXME 开启B帧,能够一定程度提高清晰度,但不是所有设备都支持B帧,可能会因此报错。
215+
outputFormat.setInteger(MediaFormat.KEY_MAX_B_FRAMES, 2);
216+
}
217+
212218
if (Build.VERSION.SDK_INT > 23 && isH265) {
213219
//不去生成H264的HDR视频
214220
//设置Color相关参数,使其尽量保证HDR视频转码后仍然是HDR视频

0 commit comments

Comments
 (0)