title: Trimming video with Monotouch fails with "The operation could not be completed"
body: <p>I am trying to trim a video to 5 seconds programmatically. Here is my implementation.</p>
  
  <pre><code>AVAssetExportSession exportSession= new AVAssetExportSession(videoAsset,AVAssetExportSession.PresetLowQuality.ToString());
              int SystemVersion = Convert.ToInt16(UIDevice.CurrentDevice.SystemVersion.Split('.')[0]);
              string filename;
              if (SystemVersion &gt;= 8)
              {
                  var documents = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User)[0].Path;
                  filename = Path.Combine(documents, "trimmed.mov");
              }
              else
              {
                  var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // iOS 7 and earlier
                  filename = Path.Combine(documents, "trimmed.mov");
              }
              outputUrl=new NSUrl(filename);
              exportSession.OutputUrl = outputUrl;
  
              CMTime start = new CMTime((long)1, 1);
  
              CMTime duration = new CMTime((long)5, 1);
  
              CMTimeRange range = new CMTimeRange();
              range.Start=start;
              range.Duration=duration;
              exportSession.TimeRange = range;
  
              exportSession.OutputFileType = AVFileType.QuickTimeMovie;
              ExportTrimmedVideo( exportSession);
  async void ExportTrimmedVideo(AVAssetExportSession exportSession)
      {
          await exportSession.ExportTaskAsync ();
          if (exportSession.Status == AVAssetExportSessionStatus.Completed) {
              InvokeOnMainThread (() =&gt; {
                  new UIAlertView ("Export Sucess", "Video is trimmed", null, "O K").Show ();
              });
          }
          else 
          {
              InvokeOnMainThread (() =&gt; {
                  new UIAlertView ("Export Falure", exportSession.Error.Description, null, "O K").Show ();
              });
          }
  }
  </code></pre>
  
  <p>But in completion I am getting a Filed Status. Full <code>NSError</code> Description is as follows</p>
  
  <pre><code>Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x7cebcf80 {NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x7cb08410 "The operation couldn’t be completed. (OSStatus error -12105.)", NSLocalizedFailureReason=An unknown error occurred (-12105)}
  </code></pre>
  
  <p>What am I possibly doing wrong ?</p>
  
  <h2>Edit</h2>
  
  <p>I have referred apple's <a href="https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/01_UsingAssets.html" rel="nofollow noreferrer">documentation</a> on Trimming video and have modified the above code with no positive effect as below.</p>
  
  <pre><code>var compatiblePresets= AVAssetExportSession.ExportPresetsCompatibleWithAsset(videoAsset).ToList();
              var preset="";
              if(compatiblePresets.Contains("AVAssetExportPresetLowQuality"))
              {
                  preset="AVAssetExportPresetLowQuality";
              }
              else
              {
                  preset=compatiblePresets.FirstOrDefault();
              }
              AVAssetExportSession exportSession= new AVAssetExportSession(videoAsset,preset);
              int SystemVersion = Convert.ToInt16(UIDevice.CurrentDevice.SystemVersion.Split('.')[0]);
              string filename;
              if (SystemVersion &gt;= 8)
              {
                  var documents = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User)[0].Path;
                  filename = Path.Combine(documents, "trimmed.mov");
              }
              else
              {
                  var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // iOS 7 and earlier
                  filename = Path.Combine(documents, "trimmed.mov");
              }
              outputUrl=new NSUrl(filename);
              exportSession.OutputUrl = outputUrl;
              exportSession.OutputFileType = AVFileType.QuickTimeMovie;
              CMTime start = new CMTime((long)1, 600);
  
              CMTime duration = new CMTime((long)5, 600);
  
              CMTimeRange range = new CMTimeRange();
              range.Start=start;
              range.Duration=duration;
              exportSession.TimeRange = range;
  
  
              ExportTrimmedVideo( exportSession);
  </code></pre>