是否有可能得到的Andr​​oid视频的分辨率是多少? [英] Is it possible to get the resolution of a video in Android?

查看:96
本文介绍了是否有可能得到的Andr​​oid视频的分辨率是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一种方式来获得在Android的任何视频的分辨率。它没有与其他格式相比,Android的支持的那些工作,但如果没有这将会是巨大的。如果你不确定在Android上支持的格式,请参阅本页面:

I'm looking for a way to get the resolution of any given video in Android. It doesn't have to work with other formats than the ones supported in Android, but it'd be great if it did. If you're unsure of the supported formats in Android, please refer to this page:

<一个href="http://developer.android.com/guide/appendix/media-formats.html">http://developer.android.com/guide/appendix/media-formats.html

我认为这是可能的,我想用的是什么的MediaPlayer 类的事,但是,似乎令人难以置信的愚蠢,效率低下。另外,我想一种方式,是的相对的快。

I think it's possible to do what I want using the MediaPlayer class, but that seems incredibly stupid and inefficient. Also, I'd like a way that's relatively fast.

我针对安卓3.0+,如果有什么差别。蜂窝也支持的.mkv文件,尽管它不是正式支持到Android 4.0的。

I'm targeting Android 3.0+, if that makes any difference. Honeycomb also supports .mkv files, although it's not officially supported until Android 4.0.

推荐答案

您可以使用<一个href="http://developer.android.com/reference/android/media/MediaMetadataRetriever.html">MediaMetadataRetriever检索有关视频文件分辨率的信息。你会使用<一个href="http://developer.android.com/reference/android/media/MediaMetadataRetriever.html#extractMetadata%28int%29">extractMetadata()方法和使用 METADATA_KEY_VIDEO_HEIGHT METADATA_KEY_VIDEO_WIDTH 常数。所以,你会做这样的事情:

You can use the MediaMetadataRetriever to retrieve resolution information about a video file. You'd use the extractMetadata() method and using the METADATA_KEY_VIDEO_HEIGHT and METADATA_KEY_VIDEO_WIDTH constants. So you'd do something like this:

MediaMetadataRetriever metaRetriever = new MediaMetadataRetriever();
metaRetriever.setDataSource(/* file descriptor or file path goes here */);
String height = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);
String width = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);

这篇关于是否有可能得到的Andr​​oid视频的分辨率是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆