From fcd877fdc1c56846fc5d609354f52747177255dc Mon Sep 17 00:00:00 2001 From: Jerry Date: Thu, 5 Nov 2020 18:09:47 +0800 Subject: [PATCH] fix bug. https://github.com/rs/SDAVAssetExportSession/issues/79. --- SDAVAssetExportSession.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SDAVAssetExportSession.m b/SDAVAssetExportSession.m index e99993b..9f53757 100755 --- a/SDAVAssetExportSession.m +++ b/SDAVAssetExportSession.m @@ -309,6 +309,13 @@ - (AVMutableVideoComposition *)buildDefaultVideoComposition CGSize targetSize = CGSizeMake([self.videoSettings[AVVideoWidthKey] floatValue], [self.videoSettings[AVVideoHeightKey] floatValue]); CGSize naturalSize = [videoTrack naturalSize]; CGAffineTransform transform = videoTrack.preferredTransform; + + CGRect rect = {{0, 0}, naturalSize}; + CGRect transformedRect = CGRectApplyAffineTransform(rect, transform); + // transformedRect should have origin at 0 if correct; otherwise add offset to correct it + transform.tx -= transformedRect.origin.x; + transform.ty -= transformedRect.origin.y; + // Workaround radar 31928389, see https://github.com/rs/SDAVAssetExportSession/pull/70 for more info if (transform.ty == -560) { transform.ty = 0;