SCRecorder icon indicating copy to clipboard operation
SCRecorder copied to clipboard

SCAssetExportSession watermark orientation bug

Open pingguoilove opened this issue 9 years ago • 3 comments

I found a bug when export a video file which import from album, the water mark orientation is wrongwrong gif

pingguoilove avatar Aug 25 '15 08:08 pingguoilove

me too, is there any solutions?

realcarlos avatar Feb 26 '16 13:02 realcarlos

@realcarlos No

pingguoilove avatar Mar 14 '16 05:03 pingguoilove

The reason for the different behavior is that portrait videos from the camera roll are actually landscape videos that have a transform applied to them as part of their metadata. The segments recorded by SCRecorder are actually portrait dimensions.

I solved this locally by:

  1. enabling keepInputAffineTransform (passes through the transform to the export session)
  2. disabling translatesFilterIntoComposition (seems the composition doesn't respect the transform)
  3. in the _buildWatermarkFilterForVideoSize method of SCAssetExportSession, just before drawing in the graphics context, I added this:
CGAffineTransform affineTransform = _videoInput.transform;
CGAffineTransform invertedTransform = CGAffineTransformInvert(affineTransform);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextConcatCTM(context, invertedTransform);

I can't guarantee this will work for everyone, but it worked for me. Hope this helps someone.

pixelmatrix avatar Apr 27 '17 22:04 pixelmatrix