Skip to content

Commit

Permalink
Revert layouts (shahen94#71)
Browse files Browse the repository at this point in the history
*  temporary remove playerLayer

* fix(Trimmer): Preview Images

load preview images properly when video's duration is less than 10sec

* get preview image with the right orientation
  • Loading branch information
Shahen Hovhannisyan authored Jun 7, 2017
1 parent 77d5040 commit dd3d14d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public static void getPreviewImages(String path, Promise promise, ReactApplicati

for (int i = 0; i < duration; i += duration / 10) {
Bitmap frame = retriever.getFrameAtTime(i * 1000);

if(frame == null) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,17 @@ public void sendMediaInfo() {

public void getFrame(float sec) {
Bitmap bmp = metadataRetriever.getFrameAtTime((long) (sec * 1000000));

int width = Integer.parseInt(metadataRetriever.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
int height = Integer.parseInt(metadataRetriever.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
int orientation = Integer.parseInt(metadataRetriever.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION));

Matrix mx = new Matrix();
mx.postRotate(orientation - 360);
Bitmap normalizedBmp = Bitmap.createBitmap(bmp, 0, 0, width, height, mx, true);

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
normalizedBmp.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream .toByteArray();
String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);

Expand Down
13 changes: 7 additions & 6 deletions ios/RNVideoProcessing/RNVideoPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,13 @@ class RNVideoPlayer: RCTView {
playerItem = AVPlayerItem(url: movieURL as! URL)
player.replaceCurrentItem(with: playerItem)

playerLayer = AVPlayerLayer(player: player)
playerLayer!.frame = filterView.bounds
playerLayer!.videoGravity = self._resizeMode
playerLayer!.masksToBounds = true
playerLayer!.removeFromSuperlayer()
filterView.layer.addSublayer(playerLayer!)
// MARK - Temporary removing playeLayer, it dublicates video if it's in landscape mode
// playerLayer = AVPlayerLayer(player: player)
// playerLayer!.frame = filterView.bounds
// playerLayer!.videoGravity = self._resizeMode
// playerLayer!.masksToBounds = true
// playerLayer!.removeFromSuperlayer()
// filterView.layer.addSublayer(playerLayer!)

print("CHANGED playerframe \(playerLayer), frameAAA \(playerLayer?.frame)")
self.setNeedsLayout()
Expand Down

0 comments on commit dd3d14d

Please sign in to comment.