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. Can somebody explain how does the open core handle the selection between OPENMAX method and PV's own method?

It's exactly as Andrew described it. There are two codec registries,
one for vendor supplied codecs and one for OpenCore software codecs.
If it is unable to find a vendor codec that satisfies the input/output
requirements, it falls back to OpenCore software codec. The reason for
that is that you may need multiple instances of a codec at the same
time. If there are no vendor codecs, then there is only one registry.

Example: Imagine you are playing MP3 in the background and the user's
selected ringtone is an MP3 file. While the music is playing, the
phone rings. The MP3 player is probably using the hardware codec (it
usually consumes less power than software codec), so when the ringtone
starts up, the PV framework instantiates a software codec instead.





--~--~---------~--~----~------------~-------~--~----~
unsubscribe: [EMAIL PROTECTED]
website: 

2. Little sum...

http://tech.yahoo.com/news/pcworld/20081210/tc_pcworld/verizonaimsforltedeploymentin2009

+

http://androidguys.com/?p=3046

=

4G Android fun for all you US lovelies?

Al.
http://andappstore.com/

-- 
======
Funky Android Limited is registered in England & Wales with the 
company number  6741909. The registered head office is Kemp House, 
152-160 City Road, London,  EC1V 2NX, UK. 

The views expressed in this email are those of the author and not 
necessarily those of Funky Android Limited, it's associates, or it's 
subsidiaries.


--~--~---------~--~----~------------~-------~--~----~

3. Sending SMS messages

4. Availability

5. how does notepad_list and notes_row joined in Notepadv1

6. does anyone read the bug reports?

7. scrollbar using apis