1: 1 aspect ratio video capture on iOS

I want to capture video with an iOS camera with an aspect ratio of 1: 1.

I tried with the UIImagePickerController but did not change the aspect ratio. Can anyone give me some ideas?

In addition, the iPhone "Viddy" application provides video capture in 1: 1 format http://gyazo.com/1ccba9990bb589961f1d5df23b71b84b.png?1364791668

Thanks!

+3
source share
3 answers
GPUImageMovie* movieFile = [[GPUImageMovie alloc] initWithAsset:asset]; GPUImageCropFilter *cropFilter = [[GPUImageCropFilter alloc] initWithCropRegion:CGRectMake(0.0, 0.1, 1.0, 0.8)]; [movieFile addTarget:cropFilter]; GPUImageMovieWriter* movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(320.0, 320.0)]; [cropFilter addTarget:movieWriter]; [movieWriter startRecording]; [movieFile startProcessing]; [movieWriter finishRecordingWithCompletionHandler:^{ NSLog(@"Completed Successfully"); [cropFilter removeTarget:movieWriter]; [movieFile removeTarget:cropFilter]; }]; 

where

  • asset is the input movie file.
  • cropRegion is the crop area.
  • movieUrl is the destination URL to save the cropped movie.
+4
source
 AVCaptureVideoPreviewLayer *_preview = [AVVideoCaptureVideoPreviewLayer layerWithSession:_session]; _preview.frame = CGRectMake(0,0,320,320); _preview.videoGravity = AVLayerVideoGravityResizeAspectFill; NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys: AVVideoCodecH264, AVVideoCodecKey, [NSNumber numberWithInt:320], AVVideoWidthKey, [NSNumber numberWithInt:320], AVVideoHeightKey, AVVideoScalingModeResizeAspectFill,AVVideoScalingModeKey, nil]; self.videoInput = [AVAssetWriterInput assetWriterInputWithMediaType: AVMediaTypeVideo outputSettings: videoSettings]; self.videoInput.transform = CGAffineTransformMakeRotation(M_PI); if([_writer canAddInput:_videoInput]) // AVAssetWriter *_writer [_writer addInput:_videoInput]; 

Note:

_preview videoGravity and videoSettings AVVideoScalingModeKey must be the same to get a result of 320 x 320.

+5
source

I do not think that this can be done without the help of any application, or even if it is possible using the application, you can capture a video and then crop it to 1: 1

-one
source

All Articles