Skip to content

Instantly share code, notes, and snippets.

@vxhviet
Last active March 25, 2016 06:17
Show Gist options
  • Save vxhviet/ed2ec00539d702ee1001 to your computer and use it in GitHub Desktop.
Save vxhviet/ed2ec00539d702ee1001 to your computer and use it in GitHub Desktop.
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment