[英]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
因此请确保设备分辨率支持这些值。
Try the the CamcorderProfile API. 尝试使用CamcorderProfile API。 Configurations exactly matching one of the ones retrieved from that are likely to work.
与从其中检索到的配置之一完全匹配的配置可能会起作用。
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.