mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Round the frame rate in MediaFormat
Although MediaCodec claims supporting float frame rate, encoder init failed on
API21 Nexus 5. Since it's just a performance hint to the codec, it's OK to
generalize it to other API versions.
PiperOrigin-RevId: 458434650
(cherry picked from commit 1f47fa832c)
This commit is contained in:
parent
8b0fe16821
commit
f2b4701e92
1 changed files with 2 additions and 1 deletions
|
|
@ -23,6 +23,7 @@ import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
|||
import static androidx.media3.common.util.Util.SDK_INT;
|
||||
import static java.lang.Math.abs;
|
||||
import static java.lang.Math.floor;
|
||||
import static java.lang.Math.round;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.MediaCodecInfo;
|
||||
|
|
@ -231,7 +232,7 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory {
|
|||
|
||||
String mimeType = checkNotNull(format.sampleMimeType);
|
||||
MediaFormat mediaFormat = MediaFormat.createVideoFormat(mimeType, format.width, format.height);
|
||||
mediaFormat.setFloat(MediaFormat.KEY_FRAME_RATE, format.frameRate);
|
||||
mediaFormat.setInteger(MediaFormat.KEY_FRAME_RATE, round(format.frameRate));
|
||||
mediaFormat.setInteger(
|
||||
MediaFormat.KEY_BIT_RATE,
|
||||
supportedVideoEncoderSettings.bitrate != VideoEncoderSettings.NO_VALUE
|
||||
|
|
|
|||
Loading…
Reference in a new issue