Export portrait video to square, but with scaleAspectFit

In my application, I allow users to record video in portrait mode. I use this in the application, and this is normal. However, I am implementing a feature for sharing videos on Instagram, where the video should be square.

Trimming the video into a square, say, the central part, is an option, however, since the user does not take this into account when shooting video, it usually turns out to be bad.

Therefore, I would like to export the square of the video, but with the aspect ratio and with two stripes left and right. Optimally, is there a way to determine the background color (either by code or by UIImage).

The closest thing I could find is this , however I can’t use it since I don’t understand how to set up the transformation.

Example (red frame only for marking image borders): Example

+4
source share
1 answer

In addition, to add black bars and redisplay the video, you can use the cameraOverlayView UIImagePickerController property.

That way, you can create a view with two black stripes in OR, you can create a view that has a square frame above the camera view so they know to create it there because it will share the instagram.

+1
source

All Articles