在Android上可播放的最大视频分辨率 [英] Maximum playable video resolution on Android

查看:1236
本文介绍了在Android上可播放的最大视频分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以提取Android可以播放的最大视频分辨率?我们有从相机下载的MP4文件,我想在播放之前向用户显示一些错误.因为如果分辨率太高,Android只会给您黑屏.

Is there a way to extract the maximum video resolution Android can play? We have MP4 files we download from the camera and I would like to show some error to the user before playing. Because if the resolution is too high, Android will just give you a black screen.

我尝试使用便携式摄像机配置文件,但是即使在可以处理更高分辨率的设备(例如Galaxy S5)上,这大部分时间都可以给我提供1920x1080的分辨率.

I tried using the camcorder profile, but this one is giving me most of the time 1920x1080 even on devices that can handle higher resolutions such as the Galaxy S5.

 CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);

我们非常感谢您的帮助!

Any help is really appreciated!

推荐答案

好的,

在Android Lollipop上

on Android Lollipop

您可以使用此

MediaCodecInfo.VideoCapabilities.areSizeAndRateSupported(int width, int height, double frameRate)

返回是否支持给定视频size (width and height)frameRate组合.

which returns whether a given video size (width and height) and frameRate combination is supported.

在Android上<棒棒糖

On Android < Lollipop

您只需检查支持哪些AVC编解码器级别,即可得出最大支持的分辨率,不幸的是,这对于大多数设备而言都不正确.例如,在Nexus 5上,Android将返回AVC配置文件级别4,这表示您可以播放1920x1080视频.但是,Nexus 5已经可以播放更高分辨率的视频,因此不可靠.

you can just check which AVC codec levels are supported, so you could derive the maximum supported resolution, which unfortunately is not correct for most of the devices. For example, on the Nexus 5, Android will return AVC profile level 4 which would mean that you can playback 1920x1080 videos. However, the Nexus 5 is capable of playing higher resolution videos already, so it is not reliable.

仅适用于Android的解决方法<到目前为止5项:尝试播放视频并检查是否有错误. HTC或其他设备也是如此.结果,在某些设备上,每2秒左右您将获得大约1帧.

Only workaround on Android < 5 so far: Try to play the video and check for any errors. That's what HTC or other devices do as well. As a result it can happen that on some devices you will get about 1 frame each 2 seconds or so.

这篇关于在Android上可播放的最大视频分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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