如果标题真的令人困惑,我可以理解,但我会尽我最大努力更详细地解释!我有一个iOS Swift应用程序的计划,将录制一个视频的时间限制为10秒。但当剪辑达到10秒时,它不应停止录制。它应该删除剪辑的结尾,这样它就不会超过10秒。所以它不会占用太多内存。当有人按下“停止录制”按钮时,它会将其保存到相机胶卷中。
我已经在网上搜索过这样的东西,但我没有找到任何有用的东西。你知道一个好的教程或者源代码吗?
//提前谢谢,安东
发布于 2015-04-03 23:08:29
使用属性:
发布于 2016-05-22 11:51:32
你有一个令人困惑的问题。您不想停止录制,但只想删除剪辑的结尾?为什么不在10秒后停止录制?
你可以使用dispatch_time来停止,对我来说很有效:
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
}发布于 2018-03-29 18:55:07
如果在将AVCaptureMovieFileOutput添加到AVCaptureSession时,使用AVFoundation录制应设置最长录制时长。
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,持续时间比最大值低一些毫秒。请注意,错误不会为零。
https://stackoverflow.com/questions/27662727
复制相似问题