Android camera and preview orientation - how to split

I just played through the android camera tutorial . the problem is orientation. the recorded videos are in the wrong orientation if I start in portrait mode. In my case, I changed the preview layout a bit - now it has a wrong / arbitrary aspect, but the recorded videos also have the same (wrong) aspect ratio !?

Why and how are previews and actual recordings related? is there any way to separate it: the recorded video should only record what the camera provides.

So, how to create a camera application that ignores the orientation when recording (or uses the orientation only for saving in metadata), but reflects it in the preview (do nothing - the portrait becomes a landscape, turning the phone). are there any examples of camera applications with proper rotation processing?

+1
source share
2 answers

If you want to record video on Android with a different default orientation, you need to use the MediaRecorder setOrientationHint method .

( setDisplayOrientation ) , , .

, Camera setDisplayOrientation, , Media Recorder setOrientation, .

Android , AOSP, .

+3
            mSession = SessionBuilder.getInstance()
                .setContext(getApplicationContext())
                .setAudioEncoder(SessionBuilder.AUDIO_AAC)
                .setAudioQuality(new AudioQuality(8000, 16000))             
                .setVideoEncoder(SessionBuilder.VIDEO_H264)
                .setSurfaceView(mSurfaceView).setPreviewOrientation(90)
                .setCallback(this).build();
0

Source: https://habr.com/ru/post/1588993/


All Articles