MediaRecorder.stop() stop failed: -1007

Quoting the documentation of "stop" method in MediaRecorder.java in 4.0.3:

Stops recording. Call this after start(). Once recording is stopped, you will have to configure it again as if it has just been constructed. Note that a RuntimeException is intentionally thrown to the application, if no valid audio/video data has been received when stop() is called. This happens if stop() is called immediately after start(). The failure lets the application take action accordingly to clean up the output file (delete the output file, for instance), since the output file is not properly constructed when this happens.

And the fact that MediaPlayer is reporting this "media server died" is due to the same reason. Can you post the rest of your code to see if there's any misconception that may cause this issue?


Solved it at last. The issue was setting the preview size before setting the actual preview for the camera. The preview size MUST be equal to the selected video size.

CamcorderProfile profile = [get required profile];

Camera.Parameters parameters = mCamera.getParameters();
parameters.setPreviewSize(profile.videoFrameWidth,profile.videoFrameHeight);
mCamera.setParameters(parameters);

mCamera.setPreviewDisplay([surface holder]);
mCamera.startPreview();

...

//configure MediaRecorder and call MediaRecorder.start()