Move MediaFormat creation

For code clarity.

PR #6766 <https://github.com/Genymobile/scrcpy/pull/6766>
This commit is contained in:
Romain Vimont 2026-04-08 19:39:25 +02:00
parent fd6536b34a
commit f54cf8b336

View file

@ -67,6 +67,7 @@ public class SurfaceEncoder implements AsyncProcessor {
private void streamCapture() throws IOException, ConfigurationException {
Codec codec = streamer.getCodec();
MediaCodec mediaCodec = createMediaCodec(codec, encoderName);
MediaFormat format = createFormat(codec.getMimeType(), videoBitRate, maxFps, codecOptions);
MediaCodecInfo.VideoCapabilities caps = mediaCodec.getCodecInfo().getCapabilitiesForType(codec.getMimeType())
.getVideoCapabilities();
@ -77,8 +78,6 @@ public class SurfaceEncoder implements AsyncProcessor {
Ln.d("Actual video size alignment: " + alignment + "px");
}
MediaFormat format = createFormat(codec.getMimeType(), videoBitRate, maxFps, codecOptions);
capture.init(reset, alignment);
try {