Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is probably a better way to do this, but the following code should work. I'm assuming that you are using the GPUImage framework by Brad Larson. Note that this code will save a 480x480 square video.</p> <pre><code>//Square cropping UIImage *testImage = [filter imageFromCurrentlyProcessedOutput]; double camWidth = testImage.size.width; double camHeight = testImage.size.height; double offset; double normalizedOffset; CGRect normalizedCropFrame; if(camWidth &gt; camHeight) { offset = (camWidth - camHeight) / 2.0; normalizedOffset = offset / camWidth; normalizedCropFrame = CGRectMake(normalizedOffset, 0.0, camHeight/camWidth, 1.0); } else { offset = (camHeight - camWidth) / 2.0; normalizedOffset = offset / camHeight; normalizedCropFrame = CGRectMake(0.0, normalizedOffset, 1.0, camWidth/camHeight); } squareCrop = [[GPUImageCropFilter alloc] initWithCropRegion:normalizedCropFrame]; //pause camera while setting up movie writer [videoCamera pauseCameraCapture]; //set up movie writer pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie.m4v"]; unlink([pathToMovie UTF8String]); NSURL *movieURL = [[NSURL alloc] initFileURLWithPath:pathToMovie]; movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(480.0, 480.0)]; //start recording [filter addTarget:squareCrop]; [squareCrop addTarget:movieWriter]; videoCamera.audioEncodingTarget = movieWriter; [movieWriter startRecording]; [videoCamera resumeCameraCapture]; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload