I want to record video only in android with MPEG4 format. I want the container and codec to be MPEG4. So here is what I did for this.
Thread video = new Thread(new Runnable() { public void run() { videoRecorder = new MediaRecorder(); videoRecorder.setPreviewDisplay(surfaceView.getHolder().getSurface()); videoRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT); videoRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); videoRecorder.setVideoEncodingBitRate(56 * 8 * 1024); videoRecorder.setVideoSize(176, 144); videoRecorder.setVideoFrameRate(12); videoRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP); videoRecorder.setOutputFile("/sdcard/video.m4e"); try { videoRecorder.prepare(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } videoRecorder.start(); } }); video.start();
Now, after recording, I got the video recorded in the video.m4e
file. But when I check his information, I got the following:
At the same time, I used the following to record sound:
Thread audio = new Thread(new Runnable() { public void run() { audioRecorder = new MediaRecorder(); audioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); audioRecorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR); audioRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); audioRecorder.setOutputFile("/sdcard/audio.amr"); try { audioRecorder.prepare(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } audioRecorder.start(); } }); audio.start();
and I got the container format and codec as AMR, as I assumed:
So what makes MediaRecorder
record video in 3GP format? I did not specify 3GP anywhere in my program. I am testing this code on a Samsung Galaxy tab running Android 2.2
source share