My app lets the user capture video:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_VIDEO_REQUEST);
or pics:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
In the case of the pics, I can tell whether they were taken in any mode other than landscape and then rotate them before I upload them to the web:
ExifInterface exif = new ExifInterface(fileName);
int exifOrientation = Integer.parseInt(exif.getAttribute(ExifInterface.TAG_ORIENTATION));
float rotate = 0;
switch (exifOrientation){
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
}
if(rotate > 0){
Bitmap bitmap = BitmapFactory.decodeFile(fileName);
Matrix matrix = new Matrix();
matrix.postRotate(rotate);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
OutputStream outStream = context.getContentResolver().openOutputStream(Uri.fromFile(file));
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
}
How do I accomplish the same with video?
I do not seem to fully understand your question. Here are some questions that I thought would at least steer you in the right direction. Hope it helps
Do you want to rotate the video for playback with the MediaPlayer?
Do you want to change the hard code in the video file to make it play rotated everywhere?
Rotate buffered video orientation?
================================================================================== This answer to question # 1:
//rotating a SurfaceView that contains the MediaPlayer
/*
Create a new MediaPlayer SurfaceView, then use the SurfaceHolder interface
*/
video = new SurfaceView();
video.getHolder().setType(SurfaceHolder.SURFACE_TYPE_NORMAL);
video.getHolder().lockCanvas().rotate(90);
This answer to question # 2:
As for changing the hard code of a video. I would advise to use a nice GUI video codec to rotate the video and it should save its settings. Otherwise you will have to access the source code from the decoder then your SOL with my advice.
This answer to question # 3:
The post below explains how you can rotate a buffered video and/or change its orientation settings for different modes.
Post here: Android VideoView orientation change with buffered video
==================================================================================
If this doesn't help you then I am sure it will help someone else, and good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With