Created
March 25, 2014 02:25
-
-
Save xalexchen/9754193 to your computer and use it in GitHub Desktop.
calculateVideoSize From https://github.com/dmytrodanylyk/dmytrodanylyk/blob/gh-pages/articles/surface-view-video-cropping.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void calculateVideoSize() { | |
try { | |
AssetFileDescriptor afd = getAssets().openFd(FILE_NAME); | |
MediaMetadataRetriever metaRetriever = new MediaMetadataRetriever(); | |
metaRetriever.setDataSource( | |
afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); | |
String height = metaRetriever | |
.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT); | |
String width = metaRetriever | |
.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH); | |
mVideoHeight = Float.parseFloat(height); | |
mVideoWidth = Float.parseFloat(width); | |
} catch (IOException e) { | |
Log.d(TAG, e.getMessage()); | |
} catch (NumberFormatException e) { | |
Log.d(TAG, e.getMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment