在Android上可播放的最大视频分辨率

编程入门 行业动态 更新时间:2024-10-25 22:37:35
本文介绍了在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上可播放的最大视频分辨率

本文发布于:2023-10-04 02:13:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1467101.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可播放   分辨率   视频   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!