How to add a video rotation function (when shooting and saving) to my Android application with a camera. Perhaps there are libraries that already have this functionality. I use standart camera my device.
1 Answers
If you mean that you want the user to be able to select the orientation to save the video, then MediaRecorder has a method that allows you to set aa 'hint' to the player so it plays it in the orientation you want:
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.
Its worth noting that this is a hint and players can ignore it - it is not actually changing the video itself when recording it. It is however a common approach - you can see some example code in this answer here: https://stackoverflow.com/a/41311874/334402