-1

I used code from here. But there is one problem, I can´t change camera orientation. Final video is upside down.

I tried to change it by this (I tried all possible values - 0,90,180,270):

    camera.setDisplayOrientation(90);
    camera.getParameters().setRotation(90);

or

    camera.getParameters().set("orientation", "portrait");
    camera.getParameters().set("rotation", 90);

But nothing works. Any idea how to setup it? I tested it on Nexus 5X with Android 7.1.1. I want to use fixed orientation, no matter how I hold device, orientation must remain same.

Community
  • 1
  • 1
Michal
  • 2,071
  • 19
  • 30

2 Answers2

0

camera.setDisplayOrientation(90) This affects the preview frames and the picture displayed after snapshot. This does not affect the order of byte array passed in onPreviewFrame, JPEG pictures, or recorded videos. So you can't change the REC orientation using this API. If you want to change the REC orientation, you should rotate the every frame date in onPreviewFrame or rotate the SurfaceTexture base on the way you record video.

Yua
  • 23
  • 8
  • I tried to do this "surfaceView.setRotation(90);", but without any change. This should do it, right? – Michal Jan 29 '17 at 19:56
0

use mediaRecorder.setOrientationHint(180);

  • 2
    Hi, and welcome to Stack Overflow! While this may solve the problem, we generally think answers on Stack Overflow should additionally include an English explanation of *why* or *how* the code solves the problem. Could you explain why this works? – Max von Hippel May 30 '18 at 16:03