Firstly, please forgive it is already asked one or can be find easily with Google. I am posting this since I do have only limited time. Here is code to record audio and video.
stopPreview();
Log.d("streamer", "Start camera.....");
videoRecorder = new MediaRecorder();
videoRecorder.setPreviewDisplay(surfaceView.getHolder()
.getSurface());
videoRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
videoRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
videoRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
videoRecorder.setVideoSize(800, 600);
videoRecorder.setVideoFrameRate(30);
videoRecorder.setOutputFile(videoPipe.getOutput());
videoRecorder.prepare();
videoRecorder.start();
Log.d("streamer", "Start camera.....action.......");
Log.d("streamer", "Start mic.....");
audioRecorder = new MediaRecorder();
audioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
audioRecorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
audioRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
audioRecorder.setOutputFile(audioPipe.getOutput());
audioRecorder.prepare();
audioRecorder.start();
Log.d("streamer", "Start mic.....action");
But, when I run it, the above code produces the following on logcat.
12-22 09:05:43.456: E/CameraInput(2407): Unsupported parameter(x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value)
12-22 09:05:43.456: E/CameraInput(2407): VerifiyAndSetParameter failed on parameter #0
.....
12-22 09:05:43.456: E/CameraInput(2407): VerifiyAndSetParameter failed on parameter #0
12-22 09:05:43.464: E/MediaProfiles(2407): mCodec : 2
12-22 09:05:43.464: E/MediaProfiles(2407): mCodec : 1
12-22 09:05:43.464: E/MediaProfiles(2407): mCodec : 3
And, the surface view showing preview seems to be freezed. It shows last taken frame of image. Also, the video & audio doesn’t seems to be recording. What will be the problem? Any help is very much appreciated!
NOTE:
I am trying this on Samsung Galaxy Tab with Android 2.2.
Commenting the following two lines also doesn’t seems to solve the problem
videoRecorder.setVideoSize(800, 600);
videoRecorder.setVideoFrameRate(30);
The following permissions are set on the manifest file.
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
If you see the Supported Media Formats, for MPEG-4 SP, you need to use 3GP (
THREE_GPP) output format.So you can try with