5

I capture video using AVCaptureSession session preset is

session!.sessionPreset = AVCaptureSessionPreset1280x720

and extract image from video using this code

func videoThumbnails(url: NSURL ){
    let asset = AVAsset(URL: url)
    let imageGenerator = AVAssetImageGenerator(asset: asset)
    imageGenerator.appliesPreferredTrackTransform = true
    imageGenerator.maximumSize = CGSizeMake(720, 1280)
    imageGenerator.requestedTimeToleranceAfter = kCMTimeZero

    var time = asset.duration
    let totalTime = time
    var frames = 0.0
    let singleFrame = Double(time.seconds) / 4
    while (frames < totalTime.seconds) {
        frames += singleFrame
        time.value = (Int64(frames)) * Int64(totalTime.timescale)
        do {

            let imageRef = try imageGenerator.copyCGImageAtTime(time, actualTime: nil)

            self.sendImage.append(UIImage(CGImage: imageRef))
        }
        catch let error as NSError
        {
            print("Image generation failed with error \(error)")

        }
    }

    self.performSegueWithIdentifier("showCapturedImages", sender: nil)

}

Now you can check image above the video so that you can check color difference.

enter image description here

Now what I want is extract exact image from video. how to do?

Muhammad Raza
  • 952
  • 7
  • 24
  • It just seems a part of the UI of your application – Andrea Mar 02 '17 at 15:56
  • No its not. I extract the image from video and just show it above the video with exact position using UIImage above AVPlayerViewController. and when I export the video it is still the same with that color issue. – Muhammad Raza Mar 03 '17 at 07:25
  • There are plenty of possible causes: the inner image is resized to fit the area, how you set the camera ( the frames are usually in YUV but probably it converts to RGB), compression etc – Andrea Mar 03 '17 at 08:22
  • 1
    so, how to resolve this thing.? – Muhammad Raza Mar 03 '17 at 12:28

0 Answers0