-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[video_player_avfoundation] Applies the standardized transform for videos with different orientations #5069
Changes from 9 commits
f69f79e
85da558
bc4b06d
7a74c2a
2ae271b
7c91a3f
1c7bc9a
2bb2f41
e452c89
07cb30e
b801da1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import <AVFoundation/AVFoundation.h> | ||
|
||
/** | ||
* Note: https://stackoverflow.com/questions/64161544 | ||
* `AVAssetTrack.preferredTransform` can have wrong `tx` and `ty` | ||
* on iOS 14 and above. This function provides a standardized transform | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh just double check - have you tested both iOS 14+ and earlier OS version? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I can only and have tested this on iOS14+... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let me try it on earlier OS. could you please hold this PR for now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sure. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tested on iOS 13.7 and it worked. I am curious where is this "iOS 14 and above" coming from? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one: "used to be broken and now is working" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let me try iOS 12 too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me update the comment then.
Maybe we can file another issue to track this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good if you think it's unrelated. |
||
* according to the orientation of the track. | ||
*/ | ||
CGAffineTransform FLTGetStandardizedTransformForTrack(AVAssetTrack* track); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import <AVFoundation/AVFoundation.h> | ||
|
||
CGAffineTransform FLTGetStandardizedTransformForTrack(AVAssetTrack *track) { | ||
CGAffineTransform t = track.preferredTransform; | ||
CGSize size = track.naturalSize; | ||
// Each case of control flows corresponds to a specific | ||
// `UIImageOrientation`, with 8 cases in total. | ||
if (t.a == 1 && t.b == 0 && t.c == 0 && t.d == 1) { | ||
// UIImageOrientationUp | ||
t.tx = 0; | ||
t.ty = 0; | ||
} else if (t.a == -1 && t.b == 0 && t.c == 0 && t.d == -1) { | ||
// UIImageOrientationDown | ||
t.tx = size.width; | ||
t.ty = size.height; | ||
} else if (t.a == 0 && t.b == -1 && t.c == 1 && t.d == 0) { | ||
// UIImageOrientationLeft | ||
t.tx = 0; | ||
t.ty = size.width; | ||
} else if (t.a == 0 && t.b == 1 && t.c == -1 && t.d == 0) { | ||
// UIImageOrientationRight | ||
t.tx = size.height; | ||
t.ty = 0; | ||
} else if (t.a == -1 && t.b == 0 && t.c == 0 && t.d == 1) { | ||
// UIImageOrientationUpMirrored | ||
t.tx = size.width; | ||
t.ty = 0; | ||
} else if (t.a == 1 && t.b == 0 && t.c == 0 && t.d == -1) { | ||
// UIImageOrientationDownMirrored | ||
t.tx = 0; | ||
t.ty = size.height; | ||
} else if (t.a == 0 && t.b == -1 && t.c == -1 && t.d == 0) { | ||
// UIImageOrientationLeftMirrored | ||
t.tx = size.height; | ||
t.ty = size.width; | ||
} else if (t.a == 0 && t.b == 1 && t.c == 1 && t.d == 0) { | ||
// UIImageOrientationRightMirrored | ||
t.tx = 0; | ||
t.ty = 0; | ||
} | ||
return t; | ||
} |
Uh oh!
There was an error while loading. Please reload this page.