Note that there are some explanatory texts on larger screens.

plurals
  1. POReceived memory warning in recording the video
    text
    copied!<p>I made an app for ipad which contains image dragging and video recording. </p> <p>It takes screenshots as recording starts and after that makes movie by appending them. </p> <p>When i record video of 5 to 10 seconds , it works fine. But as i try to record video of 1 minute or more, it crashes and gives <code>"Received memory warning"</code> in log.</p> <p>I have used the following code ;</p> <pre><code>- (IBAction)btnRecording_Pressed:(id)sender { if ([recordButton.titleLabel.text isEqualToString:@"Start Recording"]) { backButton.enabled = NO; [recordButton setTitle:@"Stop Recording" forState:UIControlStateNormal]; fileIndex = 0; recTimer = [NSTimer scheduledTimerWithTimeInterval:1.0/5.0 target:self selector:@selector(startFrameCapture) userInfo:nil repeats:YES]; [recTimer retain]; [self startRecording]; }else{ [recordButton setTitle:@"Start Recording" forState:UIControlStateNormal]; [recTimer invalidate]; [recTimer release]; [self stopRecording]; [self getFileName]; } } -(void)startFrameCapture { fileIndex++; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; documentsDirectory = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"Screenshot%d.jpg",fileIndex]]; [self performSelectorInBackground:@selector(newThread:) withObject:documentsDirectory]; } -(void)newThread:(NSString *)frameName{ if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale); else UIGraphicsBeginImageContext(self.view.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); imageData = UIImageJPEGRepresentation(viewImage, 1.0); [imageData writeToFile:frameName atomically:YES]; } - (void) startRecording{ if([recorder isRecording]){ NSLog(@"Stopped Recording"); [self stopRecording]; }else{ NSLog(@"Started Recording"); [self prepareRecorderNow]; [recorder record]; } } - (void) stopRecording{ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; if([recorder isRecording]){ [recorder stop]; [recorder release]; recorder = nil; } [pool drain]; } -(void)prepareRecorderNow{ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; AVAudioSession *audioSession = [AVAudioSession sharedInstance]; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; NSError *err = nil; [audioSession setCategory :AVAudioSessionCategoryPlayAndRecord error:&amp;err]; if(err){ NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]); return; } [audioSession setActive:YES error:&amp;err]; err = nil; if(err){ NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]); return; } recordSetting = [[NSMutableDictionary alloc] init]; [recordSetting setValue :[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey]; [recordSetting setValue:[NSNumber numberWithFloat:44100] forKey:AVSampleRateKey]; [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey]; [recordSetting setValue :[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey]; [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey]; [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey]; // Create a new dated file [recorderFilePath release]; recorderFilePath = [[NSString stringWithFormat:@"%@/deformed.caf", DOCUMENTS_FOLDER] retain]; NSURL *url = [NSURL fileURLWithPath:recorderFilePath]; err = nil; recorder = [[ AVAudioRecorder alloc] initWithURL:url settings:recordSetting error:&amp;err]; [recordSetting release]; if(!recorder){ NSLog(@"recorder: %@ %d %@", [err domain], [err code], [[err userInfo] description]); UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Warning" message: [err localizedDescription] delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; return; } //prepare to record [recorder setDelegate:self]; [recorder prepareToRecord]; recorder.meteringEnabled = YES; BOOL audioHWAvailable = audioSession.inputIsAvailable; if (! audioHWAvailable) { UIAlertView *cantRecordAlert = [[UIAlertView alloc] initWithTitle: @"Warning" message: @"Audio input hardware not available" delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [cantRecordAlert show]; [cantRecordAlert release]; return; } NSLog(@"Not Over Man"); [pool drain]; } </code></pre> <p>What can be the issue ?</p> <p>Thanks!!</p>
 

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