FFmpegMediaMetadataRetriever
FFmpegMediaMetadataRetriever copied to clipboard
Front Camera orientation problem.
When operating the Lib on Video taken from Front Camera, the orientation is wrong. That is we are seeing a 90 degree rotation of the images. This was working fine in MediaMetadataRetriever class. Please help.
Can you post a sample video I can test with?
Here is video : https://drive.google.com/file/d/0B-T15ODuON57S2U0LTRZTGNJTk0/view?usp=drivesdk
I am getting landscape bitmaps. video is recorded from app as portrait and following is my code :
FFmpegMediaMetadataRetriever fpeg = new FFmpegMediaMetadataRetriever();
fpeg.setDataSource(AppUtils.videoPath); // its sdcard video path
String duration = fpeg
.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_DURATION);
seesaw_bitmaps[0] = fpeg.getFrameAtTime(1, FFmpegMediaMetadataRetriever.OPTION_CLOSEST_SYNC);
@hardikJoshi123 Maybe this snippet of code will help get you in the right direction:
public void fixImageRotation(){
imageview.buildDrawingCache();
Bitmap original = imageview.getDrawingCache();
//fileUri is the uri of the selected image
imageview.setImageBitmap(imageOreintationValidator(original, fileUri.getPath()));
}
private Bitmap imageOreintationValidator(Bitmap bitmap, String path) {
ExifInterface ei;
try {
ei = new ExifInterface(path);
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
bitmap = rotateImage(bitmap, 90);
break;
case ExifInterface.ORIENTATION_ROTATE_180:
bitmap = rotateImage(bitmap, 180);
break;
case ExifInterface.ORIENTATION_ROTATE_270:
bitmap = rotateImage(bitmap, 270);
break;
}
} catch (IOException e) {
e.printStackTrace();
}
return bitmap;
}
private Bitmap rotateImage(Bitmap source, float angle) {
Bitmap bitmap = null;
Matrix matrix = new Matrix();
matrix.postRotate(angle);
try {
bitmap = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(),
matrix, true);
} catch (OutOfMemoryError err) {
err.printStackTrace();
}
return bitmap;
}
Look at my issue #190, Using ExifInterface will not fix the issue on some Samsung devices, I can confirm this on my Samsung J7 Pro. I found a workaround.