如何使用iPhone SDK暂停视频录制? [英] How do i pause video recording with iPhone SDK?

查看:195
本文介绍了如何使用iPhone SDK暂停视频录制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到有一个名为iFile的应用在录制视频时具有暂停功能。他们如何做到这一点?我尝试使用AVMutableComposition类,当用户暂停时,我剪切了一个新视频,然后在最后合并视频,但是合并视频的处理时间是不可取的。

I see there is an app called iFile with a pause feature while recording video. How do they do this? I tried using AVMutableComposition classes and when the user pauses i cut a new video and then merge the video at the end, however the processing time to merge the videos is not desirable.

有人可以就如何做到这一点给我其他好主意吗?我注意到iFile方式非常无缝。

Can someone give me other good ideas on how to do this? I noticed the iFile way is very seamless.

谢谢

推荐答案

这是一些想法。我没有尝试过这两种方法。

Here are some ideas. I have not tried either of these.

如果您使用AVAssetWriter来编写捕获的图像,那么您可以在暂停时简单地删除帧。您需要跟踪所使用的最后一个演示时间戳(PTS)。然后,当您再次开始录制时,需要根据最后一个时间戳计算下一个图像PTS。使用音频执行此操作可能会有点棘手。

If you are using an AVAssetWriter to write your captured image then you can simply drop the frames while paused. You will need to keep track of the last presentation time stamp (PTS) that was used. Then you need to calculate the next image PTS based on this last time stamp when you start recording again. Doing this with audio as well might be a little trickier.

另一种方法是使用空编辑。我不确定如何使用AVAssetWriter在轨道中间插入空编辑。我知道你可以在开头和结尾插入它们。使用AVMutableCompositionTrack你可以使用insertEmptyTimeRange:其中时间范围的构造类似于

An alternate method would be to use empty edits. I am not sure how you would insert an empty edit in the middle of a track using AVAssetWriter. I know you can insert them at the beginning and end. Using AVMutableCompositionTrack you could use insertEmptyTimeRange: where the time range is constructed like

CMTime delta = CMTimeSubtract(new_sample_time, last_sample_time)
CMTimeRangeMake(last_sample_time, delta)

其中new_sample_time是取消暂停后第一个样本的时间,和last_sample_time是暂停前最后一个样本的时间。再次使用音频这可能有点棘手,因为音频缓冲区通常包含1024个样本。 CMSampleBufferGetPresentationTimeStamp返回的CMTime是第一个样本的时间。

Where new_sample_time is the time of the first sample after un-pausing, and last_sample_time is the time of the last sample before pausing. Again with audio this may be a little tricky as the buffer for audio generally contains 1024 samples. The CMTime returned by CMSampleBufferGetPresentationTimeStamp is the time of the first sample.

希望这有助于或引导您找到解决方案。

Hope this helps or leads you to a solution.

这篇关于如何使用iPhone SDK暂停视频录制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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