I want to make my custom media player and requires orientation info of video (for detecting it is recorded from front or back camera). for jpeg images i can use ExifInterface.TAG_ORIENTATION
but for video how i can find this information.
I tried to grab frame from video file and convert it into jpeg but again it always provides orientation 0
in all cases.
Please help me. Thanks in advance.
int orientation = display. getOrientation(); Check orientation as your way and use this to change orientation: setRequestedOrientation (ActivityInfo.
Open Google Photos on your Android phone and tap the search bar. Choose Videos, then select the video you want to rotate. Tap the slider bar icon (it's at the bottom of the screen in the middle). Select Rotate until the video is oriented the way you want it.
This usually happens if you're holding the phone in a way that's not firmly in landscape mode, like if you point the phone down. It can also happen if you open the camera app and start recording before it can change orientation. On other occasions, you may rotate your phone while recording a video.
To rotate a video on Android using a third-party app:Tap Create New Project. Select a video to edit and then tap Create. In the editing menu, scroll through the options at the bottom and tap Transform. Tap the Rotation option.
Api level 17 later, we can extract the orientation of video: MediaMetadataRetriever
MediaMetadataRetriever m = new MediaMetadataRetriever();
m.setDataSource(path);
Bitmap thumbnail = m.getFrameAtTime();
//
if (Build.VERSION.SDK_INT >= 17) {
String s = m.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION);
Log.e("Rotation", s);
}
FFmpegMediaMetadataRetriever can do this and it works with API 7+:
FFmpegMediaMetadataRetriever fmmr = new FFmpegMediaMetadataRetriever();
fmmr.setDataSource(path);
String rotation = fmmr.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION);
Log.e("Rotation", rotation);
fmmr.release();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With