MediaRecorder video/audio recording

by Maurizio Bellemo » Thu, 06 Aug 2009 17:25:38 GMT


Sponsored Links
 i all,

I'm trying to create an application to save video recording on a file
in Android. The problem is that only for audio recording, it's fine,
but when I try to add the video part the prepare() fails. Below the
code....

public classTest extends Activity {
MediaRecorder mr;
File audiofile = null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Configuring audio/video access
try {
setStreaming();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

mr.stop();
mr.reset();
mr.release();
processaudiofile();
}

@Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();

// Configuring audio/video access
try {
setStreaming();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Starting the MediaRecorder
mr.start();
}

// @Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();

// Starting the MediaRecorder
mr.start();
}

@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();

// Stopping MediaRecorder
mr.stop();
mr.reset();
mr.release();
processaudiofile();
}

private void setStreaming() throws IOException {
// Creating a MediaRecorder object
mr = new MediaRecorder();
// Configuring audio/video source (MIC and camera)
mr.setAudioSource(MediaRecorder.AudioSource.MIC);
//mr.setCamera(Camera.open());
mr.setVideoSource(MediaRecorder.VideoSource.DEFAULT);

// Configuring the output format
mr.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
// Configuring audio/video codecs
mr.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mr.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
// Setting the output file
if (audiofile == null) {
File sampleDir = Environment.getExternalStorageDirectory();
try
{
audiofile = File.createTempFile("moca", ".mp4", sampleDir);
}
catch (IOException e)
{
Log.e("ERROR","sdcard access error");
return;
}
}
mr.setOutputFile(audiofile.getAbsolutePath());
// the recorder is ready to register

mr.prepare();
mr.start();
}

protected void processaudiofile() {
ContentValues values = new ContentValu



Other Threads

1. GPS low signal

Hi everyone.
I have a doubt I have been trying to solve since several days but
still giving me troubles.

Is there a way to detect when the GPS has lost signal (when I drive
through a tunnel for example)?
I tried to use te onStatusChanged listener because I thought that the
"temporarily unavailable" status was associated to a lack of signal
but it doesnt seem to work well.

I also tried to make a count with low preccison locations rounds to
trigger but it also fails.

Anyone knows any solution?

Thanks in advance and sorry for my bad english.

-- 

2. LinearLayout stack overflow, fails on 1.5, ok on 1.6?

That would be expected on 1.5 if you have too many views in your UI.



> 

3. About openConverter of icu

4. ACTION_POINTER_DOWN

5. opengl crash after pause/unpause app

6. LinearLayout stack overflow, fails on 1.5, ok on 1.6?

7. LinearLayout stack overflow, fails on 1.5, ok on 1.6?