如何在录制视频时以编程方式拍摄照片 [英] How to Programmatically Take Photos While Recording Video

查看:201
本文介绍了如何在录制视频时以编程方式拍摄照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iPhone 5S能够在录制视频时拍照,我正在试图弄清楚如何以编程方式执行此操作。我知道我会使用AVFoundation,但是,我在编程指南。我还检查了示例项目(与AVFoundation相关)并且看起来没有任何东西能够满足我的需求。如果你可以帮我指出一个很好的方向。

The iPhone 5S is capable of taking pictures while recording video and I am trying to figure out how I would do this programatically. I know I would be utilizing AVFoundation, however, I couldn't find anything in the programming guide regarding this. I have also checked the sample projects (AVFoundation-related) and it doesn't look like there is anything there that does what I am looking for. if you could help point me in the right direction that would be great.

推荐答案

实际上你可以用任何能够录制视频:

Actually you can do it with any device that can record video:


  • 创建并配置 AVCaptureVideoDataOutput

  • 将其添加到您的 AVCaptureSession

  • 添加 AVCaptureVideoDataOutputSampleBufferDelegate

  • 在委托中实现 captureOutput:didOutputSampleBuffer:fromConnection:并使用 imageFromSampleBuffer获取图像:

  • Create and configure a AVCaptureVideoDataOutput.
  • Add it to your AVCaptureSession.
  • Add a AVCaptureVideoDataOutputSampleBufferDelegate.
  • Implement captureOutput:didOutputSampleBuffer:fromConnection: in the delegate and get the image with imageFromSampleBuffer:.

可以找到一些类似的代码这里,其中以给定间隔捕获图像,但您只需要一个图像。

Some similar code can be found here, where images are captured at a given interval, but you only want one image.

这篇关于如何在录制视频时以编程方式拍摄照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆