Skip to content

Instantly share code, notes, and snippets.

@xalexchen
Created March 25, 2014 02:25
Show Gist options
  • Save xalexchen/9754193 to your computer and use it in GitHub Desktop.
Save xalexchen/9754193 to your computer and use it in GitHub Desktop.
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