How can I open android video camera only HD mode? - android

I want to open video camera with intent and take a video only HD mode.(Phone have Full HD, HD and TV(very low) mode). I just open video camera like above. But I cannot set any params in it.
Intent videoCapture = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(videoCapture, 1);

MediaStore.class
/**
* The name of the Intent-extra used to control the quality of a recorded video. This is an
* integer property. Currently value 0 means low quality, suitable for MMS messages, and
* value 1 means high quality. In the future other quality levels may be added.
*/
public final static String EXTRA_VIDEO_QUALITY = "android.intent.extra.videoQuality";
I think there is no solution for now .s

You can use this to set parameters for your video capture :
Intent videoCapture = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
videoCapture.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 60); // Duration in Seconds
videoCapture.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // Quality High (0 : Quality Low)
videoCapture.putExtra(MediaStore.Video.Thumbnails.HEIGHT, 320);
videoCapture.putExtra(MediaStore.Video.Thumbnails.WIDTH, 240);
You can find more informations on the MediaStore page.
Hope it helps !

Related

How to obtain correct dimension from Camera2 and ImageReader?

In my Android application, I use Camera2 API to allow the user to take a snapshot. The code mostly is straight out of standard Camera2 sample application.
When the image is available, it is obtained by calling acquireNextImage method:
public void onImageAvailable(ImageReader reader) {
mBackgroundHandler.post(new ImageSaver(reader.acquireNextImage(), mFile));
}
In my case, when I obtain the width and height of the Image object, it reports it as 4160x3120. However, in reality, it is 3120x4160. The real size can be seen when I dump the buffer into a jpg file:
ByteBuffer buffer = mImage.getPlanes()[0].getBuffer();
byte[] bytes = new byte[buffer.remaining()];
buffer.get(bytes);
// Dump "bytes" to file
For my purpose, I need the correct width and height. Wondering if the width and height are getting swapped because the sensor orientation is 90 degrees.
If so, I can simply swap the dimensions if I detect that the sensor orientation is 90 or 270. I already have this value:
mSensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
I feel this is a general problem and not specific to my code. Regards.
Edit:
Turns out the image size reported is correct. Jpeg image metadata stores a field called "Orientation." Most image viewers know how to interpret this value.

How do I convert video to usable quality using an Intent?

On my Android device I can take videos one of 2 ways:
1) I can write a custom class / set of methods that will allow me to utilize the camera and have direct control over the features
or
2) I can use an intent to open the video and take a recording.
This question is with regards to the latter (using an intent). This is the intent code I am using to take a video:
private void takeVideo(Activity activity, Context context){
//Actual intent used to capture the video
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
//30 Second time limit (can make it anything, just using 30 here)
takeVideoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 30);
//Utility method I have for generating a uri to use for the video
android.net.Uri myUri = generateVideoUri(context);
//Uri to use
takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, myUri);
//Cap it at 20mb
takeVideoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 20000000L);
//HERE IS WHERE MY QUESTION LIES //0 is low, 1 is high
takeVideoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
activity.startActivityForResult(takeVideoIntent, 100);
}
The above code works just fine. My question is surrounding the quality.
If I send in 0 as the quality, it is absolutely horrible quality (IE, 10 seconds of video is about 0.3mb and appears to be the lowest quality the phone can handle). If I send in 1 as the quality, it is ungodly large and unwieldy (IE, 10 seconds of video is about 50mb).
Bearing in mind that some phone makers will ignore the intent extras sent, How do I go about getting medium quality video to use for uploads, messaging, etc?
Do I need to run some sort of compression on the large files?
Can this only be done via a custom video/ camera class?
Is there some other way I am not thinking of?
What would you recommend I do to get a "medium quality" video as opposed to the 2 extremes of way too large or way too small?
Thanks all!

Increasing the quality of the edited image in adobe creative SDK

I have this code to launch the adobe creative SDK image editor.
Uri imageUri = Uri.parse(path);
Intent imageEditorIntent = new AdobeImageIntent.Builder(this)
.setData(imageUri)
.build();
startActivityForResult(imageEditorIntent, 1);
I want the edited image be in highest quality.
What Intent parameters be passed for that ? Or any other workaround ?
Example from the Image Editor guide
You can set the image quality with the Image Editor's optional methods. Here is an example from the Creative SDK's Image Editor guide:
Intent imageEditorIntent = new AdobeImageIntent.Builder(this)
.setData(uri) // input image source
.withOutput(Uri.parse("file://" + getFilesDir() + "/my-pic-name.jpg")) // output file destination
.withOutputFormat(Bitmap.CompressFormat.JPEG) // output format
.withOutputSize(MegaPixels.Mp5) // output size
.withOutputQuality(90) // output quality
.build();
In your case, you might mostly be interested in .withOutputSize() and .withOutputQuality().
Relevant optional methods
From the Image Editor guide:
.withOutputSize(MegaPixels)
Sets the output file size (in megapixels).
If this method is not called, or a value of 0 is passed, then the preview sized image will be returned (usually the screen size of the device).
Note: you can pass in any value from the Creative SDK's MegaPixels enum, Mp0 to Mp30.
.withOutputQuality(int)
If the outputformat is JPEG, defines the quality of the saved JPEG image.
Note: for maximum quality, pass in 100.
Documentation for all optional methods
For details on the methods above and all other optional methods, you can refer to this section of the Creative SDK Image Editor guide.

Adobe Creative SDK Android - The size of preview image is too small on HTC device

I'm using Creative SDK as photo editor of my selfie app. According to SDK Document, I wrote following code to send an photo to Editor activity.
Uri uri = Uri.fromFile(fileImg);
//set preview size
DisplayMetrics dm = DeviceUtils.getDisplayMetrics();
int max_size = Math.max(dm.widthPixels, dm.heightPixels);
max_size = (int) ((float) max_size / 1.2f);
//prepare
Intent newIntent = new AviaryIntent.Builder(fromAct).setData(uri)
.withOutput(uri)
.withOutputFormat(Bitmap.CompressFormat.JPEG)
.withOutputSize(MegaPixels.Mp5).withNoExitConfirmation(true)
.saveWithNoChanges(false)
.withOutputQuality(100)
.withPreviewSize(max_size)
.build();
// ..and start feather
fromAct.startActivityForResult(newIntent, ACTION_REQUEST_FEATHER);
In Aviary Editor activity, the preview image is too small on HTC device(HTC One M8). It works properly on another device(with full size).
How could I solve it?
A small image loaded on screen depends on different factors:
the passed withPreviewSize(max_size) is smaller than the screen size.
the image itself is smaller than the screen size.
in your case what is the value of max_size? Try to omit that parameter (the editor activity will try to load the image using an optimal resolution).
Secondly, Are you sure the image you're trying to load is big enough? Try to load that image in your activity and print out the bitmap width and height.
So, working well for me with:
.withOutputQuality(100)
.withPreviewSize(2000)

Android Camera Preview is corrupting image output on G2?

I'm using Android's Camera and SurfaceView to show a the preview image to the user before taking a picture. This appears fine on the screen but when I take the picture the resulting jpg is corrupted (horizontal lines).
As a starting point I used Mark Murphy's Camera/Picture example which exhibits the same issue on the G2.
The camera paramaters:
preview size: 800x480
picture format: JPEG
Both parameters are supported according to the getSupportedPreviewSizes() and getSupportedPictureFormats()
The Nexus One, which has the same size screen, works correctly with the same parameters.
The G2 works correctly when setting the preview size to 640x480
My question: Has anyone else run into this issue before (corrupted image despite using supported settings)? How frequent is it? How did you work around it?
So far I had the same issue and now I manage to fix mine using
setPictureFormat(ImageFormat.JPEG);
Camera parameter settings.
Just recently found out that the camera default picture output was YUV. That's is why it shows perfectly on preview but once the picture is taken you would get a green or pink or corrupted image output.
These are the ImageFormat values which camera might support.
JPEG = 256;
NV16 = 16;
NV21 = 17;
RAW10 = 37;
RAW_SENSOR = 32;
RGB_565 = 4;
UNKNOWN = 0;
YUV_420_888 = 35;
YUY2 = 20;
YV12 = 842094169;
So other than the supported size, on some cases we might need to check the PictureFormat as well.
http://i.stack.imgur.com/PlHFH.png
These are just sample images taken using ImageFormat YUV and thus saving it as JPEG compression.
But in any case that you don't want to change the ImageFormat and thus keep the settings in YUV format you may need to save the image in this workaround:
Camera.Parameters parameters = camera.getParameters();
Camera.Size size = parameters.getPreviewSize();
YuvImage image = new YuvImage(data, parameters.getPreviewFormat(),
size.width, size.height, null);
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "YuvImage.jpg");
FileOutptStream filecon = new FileOutputStream(file);
image.compressToJpeg(new Rect(0, 0, image.getWidth(), image.getHeight()), 90,
filecon);

Categories

Resources