title: Could not save .mp4 video file to iphone camera roll?
body: <p>I received the video file contents in the format of NSData and I am playing that file in MPMoviePlayerController successfully with following code </p>
  
  <pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsDirectory = [paths objectAtIndex:0];
  
  NSString *FileExtension=[[NSString alloc]init];
  
  if([contentType hasPrefix:@"video"] || [contentType isEqualToString:@"application/video"]) {
      FileExtension=@"mov";
     //FileExtension=@"mp4";
  }
  else
  {
    FileExtension=[contentType lastPathComponent];
  }
  
   //appFile is type of NSString.
   appFile = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"MyFile.%@",FileExtension]];
  
  //videoData is type of NSData
  [videoData writeToFile:appFile atomically:YES]; 
  
  NSURL *fileURL = [NSURL fileURLWithPath:appFile isDirectory:NO];
  
  moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
  moviePlayerController.view.frame = self.view.bounds;
  moviePlayerController.movieSourceType = MPMovieSourceTypeFile;
  moviePlayerController.fullscreen = YES;
  moviePlayerController.shouldAutoplay=NO;
  
  [self.view addSubview:moviePlayerController.view];
  [moviePlayerController prepareToPlay];
  </code></pre>
  
  <p>but I am unable to write/save this video file to camera roll,this is my code for writing code to the camera roll.</p>
  
  <pre><code>  ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
    NSURL *filePathURL = [NSURL fileURLWithPath:appFile isDirectory:NO];
    if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:filePathURL]) {
      [library writeVideoAtPathToSavedPhotosAlbum:filePathURL completionBlock:^(NSURL *assetURL, NSError *error){
          if (error) {
              NSLog(@"Not success");
          } else {
              NSLog(@"success");
          }
      }];
  
  } 
  </code></pre>
  
  <p>this code is work fine when I set mimeType/file_format as .mov &amp; .3Gp but I have problem related to save video to the camera roll when mimeType/file_format as .mp4 file.  </p>