【发布时间】:2011-11-15 12:32:24
【问题描述】:
我的应用让用户捕捉视频:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_VIDEO_REQUEST);
或图片:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
就图片而言,我可以判断它们是否是在横向以外的任何模式下拍摄的,然后在将它们上传到网络之前旋转它们:
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);
}
我如何通过视频实现同样的效果?
【问题讨论】:
-
是的,我想我可以将它按原样发布到服务器并在那里运行 flvtool 和 ffmpeg。无论如何要在设备中执行此操作吗?
-
嘿@shaharsol,你有没有找到这个问题的解决方案?我面临同样的问题。
-
我也有同样的问题,谁能提供有效的答案。我在录制后上传视频并在上传后更改方向