|
|
|
|
42
|
filePath = filePath.replace("file://","");
|
42
|
filePath = filePath.replace("file://","");
|
43
|
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
|
43
|
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
|
44
|
retriever.setDataSource(filePath);
|
44
|
retriever.setDataSource(filePath);
|
45
|
- int videoWidth = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
|
|
|
46
|
- int videoHeight = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
|
|
|
47
|
-
|
|
|
48
|
Bitmap image = retriever.getFrameAtTime(1000000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
|
45
|
Bitmap image = retriever.getFrameAtTime(1000000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
|
49
|
|
46
|
|
50
|
- int bitmapWidth = image.getWidth();
|
|
|
51
|
- int bitmapHeight = image.getHeight();
|
|
|
52
|
-
|
|
|
53
|
- if ((bitmapWidth > bitmapHeight) != (videoWidth > videoHeight)) {
|
|
|
54
|
- // we need to rotate image
|
|
|
55
|
- Matrix matrix = new Matrix();
|
|
|
56
|
- matrix.postRotate(-90);
|
|
|
57
|
- image = Bitmap.createBitmap(image, 0, 0, bitmapWidth, bitmapHeight, matrix, true);
|
|
|
58
|
- }
|
|
|
59
|
-
|
|
|
60
|
String fullPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/thumb";
|
47
|
String fullPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/thumb";
|
61
|
|
48
|
|
62
|
try {
|
49
|
try {
|