I want to capture the video through my application and also need extra information of captured video like Start time , end time , Quality of the video.
Currently I am using existing camera application to capture the video in my application , with sample code
static final int REQUEST_VIDEO_CAPTURE = 1;
private void dispatchTakeVideoIntent() {
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
}
}
From above sample code , I am able to capture video and store on device but I am not getting any way to get that extra information?
Is it possible to get that extra info using existing camera application?
If yes then how else is there any other way to do this?
Is it possible to get that extra info using existing camera application?
No.
If yes then how else is there any other way to do this?
You are welcome to use the time that you call startActivityForResult() as the start time, the time you are called with onActivityResult() as the end time, and the quality that you request via EXTRA__VIDEO_QUALITY as the quality.
Or, write your own video recorder, using the camera APIs and MediaRecorder.
Related
I am using Android 5.0 to implement an application which allows to automatically capture and save an image into my phone. Currently, I am using bellow code but it requires press the capture button in Capture UI of my phone. Is it possible to capture and save the image without press the capture button? For example, I just call the function myCaptureandSave(), then the phone will display Capture UI and intermediately capture the image and save, I do not need doing more step.
public void myCaptureandSave() {
String image_path = Environment.getExternalStorageDirectory() +"/"+System.currentTimeMillis()+".jpg";
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
//File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
File output = new File(image_path);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(output));
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
You have to use Camera Api. Create Service, running in background, which hold reference to this api and current SurfaceTexture, it is necessary, camera will be 'previewing to nowhere'. after that you'll be able to take pictures even if device is locaked
Yes it is possible, but I believe you can't do it using the internal camera (calling the intent). You have to use Camera2 API.
I made a library to use Camera2 API, you can take a look at it if you want:
https://github.com/omaflak/Android-Camera2-Library
In your case, simply pass a dummy SurfaceTexture for the preview and call takePicture().
Hope it will help
how to capture an image in background without using the camera application
i tried with this time ago and with little bit changes i got it.
Hope this helps..
I want to take a photo with the camera app which is default on the device. After taking it I have my own preview on which the user can input a text and accept the picture or refuse it. This already works fine.
My problem is now that some user has activated the preview option in the default camera app. Is there a parameter for the Intent to deactivate the default setting and send the picture directly to my app without a preview? I don't find a documentation for this case...
I start the camera with the following code
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(this.getPackageManager()) != null) {
this.startActivityForResult(takePictureIntent, MY_CAMERA_REQUEST_CODE);
}
The alternative is to create a own camera in my app. But this is in my opinion a little bit oversized.
Thanks in advance for any help.
There is no possibility to disable the preview programmatically. If something different is needed as the settings of the default camera, an own camera has to be implemented :-(
I've written an app before where I open the native camera app to capture an image like this:
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Or, like this for capturing video:
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
But is there a way to open the native camera app with the option to capture either video or an image? I'd like to open to the image given below, where the user can swipe to access the side-menu and change their input type.
I've tried searching, but no results have come up yet. I'm not sure if there is a way to do this without writing a custom camera implementation, which I'd like to avoid for now.
If this is possible, how can I do it? And how could I go about recognizing what media type the user has chosen once the capture is complete (in onActivityResult, probably)?
Thank you in advance!
Currently As specified by you there are 2 intents for capturing image and video i.e. MediaStore.ACTION_IMAGE_CAPTURE & MediaStore.ACTION_VIDEO_CAPTURElink.
For intially I was also thinking startActivityForResult (Intent intent, int requestCode, Bundle options), Here options param was used to give the extras for the external applications but we can only specify some animations not the values as specified link1 & link2.
Solution
I would rather suggest you to go for the custom app with options as you like rather than the restrictions given by the existing camera app.
Is there a way we can extend the default video recording time on glass. The current recording time is only 10 seconds and we have to extend it manually by pressing the camera key for one second or by tapping and choosing Extend Video option. So i was wondering whether there is a flag that we can set when requesting the camera to start recording which will cause the camera to record an extended video.
I was also wondering how can we set the maximum time limit of video recording and what is the default time limit of video recording in glass ?
I am using the code below for starting the glass camera for video recording
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent, CAPTURE_VIDEO_REQUEST_CODE);
Also if there isn't a possible way can anyone guide me on the alternatives. Is there any open source camera available which works for glass or should i have to write my own camera [any links that would help me get started] ?
Hope you get him idea from it:
Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra("android.intent.extra.durationLimit", 60);
startActivityForResult(intent, CAPTURE_VIDEO_REQUEST_CODE);
This above code video duration is one minute,if u want to extend the video time then do it like that,and now the video duration is 2 minutes:
Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra("android.intent.extra.durationLimit", 120);
startActivityForResult(intent, CAPTURE_VIDEO_REQUEST_CODE);
You can access the camera directly and record the video yourself. See the official Android documentation for more information: http://developer.android.com/guide/topics/media/camera.html#capture-video
I have searched a lot but i did not get any solution. I want to open default camera of my android device so that i can capture image as well as video. I have tired it using:
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, ACTION_IMAGE_CAPTURE);
or
Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent, ACTION_VIDEO_CAPTURE);
But using this camera open only in one mode either in Image or in Video capture mode. I want to open default camera. Please don't suggest using Surface View holder.
Thanks a lot in Advacnce
Please don't suggest using Surface View holder.
You can't do it.Both in one time.Either you open image or video.You should put alert for choose one Video or image.
You will have to get native interaction for that purpose. Search for Qualcomm's Augmented Reality Sample apps. In that they have opened the Camera natively and not through Android's Camera api.