Exporting AVCaptureSession video in a size that matches the preview layer

前端 未结 1 1000
失恋的感觉
失恋的感觉 2021-02-06 07:04

I\'m recording video using AVCaptureSession with the session preset AVCaptureSessionPreset640x480. I\'m using an AVCaptureVideoPreviewLayer

相关标签:
1条回答
  • 2021-02-06 07:10

    Video Resolution and Video Size are two different things. Resolution stands for clarity, higher resolution means higher clarity. Whereas, Video size is the bounds in which to display the video. Depending on the video resolution and aspect ratio of the video, the video will stretch or shrink, when seen in the viewer.

    Now as the facts have been explained, You can find Your answer here:

    How do I use AVFoundation to crop a video

    Perform the steps in this order:

    1. Record Video to disk.
    2. Save from Disk to asset library.
    3. Delete from disk.
    4. Perform the steps mentioned in the above link.

    NOTE: Perform the steps after recording and writing your video to asset library, saveComposition being the saved asset.

    and provide your size in this step:videoComposition.renderSize = CGSizeMake(320, 240); as videoComposition.renderSize = CGSizeMake(300, 300);

    And an advice. Since writing the file to disk, then to library, then again back to disk is kind of a lengthy operation. Try doing it all asynchronously using a dispatch_queue or operationBlock

    Cheers, Have Fun.

    0 讨论(0)
提交回复
热议问题