android 上的旋转视频
Rotation video on android
如何将视频旋转功能(拍摄和保存时)添加到我的 Android 带相机的应用程序。
也许有些库已经具有此功能。
我在我的设备上使用标准相机。
如果您的意思是您希望用户能够 select 方向来保存视频,那么 MediaRecorder 有一个方法可以让您设置 aa 'hint' 到播放器,这样它按您想要的方向播放:
setOrientationHint
added in API level 9
public void setOrientationHint (int degrees)
Sets the orientation hint for output video playback. This method should be called before prepare(). This method will not trigger the source video frame to rotate during video recording, but to add a composition matrix containing the rotation angle in the output video if the output format is OutputFormat.THREE_GPP or OutputFormat.MPEG_4 so that a video player can choose the proper orientation for playback. Note that some video players may choose to ignore the compostion matrix in a video during playback.
值得注意的是,这是一个提示,玩家可以忽略它——它实际上并没有在录制视频时改变视频本身。然而,这是一种常见的方法 - 您可以在此处的答案中看到一些示例代码:
如何将视频旋转功能(拍摄和保存时)添加到我的 Android 带相机的应用程序。 也许有些库已经具有此功能。 我在我的设备上使用标准相机。
如果您的意思是您希望用户能够 select 方向来保存视频,那么 MediaRecorder 有一个方法可以让您设置 aa 'hint' 到播放器,这样它按您想要的方向播放:
setOrientationHint
added in API level 9 public void setOrientationHint (int degrees) Sets the orientation hint for output video playback. This method should be called before prepare(). This method will not trigger the source video frame to rotate during video recording, but to add a composition matrix containing the rotation angle in the output video if the output format is OutputFormat.THREE_GPP or OutputFormat.MPEG_4 so that a video player can choose the proper orientation for playback. Note that some video players may choose to ignore the compostion matrix in a video during playback.
值得注意的是,这是一个提示,玩家可以忽略它——它实际上并没有在录制视频时改变视频本身。然而,这是一种常见的方法 - 您可以在此处的答案中看到一些示例代码: