首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何设置10秒的录像限制并实时删除10秒的旧胶片部分-- Swift iOS

如何设置10秒的录像限制并实时删除10秒的旧胶片部分-- Swift iOS
EN

Stack Overflow用户
提问于 2014-12-27 06:43:33
回答 3查看 8.1K关注 0票数 2

如果标题真的令人困惑,我可以理解,但我会尽我最大努力更详细地解释!我有一个iOS Swift应用程序的计划,将录制一个视频的时间限制为10秒。但当剪辑达到10秒时,它不应停止录制。它应该删除剪辑的结尾,这样它就不会超过10秒。所以它不会占用太多内存。当有人按下“停止录制”按钮时,它会将其保存到相机胶卷中。

我已经在网上搜索过这样的东西,但我没有找到任何有用的东西。你知道一个好的教程或者源代码吗?

//提前谢谢,安东

EN

回答 3

Stack Overflow用户

发布于 2015-04-03 23:08:29

使用属性:

videoMaximumDuration

票数 11
EN

Stack Overflow用户

发布于 2016-05-22 11:51:32

你有一个令人困惑的问题。您不想停止录制,但只想删除剪辑的结尾?为什么不在10秒后停止录制?

你可以使用dispatch_time来停止,对我来说很有效:

代码语言:javascript
复制
func captureOutput(captureOutput: AVCaptureFileOutput!, didStartRecordingToOutputFileAtURL fileURL: NSURL!, fromConnections connections: [AnyObject]!) {

    captureOutput.maxRecordedDuration = CMTimeMake(10, 1)

    /* After 10 seconds, let's stop the recording process */
    let delayInSeconds = 10.0
    let delayInNanoSeconds = dispatch_time(DISPATCH_TIME_NOW, Int64(delayInSeconds * Double(NSEC_PER_SEC)))
    dispatch_after(delayInNanoSeconds, dispatch_get_main_queue(), {
        captureOutput.stopRecording()
    })

    return
}
票数 3
EN

Stack Overflow用户

发布于 2018-03-29 18:55:07

如果在将AVCaptureMovieFileOutput添加到AVCaptureSession时,使用AVFoundation录制应设置最长录制时长。

代码语言:javascript
复制
private let session = AVCaptureSession()
private let movieOutput = AVCaptureMovieFileOutput()

movieOutput.maxRecordedDuration = CMTime(seconds: 10, preferredTimescale: 600)
if session.canAddOutput(movieOutput) {
    session.addOutput(movieOutput)
}

在最大录制持续时间后,将调用fileOutput(didFinishRecordingTo:from:error:),并将您的视频保存到指定的URL,持续时间比最大值低一些毫秒。请注意,错误不会为零。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27662727

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档