[英]Orientation Issue while video recording in Portrait Mode android grafika
I set the device Orientation Landscape
mode then it saves the video perfectly. 我设置了设备“定向
Landscape
模式,然后完美保存了视频。 if I capture a video with both sides. 如果我拍摄双方的视频。
But I set the device orientation Portrait
Mode this work weird. 但是我将设备方向设置为
Portrait
模式这一工作很奇怪。
For Example: 例如:
Below Screenshot while i Recording video : 在我录制视频时的屏幕截图下方:
But when i save the video and see in MXPlayer then it's look like this: 但是,当我保存视频并在MXPlayer中观看时,它看起来像这样:
I use below code : 我使用以下代码:
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
if (display.getRotation() == Surface.ROTATION_0) {
mCamera.setDisplayOrientation(90);
// layout.setAspectRatio((double) cameraPreviewSize.height / cameraPreviewSize.width);
} else if (display.getRotation() == Surface.ROTATION_270) {
// layout.setAspectRatio((double) cameraPreviewSize.height / cameraPreviewSize.width);
mCamera.setDisplayOrientation(180);
} else {
// Set the preview aspect ratio.
//layout.setAspectRatio((double) cameraPreviewSize.width / cameraPreviewSize.height);
}
Also i try to add setOrientationHint where i start the MediaMuxer
我也尝试在启动
MediaMuxer
地方添加setOrientationHint
Finally after 2 day i solve my problem. 终于两天后,我解决了我的问题。
Grafika
ContinuousCaptureActivity.java
Grafika
ContinuousCaptureActivity.java
此解决方案 In drawFrame()
Method i'll change some code for portrait
. 在
drawFrame()
方法中,我将为portrait
更改一些代码。
I add below 2 line in drawFrame
method: 我在
drawFrame
方法中添加以下2行:
Matrix.rotateM(mTmpMatrix, 0, 270, 0, 0, 1);
Matrix.translateM(mTmpMatrix, 0, -1, 0, 0);
In drawFrame
Method 2 type to set the glViewport
在
drawFrame
方法2中,键入以设置glViewport
SurfaceView
with it . SurfaceView
。 (it means this orientation change while user recording a video) So i'll be change in 2nd opetion 所以我会第二次改变
Please find full code at below : 请在下面找到完整的代码:
// Send it to the video encoder.
if (!mFileSaveInProgress) {
mEncoderSurface.makeCurrent();
if (!AppSetting.getValue(activity, Config.ORIENTATION, "").equalsIgnoreCase("Select")) {
if (AppSetting.getValue(activity, Config.ORIENTATION, "").equalsIgnoreCase("Portrait")) {
Matrix.rotateM(mTmpMatrix, 0, 270, 0, 0, 1);
Matrix.translateM(mTmpMatrix, 0, -1, 0, 0);
}
}
GLES20.glViewport(0, 0, VIDEO_WIDTH, VIDEO_HEIGHT);
mFullFrameBlit.drawFrame(mTextureId, mTmpMatrix);
//drawExtra(mFrameNum, VIDEO_WIDTH, VIDEO_HEIGHT);
mCircEncoder.frameAvailableSoon();
mEncoderSurface.setPresentationTime(mCameraTexture.getTimestamp());
mEncoderSurface.swapBuffers();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.