Video Recording Problem.

All your problems with Audio, Video and Images.

Video Recording Problem.

Postby yeshwin.nvs » Wed Jul 08, 2009 7:22 am

[font=Times New Roman]
Hi
i write the program which Records video using MediaRecorder.
I Got the Exception in : setVideoSource(MediaRecorder.VideoSource.DEFAULT);[/font]

Exception i Got is: setVideoSource failed.

My Code is:

recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT); //Here I Got Exception
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
recorder.setVideoSize(480, 320);
recorder.setVideoFrameRate(15);
recorder.setMaxDuration(10000);
yeshwin.nvs
Freshman
Freshman
 
Posts: 8
Joined: Mon Apr 13, 2009 10:43 am

Top

Postby yeshwin.nvs » Wed Jul 08, 2009 9:27 am

Hi I mention my problem above..
What is the procedure for recording VIDEO.
yeshwin.nvs
Freshman
Freshman
 
Posts: 8
Joined: Mon Apr 13, 2009 10:43 am

Postby Jonpro » Thu Jul 23, 2009 8:38 pm

Make sure you have the camera permission enabled. You can do this by adding

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <uses-permission android:name="android.permission.CAMERA"></uses-permission>
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


to your manifest file.
Jonpro
Freshman
Freshman
 
Posts: 6
Joined: Thu Jul 23, 2009 8:29 pm

But i had differenent Problem!!

Postby lokidil » Tue Aug 18, 2009 11:24 am

I get the camera preview from the android sample and just added the video recording as similar as above post and i had set the mediarecorder.setCamera(cam);cam is instance that i get it from that android sample class,, Now the problem is the application crash while loading,,

Where to getting start with video recording application with preview video can anyone help me!!!
lokidil
Junior Developer
Junior Developer
 
Posts: 13
Joined: Mon Aug 10, 2009 6:08 am

Postby Jonpro » Tue Aug 18, 2009 3:30 pm

Try this.
Jonpro
Freshman
Freshman
 
Posts: 6
Joined: Thu Jul 23, 2009 8:29 pm

Postby lokidil » Tue Aug 18, 2009 3:39 pm

hi thx Jonpro!!
lokidil
Junior Developer
Junior Developer
 
Posts: 13
Joined: Mon Aug 10, 2009 6:08 am

Top

possibility of video recording with emulator

Postby JoyLakh » Tue Sep 01, 2009 7:31 am

Dear JonPro,

Can you please confirm whether it is possible to test your application with EMULATOR. I mean to ask you is it possible to test video recording with EMULATOR. Why I am asking this is I tested your application with emulator and it is giving "java.io.IOException: prepare failed" error. Initially i thought i missed out something, but after going through this link:

http://groups.google.com/group/android- ... 85f730da9a

i felt i better confirm this with you.

I will be glad, if you could reply soon as i already spent one week blaming myself for this error.

Thanks and Regards.
JoyLakh
Junior Developer
Junior Developer
 
Posts: 13
Joined: Tue Dec 16, 2008 5:42 am
Location: Bangalore, India

Postby manemannen » Tue Sep 01, 2009 9:53 am

JoyLakh,

I can confirm this. I get the error both on the Emulator and on a ADP1.

regards
manemannen
Freshman
Freshman
 
Posts: 4
Joined: Tue Sep 01, 2009 9:33 am

video recording test app

Postby JoyLakh » Tue Sep 01, 2009 12:10 pm

Thanks manemannen,

By the way do you have any working video recording test app. I will be very thankful if u can provide me with that.

I have written my own but it got struck at "recorder.setvideosource" saying "trying to access locked camera" . Please let me know if u have any idea on how to overcome this.

Thanks and Regards,
Siva.
Celebrate Life.
JoyLakh
Junior Developer
Junior Developer
 
Posts: 13
Joined: Tue Dec 16, 2008 5:42 am
Location: Bangalore, India

Postby Jonpro » Tue Sep 01, 2009 6:26 pm

I'm not sure if video recording will work with the emulator. I remember when I was testing the still camera on the emulator it just generated the same sample image every time.

I am on vacation this week but if you still have problems I can try to take a look at it sometime next week.
Jonpro
Freshman
Freshman
 
Posts: 6
Joined: Thu Jul 23, 2009 8:29 pm

Postby JoyLakh » Wed Sep 02, 2009 6:26 am

Thanks mate. Meanwhile if I have any update I will let u know.

Celebrate Life.
Celebrate Life.
JoyLakh
Junior Developer
Junior Developer
 
Posts: 13
Joined: Tue Dec 16, 2008 5:42 am
Location: Bangalore, India

Thanks man

Postby JoyLakh » Wed Sep 09, 2009 1:45 pm

Hey Jonpro,

Vexed with the emulator, yesterday we bought HTC magic and today I tested your code. It's perfect.

Once again, thanks a lot.
Celebrate Life.
JoyLakh
Junior Developer
Junior Developer
 
Posts: 13
Joined: Tue Dec 16, 2008 5:42 am
Location: Bangalore, India

Postby manemannen » Wed Sep 09, 2009 2:39 pm

It worked without any changes? I try to run it on the ADP1 but always get the "prepare() failed" no matter where I try to save the output file.

regards
m
manemannen
Freshman
Freshman
 
Posts: 4
Joined: Tue Sep 01, 2009 9:33 am

Video Recording

Postby JoyLakh » Fri Sep 11, 2009 5:50 am

Hey manemannen,

Apart from Jonpro's version, below pasted code segment worked for me in HTC Magic, I should say this is another form of Jonpro's code.

All the best.

public class VideoRecorder extends Activity
{
private final static String TAG = "Playing";
private MediaRecorder recorder;
private Preview mPreview;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
recorder = new MediaRecorder();
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);

mPreview = new Preview(this,recorder);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setContentView(mPreview);

}

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
menu.add(0, 0, 0, "StartRecording");
menu.add(0, 1, 0, "StopRecording");
return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case 0:
try {

recorder.start();

} catch (Exception e) {
String message = e.getMessage();
Log.w(TAG, e);
recorder.release();
}
break;

case 1: //GoToAllNotes
recorder.stop();
recorder.release();
recorder = null;
break;

default:
break;
}
return super.onOptionsItemSelected(item);
}
}

class Preview extends SurfaceView implements SurfaceHolder.Callback
{
SurfaceHolder mHolder;
MediaRecorder tempRecorder;

Preview(Context context, MediaRecorder recorder)
{
super(context);
tempRecorder = recorder;
mHolder = getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}

public Surface getSurface()
{
return mHolder.getSurface();
}

public void surfaceCreated(SurfaceHolder holder)
{
tempRecorder.setOutputFile("/sdcard/myVideo.3gp");
tempRecorder.setPreviewDisplay(mHolder.getSurface());
try{
tempRecorder.prepare();
} catch (Exception e) {
String message = e.getMessage();
tempRecorder.release();
tempRecorder = null;
}
}

public void surfaceDestroyed(SurfaceHolder holder)
{
if(tempRecorder!=null)
{
tempRecorder.release();
tempRecorder = null;
}
}

public void surfaceChanged(SurfaceHolder holder, int format, int w, int h)
{

}

}
Celebrate Life.
JoyLakh
Junior Developer
Junior Developer
 
Posts: 13
Joined: Tue Dec 16, 2008 5:42 am
Location: Bangalore, India

Postby manemannen » Fri Sep 11, 2009 6:55 am

great, i will try it out and see if it gets any better.

thanks
manemannen
Freshman
Freshman
 
Posts: 4
Joined: Tue Sep 01, 2009 9:33 am

Top
Next

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 24 guests