简体   繁体   English

Android 4.1 MediaCodec支持的分辨率

[英]Android 4.1 MediaCodec supported resolutions

I'm trying to get Android 4.1's new low-level media-features to work for H.264 encoding on an Asus Transformer TF300T tablet. 我正在尝试让Android 4.1的新低级媒体功能在Asus Transformer TF300T平板电脑上支持H.264编码。 I'm experiencing some strange behavior when I try to increase the resolution of the codec: 尝试提高编解码器的分辨率时,我遇到一些奇怪的行为:

        MediaFormat mediaFormat = MediaFormat.
                                createVideoFormat("video/mp4v-es", 320, 240); // WORKS
//      MediaFormat mediaFormat = MediaFormat.
//                              createVideoFormat("video/mp4v-es", 640, 480); // DOESN'T WORK

        mediaFormat.setInteger(MediaFormat.KEY_BIT_RATE, 125000);
        mediaFormat.setInteger(MediaFormat.KEY_FRAME_RATE, 25);
        mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar);
        mediaFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 5);
        mediaCodec.configure(mediaFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
        mediaCodec.start();

In the latter case, I'm getting a IllegalStateException when calling mediaCodec.getInputBuffers(); 在后一种情况下,调用mediaCodec.getInputBuffers();时出现IllegalStateException mediaCodec.getInputBuffers(); . Anyone who has any explanation (or even better: a fix)? 任何有任何解释(或更妙的是:修复)的人吗?

Thanks in advance! 提前致谢!

Please checkout below link : 请在以下链接结帐:

http://developer.android.com/guide/appendix/media-formats.html http://developer.android.com/guide/appendix/media-formats.html

Check the section "Video Encoding Recommendations". 检查“视频编码建议”部分。 The values are in pixels so make sure that the values are supported by the device resolution. 值以pixels因此请确保设备分辨率支持这些值。

  1. Try the the CamcorderProfile API. 尝试使用CamcorderProfile API。 Configurations exactly matching one of the ones retrieved from that are likely to work. 与从其中检索到的配置之一完全匹配的配置可能会起作用。

  2. Clearly in your case there is some combination of resolution and other parameters that makes it not work. 显然,您的情况是分辨率和其他参数的某种组合,使它无法正常工作。 I wonder if it is the framerate? 我想知道是否是帧率? 25 is a bit odd, try 29.97 or 30, or maybe 15. I also wonder if it is the bitrate? 25有点奇怪,请尝试29.97或30,或者也许是15。我也想知道这是否是比特率? It is is much too low for the resolution, try 500kbit/s. 分辨率太低,请尝试500kbit / s。

I had the same issues, when I worked with MediaRecorder. 与MediaRecorder合作时,我遇到了同样的问题。

You can try to use CamcorderProfile, but from my experience, it doesn't guarantee stable work. 您可以尝试使用CamcorderProfile,但是根据我的经验,它不能保证稳定的工作。 Also in Android 2.* you can have only two profiles of CamcorderProfile. 同样在Android 2. *中,您只能有两个CamcorderProfile配置文件。

These settings are device specific, and you can obtain the best for wide range of devices in experimental way. 这些设置是特定于设备的,您可以通过实验方式获得适用于各种设备的最佳设置。

EDIT: Also you can use H.263 instead of H.264, for your case it should work. 编辑:您也可以使用H.263而不是H.264,因为您的情况应该可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android MediaCodec HEVC支持的解决方案 - Android MediaCodec HEVC Supported Resolutions 如何获取Android 4.1和4.2上MediaCodec支持的colorFormats? - How to get the colorFormats supported by MediaCodec on android 4.1 and 4.2? 在Jelly Bean MR2下找到MediaCodec支持的视频编码分辨率 - Find the MediaCodec supported video encoding resolutions under Jelly Bean MR2 在Android 4.1 / 4.2设备中将MediaCodec.getOutputFormat()用于编码器的问题 - Problems of using MediaCodec.getOutputFormat() for an encoder in Android 4.1/4.2 devices 如何在Android中获得支持的摄像头分辨率? - How to get supported video camera resolutions in android? 保证Android MediaCodec API支持哪些视频编码器? - Which video encoders are guaranteed to be supported by android MediaCodec API? 如何统一为Android游戏定义支持的屏幕分辨率? - How to define supported screen resolutions for an android game in unity? 是否可以在Android4.1(API 16)上使用MediaCodec解码原始AAC字节流? - Is it impossible to Decode Raw AAC byte stream with MediaCodec on Android4.1 (API 16)? Android MediaCodec:多个 SurfaceView 上支持多少个同时(视频)解码线程? - Android MediaCodec: How many simultaneous (video) decoding threads are supported on multiple SurfaceViews? MediaCodec API android中的timeUs - timeoutUs in MediaCodec API android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM