vxh.viet
3/25/2016 - 6:12 AM

Detect orientation of a recorded video in Android

Detect orientation of a recorded video in Android

Source: StackOverflow

Question: How to detect orientation info of video?

Answer: For Api level 17+, 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.d(TAG, "Rotation: " + s);
}