Skip to content

Commit 0b4f3f3

Browse files
update: changing video resolution for rotated videos
1 parent 7a05ee0 commit 0b4f3f3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library/src/main/java/com/gowtham/library/utils/TrimmerUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ public static Pair<Integer, Integer> getVideoRes(Activity context, Uri videoUri)
142142
String width = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
143143
int w = TrimmerUtils.clearNull(width).isEmpty() ? 0 : Integer.parseInt(width);
144144
int h = Integer.parseInt(height);
145+
int rotation = TrimmerUtils.getVideoRotation(context, videoUri);
146+
// Swap width and height if video is rotated 90 or 270 degrees
147+
if (rotation == 90 || rotation == 270) {
148+
return new Pair<>(h, w);
149+
}
145150
return new Pair<>(w, h);
146151
} catch (Exception e) {
147152
e.printStackTrace();

0 commit comments

Comments
 (0)