Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Video Capture ignoring EXTRA_OUTPUT dilemma

I'm having a pig of a time creating a basic video capture feature in my application. I want to call the default video capture tool my device and had the file saved to a specific location.

From the documentation this is achieved by providing a Uri in EXTRA_OUTPUT, however what's happening is this is completely being ignored and the video is actually being written to the usual media store location.

My code is very simple :

      Intent i = new Intent( android.provider.MediaStore.ACTION_VIDEO_CAPTURE );
      String SD_CARD_TEMP = Environment.getExternalStorageDirectory() 
        + File.separator + MEDIA_TEMP ;       
      i.putExtra( android.provider.MediaStore.EXTRA_OUTPUT, Uri.parse(SD_CARD_TEMP) );       
      startActivityForResult( i, ACTIVITY_CAPTURE_VIDEO );

The constant MEDIA_TEMP is set to 'media_temp'. I've also tried using a File rather than a string and using Uri.fromFile() but that made no difference.

If anyone has any ideas as to why this code isn't behaving as the docs say it should.. please tell me :-)

PS. Development is being carried out live on HTC Desire HD, not emulator..

Thanks,

Dave

like image 654
David Brown Avatar asked Nov 08 '10 11:11

David Brown


3 Answers

After spending 13 hours trying to figure out what was going on with this camera API...

I was using the camera intent and the EXTRA_OUTPUT to specify where to save the file to, and it was being ignored!

This app worked a few weeks previously, and no OS upgrades had occurred in that time..

I may have figured out the source of the problem:

If there are any apps installed on the phone that interact with, or intercept the camera API, some of the API may break!

I discovered this after a 13 hour debugging marathon, trying all the possible API combinations, and following all the suggestions on stackoverflow..

My hands were getting tired holding the phone, so I built a phone stand out of a coathanger to anchor the phone to my desk, with the camera pointed at a jar of peanut butter.

In a stroke of luck, as I was debugging with my photos of peanut butter, the Google Goggles App popped up a notification saying it had "recognized" something in my image!

This prompted me to IMMEDIATELY uninstall google goggles, and all of a sudden, images start saving to my custom Uri like they used to!!!

This was on a Samsung Stratosphere.

like image 166
manthrax Avatar answered Nov 20 '22 11:11

manthrax


I have the same problem. It works on stock Android, but does not work on HTC or SonyEricsson devices.

Seems as if their cam-app behaves differently to the default.

I think the only possibility would be to ask the media provider for the latest recorded video and get the path from it. Then copy the file to your own directory and delete it from media provider.

Not very smart and error prone, but maybe the only way.

Does someone have a better idea?

like image 40
Maniac Avatar answered Nov 20 '22 10:11

Maniac


I'm doing something similar on nexus one and it works, but the same code does not work on the htc aria. so its probably something to do with the activities which are actually run on the different devices and if they respect that parameter or not.

like image 1
Cameron Ketcham Avatar answered Nov 20 '22 12:11

Cameron Ketcham