在iPhone应用程序中捕获60fps [英] Capture 60fps in iPhone app

查看:145
本文介绍了在iPhone应用程序中捕获60fps的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个项目,我们将使用iPhone作为捕捉场景的相机。录制时我们需要录制@ 60fps而不是30fps(原生支持)。所以我正在开发一款应用程序来实现这一点,因为iPhone 4S硬件支持720p @ 60fps(如果你越狱你的手机你可以实现这一点)。

I am working on a project where we will be using iPhones as cameras for capturing a scene. When recording we need to record @60fps and not 30fps (as natively supported). So I am working on an app to do this as the iPhone 4S hardware supports 720p@60fps (if you jailbreak your phone you can achieve this).

有谁知道如何在iOS上的Objective-C中执行此操作?今天我看到一个应用程序(slopro)可以在非越狱手机上录制60fps。非常感谢任何建议或提示。

Does anybody know how to do this in Objective-C on iOS? Today I saw an app out there (slopro) that can record 60fps on non jailbroken phones. Any advice or tips is much appreciated.

推荐答案

经过一些修补,这个答案分为两部分:

After some tinkering, this answer has split into two parts:

如何以60帧的速度捕获帧

iPhone4s / 5.1上的AVCaptureSessionPreset1280x720,帧持续时间设置为至:

The AVCaptureSessionPreset1280x720 on the iPhone4s/5.1, with frame durations set to:

connection.videoMinFrameDuration = CMTimeMake(1, 60);*
connection.videoMaxFrameDuration = CMTimeMake(1, 60);

为您提供稳定,超顺畅的捕捉。

gives you a stable, super smooth capture.

如何将帧捕获到文件中@ 60fps

捕获帧非常好,但大概你想要保留它们。

正如Brad在评论中指出的那样,将这些帧写入文件是另一回事。
可悲的是,无论我尝试什么配置,通过 AVAssetWriter 对帧进行编码都会导致捕获率下降到观察到的~37fps并且无法摆弄 alwaysDiscardsLateVideoFrames 可以更改它。然而,在这种方法中,每一帧都从AVFoundation复制到你的应用程序,然后再回来,这对于公共汽车来说是毫无意义的。幸运的是, AVFoundation 有一个类可以删除此往返: AVCaptureMovieFileOutput

How to capture frames into a file @60fps
Capturing frames is all very well, but presumably you want to keep them.
As Brad noted in the comments, writing those frames to a file is another story. Sadly, no matter what configurations I tried, encoding the frames via an AVAssetWriter caused the capture rate to drop to the observed ~37fps and no amount of fiddling with alwaysDiscardsLateVideoFrames could change it. However, in this approach every single frame is copied from AVFoundation to your app, and then back again, which is quite pointless and very wearing for the bus. Luckily, AVFoundation has a class that removes this round trip: AVCaptureMovieFileOutput.

如果你让 AVFoundation 为你写作,那么iPhone4S可以以60fps *的速度捕捉和编码帧+音频到.mov文件,而不会出汗( ~25%CPU)。

If you let AVFoundation do the writing for you then the iPhone4S can capture and encode frames + audio to a .mov file at 60fps* without breaking a sweat (~25% CPU).

虽然60fps视频捕捉功能很棒,但我不禁感到有些失望,因为 AVCaptureMovieFileOutput 排除了许多有趣的事情(例如使用GL着色器的实时效果,记录开始/停止而没有帧丢失)。

While 60fps video capture is great feature, I can't help but feel a little disappointed as AVCaptureMovieFileOutput rules out a lot of fun things (e.g. realtime effects with GL shaders, recording start/stop without frame loss).

cake / eat it

cake/eat it

* 59如果你还在运行iOS 5.0.1

*59 if you're still running iOS 5.0.1

这篇关于在iPhone应用程序中捕获60fps的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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