Rollback of 2ed1deb52d
*** Original commit *** Apply suggested AVC profile depending on the API version. *** PiperOrigin-RevId: 424856077
This commit is contained in:
parent
ce4a028829
commit
d68b790077
@ -32,7 +32,6 @@ import androidx.media3.common.Format;
|
|||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
import androidx.media3.common.util.MediaFormatUtil;
|
import androidx.media3.common.util.MediaFormatUtil;
|
||||||
import androidx.media3.common.util.TraceUtil;
|
import androidx.media3.common.util.TraceUtil;
|
||||||
import androidx.media3.common.util.Util;
|
|
||||||
import androidx.media3.exoplayer.mediacodec.MediaCodecUtil;
|
import androidx.media3.exoplayer.mediacodec.MediaCodecUtil;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -124,8 +123,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
|
|
||||||
format = getVideoEncoderSupportedFormat(format, allowedMimeTypes);
|
format = getVideoEncoderSupportedFormat(format, allowedMimeTypes);
|
||||||
|
|
||||||
String mimeType = checkNotNull(format.sampleMimeType);
|
MediaFormat mediaFormat =
|
||||||
MediaFormat mediaFormat = MediaFormat.createVideoFormat(mimeType, format.width, format.height);
|
MediaFormat.createVideoFormat(
|
||||||
|
checkNotNull(format.sampleMimeType), format.width, format.height);
|
||||||
mediaFormat.setFloat(MediaFormat.KEY_FRAME_RATE, format.frameRate);
|
mediaFormat.setFloat(MediaFormat.KEY_FRAME_RATE, format.frameRate);
|
||||||
mediaFormat.setInteger(MediaFormat.KEY_BIT_RATE, format.averageBitrate);
|
mediaFormat.setInteger(MediaFormat.KEY_BIT_RATE, format.averageBitrate);
|
||||||
|
|
||||||
@ -138,29 +138,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(b/210593256): Remove overriding profile/level (before API 29) after switching to in-app
|
|
||||||
// muxing.
|
|
||||||
if (mimeType.equals(MimeTypes.VIDEO_H264)) {
|
|
||||||
// Applying suggested profile/level settings from
|
|
||||||
// https://developer.android.com/guide/topics/media/sharing-video#b-frames_and_encoding_profiles
|
|
||||||
if (Util.SDK_INT >= 29) {
|
|
||||||
// Use the highest supported profile and use B-frames.
|
|
||||||
mediaFormat.setInteger(
|
|
||||||
MediaFormat.KEY_PROFILE, MediaCodecInfo.CodecProfileLevel.AVCProfileHigh);
|
|
||||||
mediaFormat.setInteger(MediaFormat.KEY_MAX_B_FRAMES, 1);
|
|
||||||
} else if (Util.SDK_INT >= 26) {
|
|
||||||
// Use the highest-supported profile, but disable the generation of B-frames. This
|
|
||||||
// accommodates some limitations in the MediaMuxer in these system versions.
|
|
||||||
mediaFormat.setInteger(
|
|
||||||
MediaFormat.KEY_PROFILE, MediaCodecInfo.CodecProfileLevel.AVCProfileHigh);
|
|
||||||
mediaFormat.setInteger(MediaFormat.KEY_LATENCY, 1);
|
|
||||||
} else {
|
|
||||||
// Use the baseline profile for safest results.
|
|
||||||
mediaFormat.setInteger(
|
|
||||||
MediaFormat.KEY_PROFILE, MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, DEFAULT_COLOR_FORMAT);
|
mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, DEFAULT_COLOR_FORMAT);
|
||||||
mediaFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, DEFAULT_I_FRAME_INTERVAL_SECS);
|
mediaFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, DEFAULT_I_FRAME_INTERVAL_SECS);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user