title: Is it possible to add filter effects into a Video file in Swift3 iOS
body: <p>I am developing a video editing kind of application in <code>Swift3</code> language Where I am merging multiple videos.. setting custom background sound, WaterMark and Fade In &amp; Fade Out effect to the final merged video using <code>AVFoundation</code> framework. </p>
  
  <p>Now my problem is I need to add filter effects like <code>Warm, cold, sepia/vintage</code> to the video... Is this possible to add such effects in <code>Swift iOS</code> using inbuilt libraries? I have searched in Google but not able to find proper solution: </p>
  
  <p><a href="https://stackoverflow.com/questions/4615029/rgb-range-for-cold-and-warm-colors">RGB range for cold and warm colors?</a></p>
  
  <p><a href="http://flexmonkey.blogspot.in/2016/04/loading-filtering-saving-videos-in-swift.html" rel="nofollow noreferrer">http://flexmonkey.blogspot.in/2016/04/loading-filtering-saving-videos-in-swift.html</a></p>
  
  <p><a href="https://stackoverflow.com/questions/33689050/how-to-create-and-add-video-filter-like-instagram-using-avfoundation-framework">How to create and add video filter like Instagram using AVFoundation framework - Swift programming</a></p>
  
  <p><a href="https://developer.apple.com/library/content/samplecode/RosyWriter/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011110" rel="nofollow noreferrer">https://developer.apple.com/library/content/samplecode/RosyWriter/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011110</a> </p>
  
  <p>Please advise me. Thank you!</p>
  
  <p>Edited: </p>
  
  <p>I tried using below code but it doesn't work.</p>
  
  <pre><code>let filter = CIFilter(name: "CISepiaTone")!
          let composition = AVVideoComposition(asset: firstAsset, applyingCIFiltersWithHandler: { request in
  
  
              let source = request.sourceImage.clampingToExtent()
              filter.setValue(source, forKey: kCIInputImageKey)
  
              // Vary filter parameters based on video timing
              let seconds = CMTimeGetSeconds(request.compositionTime)
              filter.setValue(seconds * 10.0, forKey: kCIInputRadiusKey)
  
  
              let output = filter.outputImage!.cropping(to: request.sourceImage.extent)
  
              // Provide the filter output to the composition
              request.finish(with: output, context: nil)
          })
  </code></pre>