Saturday, May 7, 2011

Using MediaStore.EXTRA_OUTPUT specify target file for MediaStore.ACTION_VIDEO_CAPTURE




When I write this post, i tested it on Nexus One running 2.2.1.
It work as expected at that time.

But...I re-test it again on Nexus One updated 2.3.4 - it cannot save the video in SD Card.

It seem to be related to the right of folder/file between the app and the Camera App!
- Not yet solved-

Android Er@2011-06-16



MediaStore.EXTRA_OUTPUT is the the name of the Intent-extra used to indicate a content resolver Uri to be used to store the requested image or video.

The article "Start Video Recording using android.provider.MediaStore.ACTION_VIDEO_CAPTURE" save the captured video in default Uri. You can use the code below to specify target file for MediaStore.ACTION_VIDEO_CAPTURE:

Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);

//Specify target file
String MyVideoFilePath = "/sdcard/test/myvideo.3gp";
File imageFile = new File(MyVideoFilePath);
Uri imageFileUri = Uri.fromFile(imageFile);
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri);
//---

startActivityForResult(intent, REQUEST_VIDEO_CAPTURED);


Download the files.

9 comments:

Florian Schulte said...

Hi,

i think the intent is
"android.media.action.VIDEO_CAPTURE"

Florian Schulte said...

...at least on my DHD running Android Revolution HD

pratheeja said...

Hi,
I could record video successfully but I failed to save in sdcard. Error msg is "illegal argument exception : unknown url file:sdcard path while pressing retake button. Also play button is not working.

Could you pls tell me the reason?

Erik said...

Sorry pratheeja,

When I write this post, i tested it on Nexus One running 2.2.1.
It work as expected at that time.

But...I re-test it again on Nexus One updated 2.3.4 - it cannot save the video in SD Card.

It seem to be related to the right of folder/file between the app and the Camera App!

pratheeja said...

Ok... How can I solve this issue? Could you pls help....


regds,
Pratheeja

szihs said...

How to make this work for 2.3.x?
Thank you.

alvinsj said...

the alternative way is to get the path only after that, then do whatever after that.
protected void onActivityResult(int requestCode, int resultCode, Intent data){
path = getRealPathFromVideoURI(data.getData())
// copy to another location, etc.
}

boonhoi said...

hi,
i wrote the almost same program. i called the action.VIDEO_CAPTURE and save the video in my specific folder by using EXTRA_OUTPUT.
it work fine, but after recording. the video crash and display error "the application camera (process com.sec.android.app.camera) has stopped unexpectedly.
when i check back my file directory, the video actually is recorded and save in that folder.
any solution/suggestion for this?
i use the same method for camera, it work perfectly,just have issue with video

akhtar said...

Hi,
I am also facing hte same issue with video recording. @boonhoi : did u got the solution for the force close.

thank you