setOrientationHint旋转视频逆时针一些手机的前置摄像头(HTC)逆时针、摄像头、手机、视频

2023-09-06 02:28:16 作者:毁花能手.

的问题:某些Android设备(列在问题的底部)利用 setOrientationHint(INT度)功能,当出现意外行为对于视频的前置摄像头拍摄。预期的行为是为视频顺时针旋转,但这些设备逆时针旋转视频。

The Problem: Certain Android devices (listed at the bottom of the question) exhibit unexpected behavior when utilizing the setOrientationHint(int degrees) function for videos taken with the front facing camera. The expected behavior is for the video to be rotated clockwise, but these devices rotate the video counterclockwise.

我的目标:可在任一摄像机设置或硬件的方向,让我predictably知道什么时候会发生这种识别的变量。具体而言,我想避免特殊外壳这些手机在我的code!的

My Goal: To identify a variable within either the camera settings or hardware orientations that allows me to predictably know when this will occur. Specifically, I would like to avoid special casing these phones in my code!

新解:我使用的是标准的 MediaRecorder 对象录制视频,并在preparing记录,我设定的方向使用视频 setOrientationHint() 。在对 setOrientationHint的文档(),被指定为度以下参数:

Further Explanation: I am recording video using the standard MediaRecorder object, and in preparing for recording, I set the orientation of the video using setOrientationHint(). In the documentation for setOrientationHint(), the following is specified for the degrees parameter:

度的 - 的角度,以顺时针方向旋转。支持的角度   0,90,180,270。

degrees –– the angle to be rotated clockwise in degrees. The supported angles are 0, 90, 180, and 270.

的功能意在添加含的旋转角度的组合物基质,使得视频播放器可以显示视频的意图。所以,我做的是我开始使用摄像头硬件的方向 CameraInfo 类,并用其作为 setOrientationHint FN。 (我曾尝试变化上使用AOSP为指导,这code,但我有相同的结果。)

The function is intended to add a composition matrix containing the rotation angle so that a video player can display the video as intended. So, what I do is that I get the camera hardware's orientation using the CameraInfo class and use that as the degrees parameter in the setOrientationHint fn. (I have tried variation on this code using the AOSP as a guide, but I had the exact same result.)

一个真实的例子:三星Galaxy S3的前置摄像头(和大多数人,其实)将有270硬件的方向,所以我用这个记录时,所得视频正确显示。一个HTC生动同样会返回270硬件取向相同的摄像头,但只有当我用90作为度正确显示在 setOrientationHint FN。如果我使用的硬件方向的270像任何其他电话,视频将是本末倒置。

A Real Example: The Samsung Galaxy S3 front-facing camera (and most others, in fact) will have a hardware orientation of 270, so I use this when recording, and the resulting video is displayed correctly. An HTC Vivid will similarly return a hardware orientation of 270 for the same camera, but will only be displayed correctly if I use 90 as the degrees parameter in the setOrientationHint fn. If I use the 270 of the hardware orientation like any other phone, the video will be upside down.

注:的 setOrientationHint()功能包括一个警告:

NB: The setOrientationHint() function includes a warning:

请注意,某些视频播放器可以选择忽略compostion   播放期间矩阵中的影片。

Note that some video players may choose to ignore the compostion matrix in a video during playback.

不过,这是的没有的正在发生的事情,因为我可以很容易地在这些手机如果我假的解决这个问题,并把90改为270。

However, this is not what is happening, because I can easily fix this issue on these phones if I fake it and put in 90 instead of 270.

,我已经看到具体出现此问题的电话: HTC生动(PH39100)运行Android 4.0.3,HTC EVO 4G(PG86100),运行Android 4.0.3,HTC霹雳(ADR6400L)运行Android 2.3.4。请注意,他们都是HTC手机。也许有人在HTC误以为顺时针逆时针。

Phones that I have seen specifically exhibit this issue: HTC Vivid (PH39100) running Android 4.0.3, HTC EVO 4G (PG86100) running Android 4.0.3, HTC Thunderbolt (ADR6400L) running Android 2.3.4. Notice that they are all HTC phones. Perhaps someone at HTC mistook clockwise for counterclockwise.

推荐答案

是的,HTC手机转错方向的摄影机前。而不是试图去猜测,我最终加入了设置屏幕,将采取两个画面与第二个旋转90度。然后,用户可以继续打接下来,我通过不同的旋转方向和角度的组合循环,直到两个画面出现了面向相同的方式。

Yes, the HTC phones rotate in the wrong direction for the front facing cameras. Instead of trying to guess, I ended up adding a settings screen that would take two pictures with the second one rotating 90 degrees. Then the user could keep hitting next as I cycled through the different rotation direction and angle combinations until both pictures appeared oriented the same way.