My previous answer was not complete.
After more tinkering I found out that many devices can be very sensitive to settings you would think of being default for most devices, but in fact there are many devices that do not behave the way you would expect and they will crash giving you many different error codes that you will not be able to find on the internet. These error codes range from -12, -19, -21 to -100 etc. and most of these error codes can be resolved by using the tips below. I will give a short list of findings below:
The HTC ChaCha running API 10 does not record using the H264 encoder. I got it to work using MP4 and/or H263, however the video still came out totally distorted. The solution to that was setting the camera preview size to 640*480 instead of using google's own "optimal preview" method which returns 576*432. By setting exceptions for this model, I was able to make it record perfectly.
The Galaxy Y running API 10 crashes when trying to record using H264. Made an exception for this one to use MP4 encoder. Fixed it.
The Galaxy Ace running API 10 crashes when trying to record using MP4 returning error code -12. Adding an exception using the H264 encoder for this device model fixes the problem.
The Desire Z running API 10 crashes when trying to record using MP4 encoder. Gave me an error -100 (Media server died). Using H264 fixes the problem.
if(API >=11){
if(CamcorderProfile.hasProfile(mCamId, CamcorderProfile.QUALITY_480P)) {
Log.d(TAG, "API 11+ 480P");
mMediaRecorder.setProfile(CamcorderProfile.get(mCamId, CamcorderProfile.QUALITY_480P));
mMediaRecorder.setVideoSize(640, 480);
mMediaRecorder.setVideoEncodingBitRate(2000000);
} else {
Log.d(TAG, "API 11+ LOW");
mMediaRecorder.setProfile(CamcorderProfile.get(mCamId, CamcorderProfile.QUALITY_LOW));
}
} else if (API < 11 && !MODEL.equals("GT-S5830") && !MODEL.equals("vision")){
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
Log.d(TAG, "API 9 device, defaulting");
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mMediaRecorder.setVideoSize(640, 480);
mMediaRecorder.setVideoEncodingBitRate(2000000);
} else if ((API < 11) && MODEL.equals("GT-S5830") || MODEL.equals("vision")) {
//Galaxy Ace and Desire Z
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mMediaRecorder.setVideoSize(640, 480);
mMediaRecorder.setVideoEncodingBitRate(2000000);
}
I bet I will run into more models being a metaphorical pain in the crack and when I do, I will add them to the list.
To sum up; if you run into these annoying, almost unexplainable error codes, have a look at the MediaRecorder parameters. I advice against using the CamcorderProfile class for any API below 11, since many of these models crash while using a high quality instance of this.
If your recorder video file shows weird green colours, semi-diagonal lines running through your screen, etc, try to set the preview size to match the recorder video size.
Camera.Parameters param = mCamera.getParameters();
param.setPreviewSize(width, height);
mCamera.setParameters( param );