问题
I am rendering an Mpeg4/avc video on android using the MediaCodec (and MediaMuxer).
I'm testing on both LG Nexus 4 & Samsung Galaxy 5.
On samsung, the rendered video looks as expected for both 640x640 and 480x480 frame size.
BUT, on the Nexus, 480x480 generates a bad looking video, while the 640x640 generates a good video.
Quesion is: what is the reason? is this a bug or a "feature" I am not aware of.
Is there a well-known frame size we can rely on being rendered correcly on all Android Device? Or do we need to test on various devices?
回答1:
Regarding " well-known frame size" - google ask for device vendors to satisfy requirements - http://source.android.com/compatibility/index.html, doc is here: http://static.googleusercontent.com/media/source.android.com/en//compatibility/android-cdd.pdf It has codecs section 5 (5.2 and 5.3 for exact values)where you can find codecs related reqs. To check it google provides CTS tests which covers all required resolution. So the advice is to stick to resolutions from this doc and covered by CTS tests
回答2:
With Lollipop Google added an API to query the video properties of the encoder. See http://developer.android.com/reference/android/media/MediaCodecInfo.VideoCapabilities.html
Here is an example for enumerating the capabilities of the H.264 encoders available:
for(MediaCodecInfo codecInfo : new MediaCodecList(MediaCodecList.ALL_CODECS).getCodecInfos()){
if(!codecInfo.isEncoder())
continue;
String[] types = codecInfo.getSupportedTypes();
for(int j=0;j<types.length;j++){
if("video/avc".equalsIgnoreCase(types[j])){
MediaCodecInfo.CodecCapabilities codecCaps = codecInfo.getCapabilitiesForType("video/avc");
MediaCodecInfo.VideoCapabilities vidCaps = codecCaps.getVideoCapabilities();
Range<Integer> framerates = vidCaps.getSupportedFrameRates();
Range<Integer> widths = vidCaps.getSupportedWidths();
Range<Integer> heights = vidCaps.getSupportedHeights();
Log.d("H.264Encoder", "Found encoder with\n" + widths.toString()
+ " x " + heights.toString() + " @ " + framerates.toString() + " fps aligned to " + vidCaps.getWidthAlignment());
}
}
}
来源:https://stackoverflow.com/questions/24490578/android-mediacodec-bad-video-generated-on-nexus-for-480x480-while-640x640-work