mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-02-22 02:23:16 +00:00
Fix video editor rendering orientation
This commit is contained in:
@@ -123,6 +123,21 @@ NSString *const kYUVVideoRangeConversionForLAFragmentShaderString = SHADER_STRIN
|
||||
#pragma mark -
|
||||
#pragma mark Initialization and teardown
|
||||
|
||||
- (UIInterfaceOrientation)orientationForTrack:(AVAsset *)asset
|
||||
{
|
||||
AVAssetTrack *videoTrack = [[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
|
||||
CGSize size = [videoTrack naturalSize];
|
||||
CGAffineTransform txf = [videoTrack preferredTransform];
|
||||
|
||||
if (size.width == txf.tx && size.height == txf.ty)
|
||||
return UIInterfaceOrientationLandscapeRight;
|
||||
else if (txf.tx == 0 && txf.ty == 0)
|
||||
return UIInterfaceOrientationLandscapeLeft;
|
||||
else if (txf.tx == 0 && txf.ty == size.width)
|
||||
return UIInterfaceOrientationPortraitUpsideDown;
|
||||
else
|
||||
return UIInterfaceOrientationPortrait;
|
||||
}
|
||||
|
||||
- (instancetype)initWithAsset:(AVAsset *)asset
|
||||
{
|
||||
@@ -554,7 +569,14 @@ NSString *const kYUVVideoRangeConversionForLAFragmentShaderString = SHADER_STRIN
|
||||
[currentTarget setInputSize:CGSizeMake(bufferWidth, bufferHeight) atIndex:targetTextureIndex];
|
||||
[currentTarget setInputFramebuffer:outputFramebuffer atIndex:targetTextureIndex];
|
||||
|
||||
// [currentTarget setInputRotation:kGPUImageRotateLeft atIndex:targetTextureIndex];
|
||||
UIInterfaceOrientation orientation = [self orientationForTrack:self.asset];
|
||||
if (orientation == UIInterfaceOrientationPortrait) {
|
||||
[currentTarget setInputRotation:kGPUImageRotateRight atIndex:targetTextureIndex];
|
||||
} else if (orientation == UIInterfaceOrientationLandscapeRight) {
|
||||
[currentTarget setInputRotation:kGPUImageRotate180 atIndex:targetTextureIndex];
|
||||
} else if (orientation == UIInterfaceOrientationPortraitUpsideDown) {
|
||||
[currentTarget setInputRotation:kGPUImageRotateLeft atIndex:targetTextureIndex];
|
||||
}
|
||||
}
|
||||
|
||||
[outputFramebuffer unlock];
|
||||
|
||||
Reference in New Issue
Block a user