Вопрос

I want to use Android_4.1 MediaCodec API to encode video data which captured from Camera,then decode the video data and show the video on TextureView. Now everything is OK,but the TextureView could not show the decoded video in correct oritentation. Please look at these two pictures.

1.Figure1

enter image description here

2.Figure2

enter image description here

TextureView in figure1 shows What I want orientation.This TextureView called setRotation(90).But it does not alwalys work.If I set this TextureView "match_parent/fill_parent/full_screen",and also setRotation(90),it does not work.

Here is my Camera's parameters:

    mCamera.setDisplayOrientation(90);
    Parameters parameters = mCamera.getParameters();
    parameters.setPreviewFormat(ImageFormat.NV21);
    parameters.setPreviewSize(640, 480);
    mCamera.setParameters(parameters);
    getSupportedCameraParams();

I have tried to set the TextureView's width = screenHeight and height = screenWidth, also I have tried to set parameters.setPreviewSize(480, 640) ,but they do not work.

My question is how I should do to make the fullscreen TextureView to show the video in correct orientation ?

I'm not good at English,I hope you can understand me.

Any help would be appreciated.Thank you!

Это было полезно?

Решение

try adding this lines after you setDisplayOrientation to force TextureView to be re-renderred.

mTextureView.requestLayout();
mTextureView.invalidate();

It helped me when I was trying to show cropped video, and it did not crop it sometimes when display orientation changed.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top